From d723104a69e5c5eba585eaddc5aad33028731eca Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 1 Jun 2022 13:34:21 -0600 Subject: [PATCH 1/2] Suppress CS8981 in generated code --- src/Microsoft.Windows.CsWin32/Generator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.Windows.CsWin32/Generator.cs b/src/Microsoft.Windows.CsWin32/Generator.cs index d4245321..dd91f10c 100644 --- a/src/Microsoft.Windows.CsWin32/Generator.cs +++ b/src/Microsoft.Windows.CsWin32/Generator.cs @@ -282,6 +282,7 @@ public class Generator : IDisposable "CS1584", // C# bug: https://github.com/microsoft/CsWin32/issues/24 "CS1658", // C# bug: https://github.com/microsoft/CsWin32/issues/24 "CS0436", // conflicts with the imported type (InternalsVisibleTo between two projects that both use CsWin32) + "CS8981", // The type name only contains lower-cased ascii characters }; private static readonly SyntaxTriviaList FileHeader = ParseLeadingTrivia(AutoGeneratedHeader).Add( From 5d9bc8b6b52c15d58433dbe584b07ff93e44b2c1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 2 Jun 2022 09:50:31 -0600 Subject: [PATCH 2/2] Fix verbatim tests and add a trait to them --- .../GeneratorTests.cs | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs index 3aa52507..2cd4f328 100644 --- a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs +++ b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs @@ -35,7 +35,7 @@ public class GeneratorTests : IDisposable, IAsyncLifetime // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 [assembly: global::System.Reflection.AssemblyMetadata(""Microsoft.Windows.CsWin32"",""{ThisAssembly.AssemblyInformationalVersion}"")] ".Replace("\r\n", "\n"); @@ -1406,7 +1406,7 @@ public void ProjectReferenceBetweenTwoGeneratingProjects(bool internalsVisibleTo this.AssertNoDiagnostics(); } - [Fact] + [Fact, Trait("Verbatim", "true")] public async Task TestSimpleStructure() { await new VerifyTest @@ -1433,7 +1433,7 @@ public async Task TestSimpleStructure() // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1468,7 +1468,7 @@ public static unsafe implicit operator bool(BOOL value) }.RunAsync(); } - [Fact] + [Fact, Trait("Verbatim", "true")] public async Task TestSimpleEnum() { await new VerifyTest @@ -1496,7 +1496,7 @@ public async Task TestSimpleEnum() // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1534,7 +1534,7 @@ internal enum DISPLAYCONFIG_SCANLINE_ORDERING }.RunAsync(); } - [Fact] + [Fact, Trait("Verbatim", "true")] public async Task TestSimpleEnumWithoutDocs() { await new VerifyTest @@ -1562,7 +1562,7 @@ public async Task TestSimpleEnumWithoutDocs() // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1590,7 +1590,7 @@ internal enum DISPLAYCONFIG_SCANLINE_ORDERING }.RunAsync(); } - [Fact] + [Fact, Trait("Verbatim", "true")] public async Task TestFlagsEnum() { await new VerifyTest @@ -1618,7 +1618,7 @@ public async Task TestFlagsEnum() // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1667,7 +1667,7 @@ internal enum FILE_ACCESS_FLAGS : uint }.RunAsync(); } - [Fact] + [Fact, Trait("Verbatim", "true")] public async Task TestSimpleDelegate() { await new VerifyTest @@ -1694,7 +1694,7 @@ public async Task TestSimpleDelegate() // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1733,7 +1733,7 @@ public static unsafe implicit operator bool(BOOL value) // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1758,7 +1758,7 @@ namespace UI.WindowsAndMessaging // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1798,7 +1798,7 @@ internal readonly partial struct HWND // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1834,7 +1834,7 @@ internal readonly partial struct LPARAM }.RunAsync(); } - [Fact] + [Fact, Trait("Verbatim", "true")] public async Task TestSimpleMethod() { await new VerifyTest @@ -1862,7 +1862,7 @@ public async Task TestSimpleMethod() // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1904,7 +1904,7 @@ internal readonly partial struct HDC // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1944,7 +1944,7 @@ internal readonly partial struct HWND // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -1979,7 +1979,7 @@ internal static partial class PInvoke }.RunAsync(); } - [Fact] + [Fact, Trait("Verbatim", "true")] public async Task TestMethodWithOverloads() { await new VerifyTest @@ -2006,7 +2006,7 @@ public async Task TestMethodWithOverloads() // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2045,7 +2045,7 @@ public static unsafe implicit operator bool(BOOL value) // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2098,7 +2098,7 @@ internal enum FILE_ACCESS_FLAGS : uint // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2129,7 +2129,7 @@ internal enum FILE_CREATION_DISPOSITION : uint // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2201,7 +2201,7 @@ internal enum FILE_FLAGS_AND_ATTRIBUTES : uint // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2232,7 +2232,7 @@ internal enum FILE_SHARE_MODE : uint // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2274,7 +2274,7 @@ internal readonly partial struct HANDLE // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2351,7 +2351,7 @@ internal int Length // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2457,7 +2457,7 @@ internal static unsafe Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(str // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System; @@ -2517,7 +2517,7 @@ internal int Length // // ------------------------------------------------------------------------------ -#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436 +#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981 namespace Windows.Win32 { using global::System;