Skip to content

C# 8.0: unmanaged constructed types #14198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 5, 2019
Merged

C# 8.0: unmanaged constructed types #14198

merged 8 commits into from
Sep 5, 2019

Conversation

pkulikov
Copy link
Contributor

@pkulikov pkulikov commented Sep 4, 2019

Fixes #14101
Supported by dotnet/samples#1411

@BillWagner
Copy link
Member

This is a great start @pkulikov There's a couple scenarios that we should cover, but it may require a slightly different sample. For discussion, I'll use the Coords<T> type you've defined.

We should explain that if the type argument is not an unmanaged type, the constructed type is not unmanaged:

var objCoords = new Coords<object>();

That's a contrived example, but you see the point.

It is also interesting that adding the unmanaged constraint would mean that any constructed type would be an unmanaged type:

public struct Coords<T> where T : unmanaged
~
    public T X;
    public T Y;
}

Thoughts on how to update to make those two points?

@pkulikov
Copy link
Contributor Author

pkulikov commented Sep 4, 2019

@BillWagner

We should explain that if the type argument is not an unmanaged type...

I understand what you mean, but wording should be different. Type argument can be a reference type. Not practical example:

public struct Coords<T>
{
    public int X;
    public int Y;
}

With that definition, Coords<T> is unmanaged for any type argument. All fields are of an unmanaged type, regardless of the type argument.

I'll think how to update the article.

@pkulikov
Copy link
Contributor Author

pkulikov commented Sep 4, 2019

@BillWagner please take a look at the latest commit; I've also added one more snippet to the sample PR.

@pkulikov
Copy link
Contributor Author

pkulikov commented Sep 5, 2019

ok, I think the current edition is final. What do you think @BillWagner?

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work again @pkulikov

I had one small grammar nit to consider, and then I'll :shipit:

@BillWagner BillWagner merged commit e114a06 into dotnet:master Sep 5, 2019
@pkulikov pkulikov deleted the unmanaged-constructed-types branch September 5, 2019 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C# 8.0 - unmanaged constructed types
2 participants