Skip to content
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

Closed
21 of 25 tasks
jcouv opened this issue Jun 10, 2019 · 6 comments
Closed
21 of 25 tasks

Test plan for "generic attributes" #36285

jcouv opened this issue Jun 10, 2019 · 6 comments
Assignees
Labels
Area-Compilers Test Test failures in roslyn-CI Test-Gap Describes a specific feature or scenario that does not have test coverage
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Jun 10, 2019

Championed issue
Latest LDM notes.

Specification

Compiler

Productivity

  • verify typing, highlighting, formatting and completion behavior in IDE
@jcouv jcouv self-assigned this Jun 10, 2019
@jcouv jcouv added this to the Compiler.Next milestone Jun 24, 2019
@gafter gafter modified the milestones: Compiler.Next, 16.4 Aug 4, 2019
@jcouv jcouv modified the milestones: 16.4, Compiler.Next Aug 21, 2019
@gafter gafter added the Test Test failures in roslyn-CI label Oct 14, 2019
@jcouv jcouv modified the milestones: Compiler.Next, Compiler.Net5 Dec 11, 2019
@gafter gafter added the Test-Gap Describes a specific feature or scenario that does not have test coverage label Jan 2, 2020
@jaredpar jaredpar modified the milestones: Compiler.Net5, 16.8 Jun 23, 2020
@jcouv jcouv modified the milestones: 16.8, Compiler.Next Jul 7, 2020
@RikkiGibson RikkiGibson self-assigned this Jul 20, 2021
@tmat
Copy link
Member

tmat commented Jul 23, 2021

  • Add EnC compiler and IDE test

@csaba-sagi-sonarsource
Copy link

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.
Will this feature make it to the C# 10 release or not?

@PathogenDavid
Copy link
Contributor

@csaba-sagi-sonarsource It's waiting until C# 11 due to some issues with the tools and an unresolved runtime issue about how CustomAttributeData.GetCustomAttributes should handle them. (See dotnet/csharplang#124 (comment) for more details and further discussion.)

@RikkiGibson
Copy link
Contributor

Basically, if you install .NET 6 and use <LangVersion>preview</LangVersion> in your project you should be able to use the feature.

@jcouv jcouv modified the milestones: Compiler.Next, 17.0 Sep 26, 2022
@ThaDaVos
Copy link

ThaDaVos commented Dec 8, 2023

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:

Unhandled exception. System.InvalidCastException: Specified cast is not valid.
     at System.Reflection.Throw.InvalidCast()
     at System.Reflection.Metadata.TypeReferenceHandle.op_Explicit(EntityHandle handle)
     at DNNE.Assembly.Attributors.Attributor.ParseCustomAttribute(MetadataReader reader, CustomAttribute attribute)
     at DNNE.Assembly.Attributors.Attributor.IsApplicable(MetadataReader reader, CustomAttribute attribute, Boolean isReturn)
     at DNNE.Assembly.AssemblyReader.<>c__DisplayClass12_0.<Read>b__0(IAttributor attributor)
     at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
     at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
     at DNNE.Assembly.AssemblyReader.Read()
     at DNNE.Program.Main(String[] args)

Maybe I am doing something wrong below - but I am not sure, can't really find much information about the MetadataReader and trying to add support for certain features to DNNE:

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 <LangVersion>preview</LangVersion> inside my project and inside DNNE

@RikkiGibson
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Test Test failures in roslyn-CI Test-Gap Describes a specific feature or scenario that does not have test coverage
Projects
None yet
Development

No branches or pull requests

8 participants