Replace PolyKit.Embedded with PolySharp in Buildvana.Sdk.SourceGenerators - #307
Conversation
PolyKit is effectively unmaintained and injects far more polyfills than the only netstandard2.0 project needs; the excess internals leaked into the test project through InternalsVisibleTo, forcing an extern-alias reference. PolySharp is restricted via PolySharpIncludeGeneratedTypes to IsExternalInit alone: polyfilling System.Index (for a single str[^1]) would drag in the nullable attributes, which are precisely the types that collided with the BCL's — so that expression becomes str[str.Length - 1] and the extern alias goes away entirely. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@claude please review this PR. |
|
Claude finished @rdeago's task in 1m 33s —— View job Review: Replace PolyKit.Embedded with PolySharp in Buildvana.Sdk.SourceGenerators
SummaryClean, well-scoped refactor. I reviewed the full diff against FindingsCorrectness — all good:
Nothing to flag — I don't have inline suggestions here. The one thing I'd normally double-check per Types of changes / checklistMatches: pure internal refactor, |
Proposed changes
WHY — #305:
PolyKit.Embeddedis effectively unmaintained and injects far more polyfills than the repository's onlynetstandard2.0project needs. The excess internals leaked into the test project throughInternalsVisibleTo, colliding with the same types inSystem.Runtime(CS0433) and forcing an extern-alias reference — a construct rare enough to be overlooked by maintainers, and one that had already triggered an in-IDE ReSharper false positive.WHERE —
Buildvana.Sdk.SourceGenerators(project file and one expression inConstantValueParser),Directory.Packages.props,Buildvana.Sdk.SourceGenerators.Tests.WHAT —
PolyKit.Embeddedis gone. PolySharp 1.16.0 (PrivateAssets="all", central version under development dependencies) provides polyfills, restricted viaPolySharpIncludeGeneratedTypesto a single type:IsExternalInit, required by the project's onereadonly record struct. The test project now references the generators project withoutAliases="Generators", and the two test files lose theirextern aliasdirectives. No consumer-visible changes; no CHANGELOG entry.HOW — #305 prescribed polyfilling
System.Indextoo, for the project's singlestr[^1]expression — but PolySharp'sIndexpolyfill references[NotNullWhen]and[DoesNotReturn], and PolySharp does not generate dependencies transitively. Polyfilling those attributes would have reintroduced, throughInternalsVisibleTo, exactly the BCL collision that forced the extern alias (the test project itself uses[NotNullWhen]). Writingstr[str.Length - 1]instead shrinks the injected surface to one type never named in source and lets the alias go for good. A comment onPolySharpIncludeGeneratedTypeswarns future polyfill additions about this dependency fan-out.Sanity check:
dotnet bv packclean (both packages produced), 51/51 source-generator tests green,dotnet buildwith zero warnings and zero errors; ReSharper inspectcode reports nothing in changed code (its single result is a pre-existing false positive inBuildvana.Core.JsonSchema, unrelated to this PR).Checklist of related issues / discussions
Types of changes
This pull request introduces the following types of changes:
docsdirectory) updateBreaking changes
This pull request introduces breaking changes:
Checklist
docsdirectory) only:🤖 Generated with Claude Code