Skip to content

Fix runtime, analyzer, code-fix, and generator correctness bugs (Phase 1) - #365

Merged
kzu merged 1 commit into
mainfrom
fix/phase-1-correctness
Nov 29, 2026
Merged

kzu merged 1 commit into
mainfrom
fix/phase-1-correctness

Conversation

@kzu

@kzu kzu commented Nov 29, 2026

Copy link
Copy Markdown
Member

Summary

Phase 1 of the codebase audit improvements — correctness, thread-safety, and diagnostic fixes across the runtime, analyzers, code fixes, and compiled proxy generator.

Runtime (src/Stunts, src/Stunts.DynamicProxy, src/Stunts.Extensions, src/Stunts.Package)

  • BehaviorPipeline & BehaviorsCollection: Made Invoke stateless across next calls (so retry behaviors re-run downstream behaviors), preserved exception stack traces via ExceptionDispatchInfo, enforced throwOnException across all return paths, and switched BehaviorsCollection to lock-guarded mutations with a copy-on-write snapshot.
  • AsyncRegistry & Argument: Wrapped continuation completion in try/catch (TrySetException) so invalid casts fault instead of hanging, preserved Register<T> for trimming via [DynamicDependency], used direct IsByRefLike/IsFunctionPointer on .NET 8+, and fixed Argument<T>.ToString() operator precedence.
  • Behaviors & helpers: Tightened signature matching in DefaultEqualityBehavior, TargetBehavior, and NotifyPropertyChangeBehavior (ignoring indexers); made RecordingBehavior and DynamicStuntInterceptor thread-safe; guarded ObservabilityBehavior Activity lifecycle and Activity.Current across async calls; aligned DataAnnotationsBehavior to return faulted Task/ValueTask via AsyncRegistry; fixed Ref.Create, MethodInvocation.ToString, Stunt.Get(null) (Stunt.cs/Stunt.vb), and null behavior validation in StuntExtensions.

Analyzers, CodeFixes & Generator (src/Stunts.CodeAnalysis, src/Stunts.CodeFixes, src/Stunts.CompiledProxy)

  • Diagnostics: Fixed ST001 title (Strings.BaseTypeNotFirst.Title), moved the missing-generator MSBuild error in Stunts.targets from ST010 to ST024, added ST025 (static abstract interface members), ST026 (file-local types), and ST027 (isolated per-stunt generation failures), and added // <auto-generated/>, #nullable enable, and .g.cs hint name to SignatureRefGenerator.
  • Analyzers & CodeFixes: Fixed NamingConvention.GetNamespace ordering, SymbolExtensions.CanBeIntercepted (Task/Task<T>), SymbolFullNameExtensions.GetTypeByFullName (ITypeSymbol?, leading _, generic/jagged arrays), StuntClosure.Substitute for nested generics inside constructed containing types, GenericWrapperAnalyzer local functions, ValidateTypesAnalyzer EnableCompileTimeStunts=false gating, AddPartialCodeFix (all non-partial ancestors + wrapper invocations), and AddGeneratorAttributeCodeFix (StringComparison.Ordinal).
  • Generator & Cache: Fixed MemberScaffold.ParameterSignature and INamedTypeSymbolExtensions.SameSignature (RefKind + generic arity), emitted scoped and allows ref struct (with StructRef<T> support for where T : allows ref struct), replicated inheritable interface attributes while skipping DefaultMemberAttribute, fixed multi-variable PromoteEventFields, and isolated StuntCache.Prune() failures from StuntCache.Create().

Verification

  • Full solution build (dotnet build /p:UseSharedCompilation=false -m:1) succeeded with 0 errors.
  • Full test suite (dnx --yes retest -- --no-build) passed: 443/443 tests passing (including new regression tests).

This pull request was created by CodeAlta.

…e 1)

- Make BehaviorPipeline stateless across retries, preserve stack traces via ExceptionDispatchInfo, and make BehaviorsCollection/RecordingBehavior/DynamicStuntInterceptor thread-safe
- Guard AsyncRegistry continuations and trimming, fix Argument/MethodInvocation/Ref/Stunt.Get/StuntExtensions edge cases, and tighten DefaultEqualityBehavior/TargetBehavior/NotifyPropertyChangeBehavior matching
- Guard ObservabilityBehavior Activity lifecycle and return faulted Task/ValueTask from DataAnnotationsBehavior
- Fix ST001 title, split missing-generator MSBuild error to ST024, add ST025/ST026/ST027, harden StuntCache.Prune, and fix NamingConvention, SymbolExtensions, SymbolFullNameExtensions, StuntClosure, GenericWrapperAnalyzer, ValidateTypesAnalyzer, AddPartialCodeFix, MemberScaffold, AttributeReplication, and CSharpRewrite

Co-authored-by: CodeAlta <noreply@codealta.io>
@kzu kzu added the bug Something isn't working label Nov 29, 2026
@kzu
kzu enabled auto-merge (rebase) November 29, 2026 19:06
@kzu
kzu merged commit df16e67 into main Nov 29, 2026
7 checks passed
@kzu
kzu deleted the fix/phase-1-correctness branch November 29, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant