From e25e34544a9261d608ae8846a9b320ade8d39bd4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 23 May 2023 14:15:20 -0700 Subject: [PATCH 1/3] Add newly introduced modifiers to our csharp_preferred_modifier_order editorconfig --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 91d15d8df5b2d4..2d2860549c8f7a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -36,7 +36,7 @@ csharp_indent_switch_labels = true csharp_indent_labels = one_less_than_current # Modifier preferences -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion # avoid this. unless absolutely necessary dotnet_style_qualification_for_field = false:suggestion From 3658d0f65d097225bde07f8e1c147223877bdfc0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 8 Jun 2023 15:37:57 -0700 Subject: [PATCH 2/3] Fix places that were using the old incorrect modifier order. --- .../Marshalling/ElementsMarshalling.cs | 4 +--- .../UnmanagedToManagedOwnershipTrackingStrategy.cs | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs index c3e5a82f627c3f..9f4c2b8e1a7e29 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs @@ -57,9 +57,7 @@ public StatementSyntax GenerateClearUnmanagedValuesSource(TypePositionInfo info, public abstract StatementSyntax GenerateElementCleanupStatement(TypePositionInfo info, StubCodeContext context); } -#pragma warning disable SA1400 // Access modifier should be declared https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3659 - static file class ElementsMarshallingCollectionSourceExtensions -#pragma warning restore SA1400 // Access modifier should be declared + file static class ElementsMarshallingCollectionSourceExtensions { public static StatementSyntax GetNumElementsAssignmentFromManagedValuesSource(this IElementsMarshallingCollectionSource source, TypePositionInfo info, StubCodeContext context) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs index 434354715d7952..c170ef9be7983c 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs @@ -168,9 +168,7 @@ IEnumerable GenerateStatementsFromInner(StubCodeContext context public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context); } -#pragma warning disable SA1400 // Access modifier should be declared https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3659 - sealed file record OwnedValueCodeContext : StubCodeContext -#pragma warning restore SA1400 // Access modifier should be declared + file sealed record OwnedValueCodeContext : StubCodeContext { private readonly StubCodeContext _innerContext; @@ -196,9 +194,7 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo public override string GetAdditionalIdentifier(TypePositionInfo info, string name) => _innerContext.GetAdditionalIdentifier(info, name); } -#pragma warning disable SA1400 // Access modifier should be declared https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3659 - static file class OwnershipTrackingHelpers -#pragma warning restore SA1400 // Access modifier should be declared + file static class OwnershipTrackingHelpers { public const string OwnOriginalValueIdentifier = "ownOriginal"; public const string OriginalValueIdentifier = "original"; From 1b241a4f3344b4ceec2bf21088a6f908ef168ad1 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 8 Jun 2023 16:36:15 -0700 Subject: [PATCH 3/3] Add back suppression of SA1400 --- .../Marshalling/ElementsMarshalling.cs | 2 ++ .../UnmanagedToManagedOwnershipTrackingStrategy.cs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs index 9f4c2b8e1a7e29..6a42d229ae29b6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs @@ -57,7 +57,9 @@ public StatementSyntax GenerateClearUnmanagedValuesSource(TypePositionInfo info, public abstract StatementSyntax GenerateElementCleanupStatement(TypePositionInfo info, StubCodeContext context); } +#pragma warning disable SA1400 // Access modifier should be declared https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3659 file static class ElementsMarshallingCollectionSourceExtensions +#pragma warning restore SA1400 // Access modifier should be declared { public static StatementSyntax GetNumElementsAssignmentFromManagedValuesSource(this IElementsMarshallingCollectionSource source, TypePositionInfo info, StubCodeContext context) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs index c170ef9be7983c..a5ec887a5e64f9 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/UnmanagedToManagedOwnershipTrackingStrategy.cs @@ -168,7 +168,9 @@ IEnumerable GenerateStatementsFromInner(StubCodeContext context public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context); } +#pragma warning disable SA1400 // Access modifier should be declared https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3659 file sealed record OwnedValueCodeContext : StubCodeContext +#pragma warning restore SA1400 // Access modifier should be declared { private readonly StubCodeContext _innerContext; @@ -194,7 +196,9 @@ public override (string managed, string native) GetIdentifiers(TypePositionInfo public override string GetAdditionalIdentifier(TypePositionInfo info, string name) => _innerContext.GetAdditionalIdentifier(info, name); } +#pragma warning disable SA1400 // Access modifier should be declared https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3659 file static class OwnershipTrackingHelpers +#pragma warning restore SA1400 // Access modifier should be declared { public const string OwnOriginalValueIdentifier = "ownOriginal"; public const string OriginalValueIdentifier = "original";