HC0096: Support non-generic attributes with typeof() argument#9650
Open
N-Olbert wants to merge 2 commits into
Open
HC0096: Support non-generic attributes with typeof() argument#9650N-Olbert wants to merge 2 commits into
typeof() argument#9650N-Olbert wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds HC0096 support for the legacy [ExtendObjectType(typeof(T))] form so the analyzer can recommend the newer [ObjectType<T>] pattern alongside the existing generic-attribute path.
Changes:
- Extend
ExtendObjectTypeAnalyzerto detect non-genericExtendObjectType(typeof(...))usage. - Update the code fix and HC0096 message text to target the unified
[ObjectType<T>]upgrade path. - Add analyzer snapshot coverage for
typeof(...)and string-basedExtendObjectTypeusages, and refresh existing snapshots.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/HotChocolate/Core/test/Types.Analyzers.Tests/ExtendObjectTypeAnalyzerTests.cs |
Adds analyzer tests for typeof(...) and string overloads. |
src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ExtendObjectTypeAnalyzerTests.MixedAttributes_OnlyRaisesInfoForExtendObjectType.md |
Updates expected HC0096 message text. |
src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ExtendObjectTypeAnalyzerTests.ExtendObjectType_WithTypeArgument_RaisesInfo.md |
Adds new snapshot for typeof(...) diagnostic coverage. |
src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ExtendObjectTypeAnalyzerTests.ExtendObjectType_WithStringArgument_NoInfo.md |
Adds new snapshot for string-overload no-diagnostic coverage. |
src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ExtendObjectTypeAnalyzerTests.ExtendObjectType_WithGenericType_RaisesInfo.md |
Updates expected HC0096 message text. |
src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ExtendObjectTypeAnalyzerTests.ExtendObjectType_MultipleClasses_RaisesInfoForAll.md |
Updates expected HC0096 message text for multiple diagnostics. |
src/HotChocolate/Core/src/Types.Analyzers/ExtendObjectTypeCodeFixProvider.cs |
Adds code-fix conversion for ExtendObjectType(typeof(T)). |
src/HotChocolate/Core/src/Types.Analyzers/ExtendObjectTypeAnalyzer.cs |
Adds analyzer logic for non-generic typeof(...) attributes. |
src/HotChocolate/Core/src/Types.Analyzers/Errors.cs |
Simplifies HC0096 diagnostic wording for both forms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Currently HC0096 only works for generic
[ExtendObjectType<T>]attributes.This PR adds the same functionality for the older but equivalent
[ExtendObjectType(typeof(T))]attribute.