Fix/contract keys and register constant#303
Closed
glennawatson wants to merge 13 commits intomainfrom
Closed
Conversation
…alyzer Replace hardcoded string literals with named constants for method names, parameter names, type patterns, file names, metadata names, and code fix titles. Also rename claude.md to CLAUDE.md.
…bute and type comparisons Replace string-based comparisons with pre-resolved symbol comparisons in MetadataExtractor to eliminate string allocations during the generator transform phase. String comparison is retained as a fallback when symbol resolution fails. Adds unit tests for the new helper methods.
…atorGetService, IocMethod
- Add comprehensive XML documentation across all non-test source files - Make key methods internal for direct testability: CodeGenerator (GetConstructorArguments, GetPropertyInitializer, GetResolutionString), ConstructorCodeFixProvider (AddAttributeAsync), PropertyCodeFixProvider (AddSetterAsync split into BuildSetterModifiers, ConvertExpressionBodiedProperty, AddSetterToGetterOnlyProperty, UpdateExistingSetterModifiers) - Extract testable helpers in AnalyzerHelpers (IsContainedInSplatRegistrations, ReportDiagnostics, GetFirstLocation) and MetadataExtractor (ExtractRegisterMetadataFromSymbol, ExtractLazySingletonMetadataFromSymbol, GetFirstLocation) - Add 66 new unit tests (939 → 1005) covering all newly internal methods, fallback paths, and edge cases
…eakTable The 4 GetTypeByMetadataName lookups were repeated per syntax node transform. Use a ConditionalWeakTable<Compilation, WellKnownSymbolsBox> so they resolve once per compilation instance. Pass WellKnownSymbols explicitly into the inner extract methods to make the dependency clear and testable.
Use argument NameColon syntax to resolve parameters by name instead of relying solely on positional index, which breaks when callers pass named arguments out of order.
Extract GetFullyQualifiedMethodInvocation as a testable internal method that fully qualifies the containing type of method invocations used as contract keys. Previously, calls like ContractHelper.GetContractKey() were emitted unqualified in generated code within namespace Splat, causing compilation errors when the method's type was in a different namespace. Also add a bounds check in ResolveParameterForArgument to return null when the positional index exceeds the parameter count, preventing IndexOutOfRangeException on malformed code.
The code generator was using sb.Append (no trailing newline) for both transient and lazy singleton registrations, causing the closing brace of SetupIOCInternal to appear on the same line as the last registration. Changed to sb.AppendLine in both GenerateTransientRegistration and GenerateLazySingletonRegistration to ensure proper formatting.
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.
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
What might this PR break?
Please check if the PR fulfills these requirements
Other information: