Repository navigation
SystemIo: target .NET 10 - #250
Draft
ghostflyby wants to merge 7 commits into
Draft
ghostflyby wants to merge 7 commits into
ghostflyby wants to merge 7 commits into
Conversation
…rator Add TruePath.PathIoGenerator, a Roslyn incremental source generator that fills the other partial part of PathIo (marked with GenerateSystemIoExtensionsAttribute) with forwarding extension methods for every public static File/Directory method of the current target framework, with the BCL XML documentation copied verbatim. - PathIo.cs keeps only the members with custom behavior or documentation; pure forwarders are generated (93 methods on net8.0, 66 on netstandard2.0), introducing previously missing APIs (symlinks, OpenHandle, Replace, EnumerateDirectories, GetParent, etc.). - Hand-written members win over generated ones, both by rewritten signature and by the forwarding call inside their body; File wins over Directory on duplicate signatures; path-io-exclusions.txt lists APIs deliberately not exposed. - BCL XML docs reach the generator via AdditionalFiles (the command-line compiler does not attach them to references), are extracted line-by-line to survive malformed netstandard.xml, and param/paramref names are normalized against the generated parameters; path parameters keep the historical sourceFile/destFile names. - Generated code uses short type names for imported namespaces. - Tests: generator unit tests plus a reflection completeness test asserting BCL API ⊆ generated ∪ hand-written ∪ exclusions.
…ndex - Drop dead test helpers, redundant nullability and qualifiers, an unused RenderFile parameter, and a redundant currentName check in BclDocIndex. - Store parsed XElement members in the doc index instead of raw strings: XElement.Parse is now called exactly once per member with its result actually used, instead of a validation-only call with a discarded return value followed by a second parse at emission time. The cached element is cloned before doc formatting, which renames param elements in place.
- Strip the UTF-8 BOM from TruePath.sln introduced by an editor. - Add a REUSE license companion for path-io-exclusions.txt. - Pin the generator test references to the Basic.Reference.Assemblies package: discovering the SDK's reference packs from the test host's runtime directory is not reliable on CI runners where the runtime and the SDK live in different roots. The test helper now also surfaces the driver diagnostics when the expected generated tree is missing. - The completeness test now mirrors the generator's third exclusion rule: BCL overloads that hand-written members forward to with path.Value as the first argument (previously flagged Directory.Delete(string,bool)).
The SPDX tags emitted into the generated file are string literals in the generator source; REUSE picked them up as this file's own tags and failed on the trailing C# syntax inside the expression.
- Reject nested marked classes with the new TPG004 diagnostic instead of silently generating a same-named top-level class, and derive the hint name from the full type name (sanitized) so same-named types cannot collide. - Hoist the exclusion file texts and the XML documentation index into their own cached pipeline nodes: the .xml filter now happens before BclDocIndex.Build, so editing path-io-exclusions.txt no longer re-scans the ~15 MB documentation files, and the exclusion file is matched by exact file name. - Move the hand-written member analysis into the syntax-anchored ForAttributeWithMetadataName transform (equatable MarkedType payload with sorted arrays), so it is cached across edits in unrelated files instead of re-running on every compilation change. - Clone the member element inside DocFormatting.ToDocLines rather than at the call site, and read the XML documentation files through SourceText.Lines instead of ToString/Replace/Split (three fewer full copies of the text). Generated output verified byte-identical on both target frameworks before and after the change.
…int names - Render every special type with its C# keyword inside generic arguments too: net10 span-based APIs like ReadOnlySpan<char> previously rendered as ReadOnlySpan<Char> because System_Char was missing from the table. - Emit the generated file under the simple type name again (PathIo.Generated.g.cs): the full-name sanitization was only needed for nested marked types, which are now rejected with TPG004. Both verified by temporarily building TruePath.SystemIo against net10.0, which generates 112 methods including the new span- and Memory-based overloads without any rule changes.
Add a net10.0 target to TruePath.SystemIo, exposing the .NET 10 BCL surface for file and directory operations through the source generator: 112 extension methods on this target, including the new span- and Memory-based overloads (AppendAllText/WriteAllText with ReadOnlySpan<char>, AppendAllBytes/WriteAllBytes with ReadOnlySpan<byte> and their ReadOnlyMemory-based async counterparts). Existing targets are unchanged. TruePath.Tests also gains a net10.0 target so the reflection completeness test validates the generated net10.0 surface against the matching runtime.
This branch has not been deployed
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.
Depends on #249 — this PR is stacked on top of the source generator change and should be merged after it. Until #249 merges, the diff below includes its commits.
Summary
Add a net10.0 target (the current LTS) to TruePath.SystemIo. With the source generator from #249 in place this is a one-line change that automatically exposes the .NET 10 BCL surface for file and directory operations: 112 extension methods on this target, including the new span- and Memory-based overloads:
The existing netstandard2.0 and net8.0 targets are unchanged.
Changes
Testing