diff --git a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs index 8167fc1ab..8d6b68b67 100644 --- a/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs +++ b/ICSharpCode.Decompiler.Tests/Helpers/Tester.cs @@ -348,7 +348,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers preprocessorSymbols.Add("CS100"); if (flags.HasFlag(CompilerOptions.Preview)) { - + preprocessorSymbols.Add("CS110"); } } } diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index ef79a1359..5f98e53ab 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -616,6 +616,11 @@ namespace ICSharpCode.Decompiler.Tests [Test] 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); } diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs index fd093f84a..df63a3635 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CustomAttributes.cs @@ -40,6 +40,18 @@ namespace CustomAttributes { } } +#if CS110 + [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] + public class GenericAttribute : Attribute + { + public GenericAttribute() + { + } + public GenericAttribute(T val) + { + } + } +#endif [My(ULongEnum.MaxUInt64)] public enum ULongEnum : ulong { @@ -145,5 +157,14 @@ namespace CustomAttributes public static void BoxedLiteralsArray() { } +#if CS110 + [Generic] + [Generic] + 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 } } diff --git a/ICSharpCode.Decompiler/CSharp/CSharpLanguageVersion.cs b/ICSharpCode.Decompiler/CSharp/CSharpLanguageVersion.cs index 375a9de66..87314b0c4 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpLanguageVersion.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpLanguageVersion.cs @@ -33,7 +33,8 @@ namespace ICSharpCode.Decompiler.CSharp CSharp8_0 = 800, CSharp9_0 = 900, CSharp10_0 = 1000, - Preview = 1000, + CSharp11_0 = 1100, + Preview = 1100, Latest = 0x7FFFFFFF } }