Disable usage analyzers by default, enable via editorconfig#214
Merged
andrewlock merged 11 commits intomainfrom Jan 3, 2026
Merged
Disable usage analyzers by default, enable via editorconfig#214andrewlock merged 11 commits intomainfrom
andrewlock merged 11 commits intomainfrom
Conversation
Co-authored-by: andrewlock <18755388+andrewlock@users.noreply.github.com>
…tests Co-authored-by: andrewlock <18755388+andrewlock@users.noreply.github.com>
Co-authored-by: andrewlock <18755388+andrewlock@users.noreply.github.com>
Co-authored-by: andrewlock <18755388+andrewlock@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Disable all usage analyzers by default and enable via editorconfig
Disable usage analyzers by default, enable via editorconfig
Jan 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements an opt-in mechanism for usage analyzers in the NetEscapades.EnumGenerators library. By default, all 8 usage analyzers are now disabled and must be explicitly enabled via an .editorconfig setting to reduce noise for users who don't utilize the generated extension methods.
Key Changes
- Added a new configuration system via
UsageAnalyzerConfigclass that checks for thenetescapades.enumgenerators.usage_analyzers.enableeditorconfig key - Updated all 8 usage analyzers (ToString, IsDefined, HasFlag, Parse, TryParse, GetValues, GetNames, GetValuesAsUnderlyingType) to check this configuration at startup
- Refactored test infrastructure by introducing a shared
AnalyzerTestsBaseclass to centralize test helper methods and configuration management
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/UsageAnalyzerConfig.cs |
New configuration class that defines the enable key and provides IsEnabled check method; includes a DiagnosticDescriptor for IntelliSense support |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/TryParseAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/ToStringAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/ParseAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/IsDefinedAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/HasFlagAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/GetValuesAsUnderlyingTypeAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/GetValuesAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/GetNamesAnalyzer.cs |
Added config check in RegisterCompilationStartAction and ConfigDescriptor to SupportedDiagnostics |
tests/NetEscapades.EnumGenerators.Tests/AnalyzerTestsBase.cs |
New base class for analyzer tests providing helper methods for verification with different assembly configurations and enabling/disabling the usage analyzers |
tests/NetEscapades.EnumGenerators.Tests/TryParseAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.Tests/ToStringAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.Tests/ParseAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.Tests/IsDefinedAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.Tests/HasFlagAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.Tests/GetValuesAsUnderlyingTypeAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.Tests/GetValuesAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.Tests/GetNamesAnalyzerTests.cs |
Refactored to inherit from AnalyzerTestsBase; removed duplicate test helper methods; added tests for Missing and Disabled config states |
tests/NetEscapades.EnumGenerators.IntegrationTests/.globalconfig |
New global config file enabling usage analyzers for integration tests |
tests/NetEscapades.EnumGenerators.IntegrationTests/AnalyzerTests.cs |
Added nullable annotation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/UsageAnalyzerConfig.cs
Show resolved
Hide resolved
src/NetEscapades.EnumGenerators/Diagnostics/UsageAnalyzers/UsageAnalyzerConfig.cs
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
andrewlock
approved these changes
Jan 3, 2026
Owner
andrewlock
left a comment
There was a problem hiding this comment.
Required fixing a bunch of things myself, but looked good enough, after making a bunch of improvements (mostly extracting common code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Usage analyzers now require explicit opt-in via
.editorconfigto reduce noise for users who don't use the generated extension methods.Changes
Config key:
netescapades.enumgenerators.usage_analyzers.enable = trueImplementation: Added
UsageAnalyzerConfig.IsEnabled()check atRegisterCompilationStartActionin each usage analyzerIntellisense: Shared
DiagnosticDescriptor(NEEGCONFIG001) added toSupportedDiagnosticsfor editorconfig autocompleteUsage
Add to
.editorconfig:Without this setting, usage analyzers are silent. Definition analyzers always run.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.