Browse Source

Add test for C# 11 generic attribute

pull/2639/head
Daniel Grunwald 3 years ago
parent
commit
a9f4694563
  1. 2
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  2. 5
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 21
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs
  4. 3
      ICSharpCode.Decompiler/CSharp/CSharpLanguageVersion.cs

2
ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

@ -348,7 +348,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
preprocessorSymbols.Add("CS100"); preprocessorSymbols.Add("CS100");
if (flags.HasFlag(CompilerOptions.Preview)) if (flags.HasFlag(CompilerOptions.Preview))
{ {
preprocessorSymbols.Add("CS110");
} }
} }
} }

5
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -616,6 +616,11 @@ namespace ICSharpCode.Decompiler.Tests
[Test] [Test]
public async Task CustomAttributes([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions) public async Task CustomAttributes([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{ {
if (cscOptions.HasFlag(CompilerOptions.UseRoslynLatest))
{
// Test C# 11 generic attributes
cscOptions |= CompilerOptions.Preview;
}
await RunForLibrary(cscOptions: cscOptions); await RunForLibrary(cscOptions: cscOptions);
} }

21
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs

@ -40,6 +40,18 @@ namespace CustomAttributes
{ {
} }
} }
#if CS110
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public class GenericAttribute<T> : Attribute
{
public GenericAttribute()
{
}
public GenericAttribute(T val)
{
}
}
#endif
[My(ULongEnum.MaxUInt64)] [My(ULongEnum.MaxUInt64)]
public enum ULongEnum : ulong public enum ULongEnum : ulong
{ {
@ -145,5 +157,14 @@ namespace CustomAttributes
public static void BoxedLiteralsArray() public static void BoxedLiteralsArray()
{ {
} }
#if CS110
[Generic<int>]
[Generic<string>]
public static void UseGenericAttribute()
{
}
// TODO: add test for generic attributes with arguments of type T
// This is blocked by https://github.com/dotnet/runtime/issues/58073
#endif
} }
} }

3
ICSharpCode.Decompiler/CSharp/CSharpLanguageVersion.cs

@ -33,7 +33,8 @@ namespace ICSharpCode.Decompiler.CSharp
CSharp8_0 = 800, CSharp8_0 = 800,
CSharp9_0 = 900, CSharp9_0 = 900,
CSharp10_0 = 1000, CSharp10_0 = 1000,
Preview = 1000, CSharp11_0 = 1100,
Preview = 1100,
Latest = 0x7FFFFFFF Latest = 0x7FFFFFFF
} }
} }

Loading…
Cancel
Save