roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Missing CS8970 when applying attribute alias with unsupported type substitution

Open akarpov89 opened this issue 3 years ago • 2 comments

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.

akarpov89 avatar Jan 13 '22 13:01 akarpov89

💭 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.

Joe4evr avatar Jan 13 '22 14:01 Joe4evr

@RikkiGibson for triage. Thanks

jcouv avatar Mar 01 '22 08:03 jcouv