dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.05k stars 4.04k forks source link

Missing CS8970 when applying attribute alias with unsupported type substitution #58836

Open akarpov89 opened 2 years ago

akarpov89 commented 2 years ago

Version Used: sharplab.io main 6 Jan 2022

Steps to Reproduce:

Compile the following code:

using System;

using SomeDynamicAlias = Some<dynamic>;
using SomeNamedTupleAlias = Some<(int X, int Y)>;

[SomeDynamicAlias]     // no error but should be
[SomeNamedTupleAlias]  // no error but should be
[Some<dynamic>]        // error
[Some<(int X, int Y)>] // error
public class C
{    
}

[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
class Some<T> : Attribute
{  
}

Expected Behavior: Error CS8970 on every attribute application including aliases.

Actual Behavior: No CS8970 when applying alias with unsupported type substitution.

Joe4evr commented 2 years ago

💭 There should be an error on the declaration of the alias at least (currently not the case). Not sure how much added value there is to report again on usage sites after that.

jcouv commented 2 years ago

@RikkiGibson for triage. Thanks