dotnet/roslyn

Missing CS8970 when applying attribute alias with unsupported type substitution

Closed

#58,836 opened on Jan 13, 2022

 (2 comments) (1 reaction) (1 assignee)C# (4,257 forks)batch import
Area-CompilersBughelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

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.

Contributor guide