Skip to content

HC0096: Support non-generic attributes with typeof() argument#9650

Open
N-Olbert wants to merge 2 commits into
ChilliCream:mainfrom
N-Olbert:HC0096ForNonGeneric
Open

HC0096: Support non-generic attributes with typeof() argument#9650
N-Olbert wants to merge 2 commits into
ChilliCream:mainfrom
N-Olbert:HC0096ForNonGeneric

Conversation

@N-Olbert
Copy link
Copy Markdown
Contributor

@N-Olbert N-Olbert commented May 5, 2026

Currently HC0096 only works for generic [ExtendObjectType<T>] attributes.
This PR adds the same functionality for the older but equivalent [ExtendObjectType(typeof(T))] attribute.

Copilot AI review requested due to automatic review settings May 5, 2026 21:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ExtendObjectTypeAnalyzer to detect non-generic ExtendObjectType(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-based ExtendObjectType usages, 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.

Comment thread src/HotChocolate/Core/src/Types.Analyzers/ExtendObjectTypeCodeFixProvider.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants