-
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
Test plan for "generic attributes" #36285
Comments
|
Hello, I see that this feature has been merged, however it is still in "Preview". And also it has been added to the C# Next table instead of the C# 10 table. |
@csaba-sagi-sonarsource It's waiting until C# 11 due to some issues with the tools and an unresolved runtime issue about how |
Basically, if you install .NET 6 and use |
I don't know if this is fully related but the following logic fails when trying to resolve a Generic Attribute using the MetadataReader - it results in an exception of:
Maybe I am doing something wrong below - but I am not sure, can't really find much information about the The following line throws the exception: TypeReference refType = reader.GetTypeReference((TypeReferenceHandle)refConstructor.Parent); which is in: internal static (StringHandle? parsedNamespace, StringHandle? parsedName) ParseCustomAttribute(MetadataReader reader, CustomAttribute attribute)
{
switch (attribute.Constructor.Kind)
{
case HandleKind.MemberReference:
MemberReference refConstructor = reader.GetMemberReference((MemberReferenceHandle)attribute.Constructor);
if (refConstructor.Parent.IsNil)
{
Debug.Assert(false, "Unknown parent reference kind");
return (null, null);
}
switch (refConstructor.Parent.Kind)
{
case HandleKind.TypeReference:
TypeReference refType = reader.GetTypeReference((TypeReferenceHandle)refConstructor.Parent);
return (refType.Namespace, refType.Name);
default:
Debug.Assert(false, "Unknown parent reference kind");
return (null, null);
}
case HandleKind.MethodDefinition:
MethodDefinition defConstructor = reader.GetMethodDefinition((MethodDefinitionHandle)attribute.Constructor);
TypeDefinition defType = reader.GetTypeDefinition(defConstructor.GetDeclaringType());
return (defType.Namespace, defType.Name);
default:
Debug.Assert(false, "Unknown attribute constructor kind");
return (null, null);
}
} I am using DotNet 8 and |
Closing out the test plan as the feature has shipped. If you are still experiencing a problem related to the feature, please file a new issue. |
Championed issue
Latest LDM notes.
Specification
csharplang
(https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/generic-attributes.md)Compiler
MyAttribute<T>
andMy<T>
are present (bug Generic attributes don't properly resolve ambiguity with verbatim identifier #54772)where T : INumeric<..>
then argument isIIntegral
Obsolete<T>
)Attribute.GetCustomAttributes(typeof(Program), typeof(Attr<>))
Productivity
The text was updated successfully, but these errors were encountered: