-
-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Resolve duplicate GeneratedCodeAttribute error and enhance XML documentation #289
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
Conversation
…ocumentation ## Problem Users reported CS0579 "Duplicate 'GeneratedCodeAttribute' attribute" errors when using Splat.DependencyInjection.SourceGenerator v2.1.1 alongside ReactiveUI.SourceGenerators v2.5.1. This occurred because both partial class declarations of `SplatRegistrations` (in Splat.DI.g.cs and Splat.DI.Reg.g.cs) were applying the `[GeneratedCodeAttribute]` attribute, causing a compilation error. ## Changes ### Bug Fixes - **Fixed duplicate attribute error**: Removed `[GeneratedCodeAttribute]` from the generated `Splat.DI.Reg.g.cs` file. The attribute now only appears once on the partial class in `Splat.DI.g.cs`, eliminating the CS0579 error - **Fixed RegisterConstant<T> signature**: Added `where T : class` constraint to match Splat's API, preventing CS0452 type constraint errors ### Documentation Improvements - **Enhanced XML documentation in Constants.cs**: All registration methods now include: - Detailed `<summary>` descriptions explaining transient vs singleton behavior - Complete `<typeparam>` documentation for generic type parameters - Proper `<param>` tags with clear explanations - `<see cref="">` references to related types - `<remarks>` sections explaining analyzer diagnostics and attribute behavior - **Added XML documentation to generated code**: The generated `Splat.DI.Reg.g.cs` now includes: - Class-level documentation explaining the partial class structure - Method-level documentation for `SetupIOCInternal` with parameter descriptions - `<see cref="">` references for better IntelliSense navigation ### Testing & Project Organization - Reorganized test structure: Moved test projects to `src/tests/` for better organization - Added TestApp: Created `Splat.DI.SourceGenerator.TestApp` to reproduce and verify the duplicate attribute issue with real-world scenarios - Added regression tests: New test `GenerateSetupIOCMethod_DoesNotIncludeDuplicateGeneratedCodeAttribute` ensures the attribute only appears once - Updated 393 snapshot tests to reflect the improved generated code format ## Impact - ✅ Resolves compatibility issues with ReactiveUI.SourceGenerators and other source generators - ✅ Improves developer experience with comprehensive IntelliSense documentation - ✅ Better code maintainability with properly documented generated code - ✅ All 834 tests passing ## Breaking Changes None. This is a bug fix release with backward-compatible improvements.
… length issues Removed EmitCompilerGeneratedFiles and CompilerGeneratedFilesOutputPath settings from TestApp.csproj. These were causing CI failures on Windows due to path length limitations with ReactiveUI.SourceGenerators generated files. The generated code can still be inspected through obj/ folders during local development if needed, but won't be committed to the repository.
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.
Pull request overview
This PR fixes a duplicate GeneratedCodeAttribute compilation error and enhances documentation for the Splat DI Source Generator. The main issue was that both partial class declarations in generated files had the [GeneratedCodeAttribute], causing CS0579 errors.
Changes:
- Removed duplicate
[GeneratedCodeAttribute]fromSplat.DI.Reg.g.csgenerated files - Added
where T : classconstraint toRegisterConstant<T>methods to match Splat's API - Enhanced XML documentation throughout the codebase
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #289 +/- ##
==========================================
+ Coverage 94.03% 94.41% +0.38%
==========================================
Files 17 17
Lines 838 896 +58
Branches 145 145
==========================================
+ Hits 788 846 +58
Misses 19 19
Partials 31 31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Problem
Users reported CS0579 "Duplicate 'GeneratedCodeAttribute' attribute" errors when using Splat.DependencyInjection.SourceGenerator v2.1.1 alongside ReactiveUI.SourceGenerators v2.5.1. This occurred because both partial class declarations of
SplatRegistrations(in Splat.DI.g.cs and Splat.DI.Reg.g.cs) were applying the[GeneratedCodeAttribute]attribute, causing a compilation error.Changes
Bug Fixes
[GeneratedCodeAttribute]from the generatedSplat.DI.Reg.g.csfile. The attribute now only appears once on the partial class inSplat.DI.g.cs, eliminating the CS0579 errorwhere T : classconstraint to match Splat's API, preventing CS0452 type constraint errorsDocumentation Improvements
Enhanced XML documentation in Constants.cs: All registration methods now include:
<summary>descriptions explaining transient vs singleton behavior<typeparam>documentation for generic type parameters<param>tags with clear explanations<see cref="">references to related types<remarks>sections explaining analyzer diagnostics and attribute behaviorAdded XML documentation to generated code: The generated
Splat.DI.Reg.g.csnow includes:SetupIOCInternalwith parameter descriptions<see cref="">references for better IntelliSense navigationTesting & Project Organization
src/tests/for better organizationSplat.DI.SourceGenerator.TestAppto reproduce and verify the duplicate attribute issue with real-world scenariosGenerateSetupIOCMethod_DoesNotIncludeDuplicateGeneratedCodeAttributeensures the attribute only appears onceImpact