-
Notifications
You must be signed in to change notification settings - Fork 0
chore: align analyzer conventions #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,99 +1 @@ | ||
| root = true | ||
|
|
||
| [*.cs] | ||
| # Treat ALL diagnostics as errors — compiler, analyzers, IDE, style | ||
| dotnet_analyzer_diagnostic.severity = error | ||
|
|
||
| # ────────────────────────────────────────────────────────────────────────────── | ||
| # Naming rules (dotnet/runtime style) | ||
| # | ||
| # Mirrors ANcpLua.NET.Sdk's NamingConvention.editorconfig. This repo doesn't | ||
| # consume the SDK, so the rules are inlined here under [*.cs] (no is_global — | ||
| # IDE picks them up via filesystem walk, no MSBuild registration needed). | ||
| # Source of truth: ANcpLua.NET.Sdk/src/Config/NamingConvention.editorconfig. | ||
| # ────────────────────────────────────────────────────────────────────────────── | ||
|
|
||
| dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case | ||
|
|
||
| # constant fields using PascalCase | ||
| dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion | ||
| dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields | ||
| dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style | ||
| dotnet_naming_symbols.constant_fields.applicable_kinds = field | ||
| dotnet_naming_symbols.constant_fields.required_modifiers = const | ||
| dotnet_naming_style.pascal_case_style.capitalization = pascal_case | ||
|
|
||
| # private/internal static fields (incl. readonly) use s_ prefix. | ||
| # Matches dotnet/runtime: private/internal static readonly is NOT PascalCase — | ||
| # the const rule above keeps const fields PascalCase; the fallback rule at the | ||
| # bottom keeps public/protected static (readonly) fields PascalCase. | ||
| dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion | ||
| dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields | ||
| dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style | ||
| dotnet_naming_symbols.static_fields.applicable_kinds = field | ||
| dotnet_naming_symbols.static_fields.required_modifiers = static | ||
| dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected | ||
| dotnet_naming_style.static_prefix_style.required_prefix = s_ | ||
| dotnet_naming_style.static_prefix_style.capitalization = camel_case | ||
|
|
||
| # private/internal instance fields use _camelCase. | ||
| # The static rule above is more specific (kinds + modifier + accessibility) | ||
| # and wins for static fields. | ||
| dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion | ||
| dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields | ||
| dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style | ||
| dotnet_naming_symbols.private_internal_fields.applicable_kinds = field | ||
| dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal | ||
| dotnet_naming_style.camel_case_underscore_style.required_prefix = _ | ||
| dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case | ||
|
|
||
| # name all constant variables using PascalCase | ||
| dotnet_naming_rule.constant_variables_should_be_pascal_case.severity = suggestion | ||
| dotnet_naming_rule.constant_variables_should_be_pascal_case.symbols = constant_variables | ||
| dotnet_naming_rule.constant_variables_should_be_pascal_case.style = pascal_case_style | ||
| dotnet_naming_symbols.constant_variables.applicable_kinds = local | ||
| dotnet_naming_symbols.constant_variables.required_modifiers = const | ||
|
|
||
| # Locals and parameters are camelCase | ||
| dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion | ||
| dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters | ||
| dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style | ||
|
|
||
| dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local | ||
| dotnet_naming_style.camel_case_style.capitalization = camel_case | ||
|
|
||
| # Local functions are PascalCase | ||
| dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion | ||
| dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions | ||
| dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style | ||
|
|
||
| dotnet_naming_symbols.local_functions.applicable_kinds = local_function | ||
| dotnet_naming_style.local_function_style.capitalization = pascal_case | ||
|
|
||
| # Type Parameters | ||
| dotnet_naming_style.type_parameter_style.capitalization = pascal_case | ||
| dotnet_naming_style.type_parameter_style.required_prefix = T | ||
|
|
||
| dotnet_naming_rule.type_parameter_naming.symbols = type_parameter_symbol | ||
| dotnet_naming_rule.type_parameter_naming.style = type_parameter_style | ||
| dotnet_naming_rule.type_parameter_naming.severity = warning | ||
| dotnet_naming_symbols.type_parameter_symbol.applicable_kinds = type_parameter | ||
| dotnet_naming_symbols.type_parameter_symbol.applicable_accessibilities = * | ||
|
|
||
| # Interface | ||
| dotnet_naming_style.interface_style.capitalization = pascal_case | ||
| dotnet_naming_style.interface_style.required_prefix = I | ||
|
|
||
| dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning | ||
| dotnet_naming_rule.interface_should_be_begins_with_i.style = interface_style | ||
| dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface_symbols | ||
|
|
||
| dotnet_naming_symbols.interface_symbols.applicable_kinds = interface | ||
| dotnet_naming_symbols.interface_symbols.applicable_accessibilities = * | ||
|
|
||
| # By default, name items with PascalCase | ||
| dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion | ||
| dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members | ||
| dotnet_naming_rule.members_should_be_pascal_case.style = non_private_static_field_style | ||
|
|
||
| dotnet_naming_symbols.all_members.applicable_kinds = * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| <Project> | ||
| <!-- SDK-owned properties - centralized here, NOT in individual csproj files --> | ||
| <PropertyGroup> | ||
| <!-- Centralize all build output to artifacts/ --> | ||
| <!-- Centralize build output to artifacts/ --> | ||
| <ArtifactsPath>$(MSBuildThisFileDirectory)artifacts/</ArtifactsPath> | ||
| <BaseOutputPath>$(ArtifactsPath)bin/$(MSBuildProjectName)/</BaseOutputPath> | ||
| <BaseIntermediateOutputPath>$(ArtifactsPath)obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath> | ||
|
|
@@ -13,9 +14,16 @@ | |
|
|
||
| <!-- Deterministic builds for reproducibility --> | ||
| <Deterministic>true</Deterministic> | ||
| <LangVersion Condition="'$(LangVersion)' == ''">latest</LangVersion> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings Condition="'$(ImplicitUsings)' == ''">enable</ImplicitUsings> | ||
| <EnableNETAnalyzers Condition="'$(EnableNETAnalyzers)' == ''">true</EnableNETAnalyzers> | ||
| <AnalysisLevel Condition="'$(AnalysisLevel)' == ''">latest-all</AnalysisLevel> | ||
|
|
||
| <MSBuildTreatWarningsAsErrors Condition="'$(MSBuildTreatWarningsAsErrors)' == '' AND '$(ContinuousIntegrationBuild)' == 'true'">true</MSBuildTreatWarningsAsErrors> | ||
| <TreatWarningsAsErrors Condition="'$(TreatWarningsAsErrors)' == '' AND '$(ContinuousIntegrationBuild)' == 'true'">true</TreatWarningsAsErrors> | ||
| <EnforceCodeStyleInBuild Condition="'$(EnforceCodeStyleInBuild)' == ''">true</EnforceCodeStyleInBuild> | ||
|
|
||
| <!-- Treat all warnings, suggestions, and hints as errors --> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| <NoWarn>$(NoWarn);NU1604</NoWarn> | ||
| <NoWarn Condition="'$(TargetFramework)' == 'netstandard2.0'">$(NoWarn);NU1701</NoWarn> | ||
|
|
||
|
|
@@ -26,6 +34,16 @@ | |
| <PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Pull in the canonical ANcpLua.NET.Sdk analyzer/style conventions without importing the SDK package --> | ||
| <PropertyGroup> | ||
| <EnableEditorConfigDogfooding Condition="'$(EnableEditorConfigDogfooding)' == ''">true</EnableEditorConfigDogfooding> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup Condition="'$(EnableEditorConfigDogfooding)' == 'true'"> | ||
| <EditorConfigFiles Include="$(MSBuildThisFileDirectory)../ANcpLua.NET.Sdk/src/Config/*.editorconfig" | ||
| Exclude="$(MSBuildThisFileDirectory)../ANcpLua.NET.Sdk/src/Config/ANcpLua.NET.Sdk*.editorconfig" /> | ||
|
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This import points to Useful? React with 👍 / 👎. |
||
| </ItemGroup> | ||
|
|
||
| <!-- CI-specific settings --> | ||
| <PropertyGroup Condition="'$(CI)' == 'true'"> | ||
| <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -117,13 +117,13 @@ public static MethodInfo GetMethodFromGenericDefinition(this Type specializedTyp | |||||||||
| #if NET6_0_OR_GREATER | ||||||||||
| return (MethodInfo)specializedType.GetMemberWithSameMetadataDefinitionAs(genericMethodDefinition); | ||||||||||
| #else | ||||||||||
| const BindingFlags all = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | | ||||||||||
| const BindingFlags All = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | | ||||||||||
| BindingFlags.Instance; | ||||||||||
|
Comment on lines
+120
to
121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 MEDIUM RISK Add BindingFlags.FlattenHierarchy to ensure static methods from base classes are included in the search.
Suggested change
|
||||||||||
| foreach (var m in specializedType.GetMethods(all)) | ||||||||||
| foreach (var m in specializedType.GetMethods(All)) | ||||||||||
| if (m.MetadataToken == genericMethodDefinition.MetadataToken) | ||||||||||
| return m; | ||||||||||
|
|
||||||||||
| throw new MissingMethodException(specializedType.FullName, genericMethodDefinition.Name); | ||||||||||
| #endif | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition depends on
$(ContinuousIntegrationBuild), but that property is only assigned later in the same file (<PropertyGroup Condition="'$(CI)' == 'true'">). MSBuild evaluates properties in order, so in CI environments that rely on this file to setContinuousIntegrationBuild, the condition here evaluates false and warnings are not elevated to errors. SetContinuousIntegrationBuildearlier or key this condition directly off$(CI)/$(GITHUB_ACTIONS).Useful? React with 👍 / 👎.