-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
In order to reflect nullability in constraint types, compiler emits Nullable attribute for rows in GenericParamConstraint metadata table #29997
Comments
Tagging @safern @stephentoub @agocke The issue is that we're using metadata representation which is legal but not representable in IL. At this point in the release cycle, I think we will stick with this design unless there is a major problem and we have a viable alternative. I'll keep this issue open for another week or two to give you the chance to chime in, then I'll close. |
cc: @jkotas |
Does this mean that you won't be able to round-trip these assemblies using ildasm/ilasm? Number of folks out there who depend on ilasm/ildasm round-tripping as part of their build... |
That's correct. We would need to update ildasm/ilasm to allow such round-tripping. @AlekseyTs Could you add details on the method implementation scenario (where is the attribute placed?). Thanks |
Also, what about Cecil and all tools build on top of it? (e.g. https://github.com/mono/linker that is officially supported tool for .NET Core 3.0) |
I was talking about interface implementations. I do not think we emit any attributes for MethodIlmpls. |
As simple as |
It looks like the interface implementation scenario is supported by IL/ilasm/ildasm after all. See details below. Interface implementation appears to be supported:From the following C#: #nullable enable
public interface I<T> { }
public interface I2<T> { }
public class D<T, U> : I<T?>, I2<U> where T : class where U : class
{
} ildasm produces the following IL:
And ildasm produces the following MetaInfo:
|
Are the attributes on generic param constraints going to be emitted in 3.0? |
Yes. They will be emitted by anyone using C# 8.0 (nullability analysis feature), which ships with Core 3.0. |
@jcouv is there a scenario where in the metadata you could generate a |
In general, yes. See AssemblyAttributesGoHere type and the like, for example? However, compiler never attaches NullableAttribute to a TypeRef. |
@AlekseyTs I know the metadata format allows it. Just wanted to make sure that adding support for custom attributes on generic parameter constraints is enough to support this feature we're discussing. |
Closing as the runtime team added support for this in the ilasm / ildasm toolset. Can re-open if it's not sufficient. |
For nullability support. Mono.Cecil introduced a breaking change in jbevain/cecil#594 because of dotnet/roslyn#29997
For nullability support. Mono.Cecil introduced a breaking change in jbevain/cecil#594 because of dotnet/roslyn#29997
It looks like there is no syntax to represent this in IL. Is this a problem?
Example:
class C<T> where T : Interface?
corefx should pick up new ILLinker(this is a corefx internal decision, the public facing reference assemblies will be correct in Core 3)Relates to dotnet/linker#626
The text was updated successfully, but these errors were encountered: