Add unified platform map for cross-platform API documentation#4327
Add unified platform map for cross-platform API documentation#4327AlexDaines merged 9 commits intodevelopmentfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive platform availability mapping infrastructure to the AWS .NET SDK documentation generator to track API availability across different .NET platforms (net472, netstandard2.0, netcoreapp3.1, net8.0). This addresses issue #3938 where customers encountered documented APIs that don't exist on their target platform.
Changes:
- Implements a unified platform availability map that scans all platforms upfront and maintains signature-to-platform mappings
- Adds isolated assembly loading via
AssemblyLoadContextto enable loading multiple platform versions of the same assembly simultaneously - Introduces infrastructure for generating documentation pages for platform-exclusive APIs (e.g., H2 bidirectional streaming methods only available in net8.0)
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| PlatformMap/*.cs | New infrastructure for tracking member availability across platforms, including map builder, entry objects, assembly contexts, and signature generation utilities |
| SdkDocGenerator.cs | Main execution flow updated to build platform maps upfront, generate exclusive content, and provide legacy fallback path |
| GenerationManifest.cs | Extended to support platform maps, supplemental manifests, and exclusive page generation |
| GeneratorOptions.cs | Added UseLegacySupplemental option with deprecation notice for rollback safety |
| ReflectionWrappers.cs | Added IsolatedAssemblyLoadContext for loading same-named assemblies from different platforms |
| NDocUtilities.cs | Extended signature generation helpers and added duplicate key protection for multi-platform doc loading |
| ClassWriter.cs | Updated to merge supplemental methods from other platforms into class documentation pages |
| BaseWriter.cs | Added platform display name mapping for user-friendly badge rendering |
| CommandLineParser.cs | Added CLI flag for legacy supplemental mode |
| SDKDocGeneratorLib.csproj | Added System.Runtime.Loader dependency for assembly isolation |
| sdkstyle.css | Minor formatting fix (removed trailing whitespace) |
docgenerator/SDKDocGeneratorLib/PlatformMap/PlatformMapBuilder.cs
Outdated
Show resolved
Hide resolved
70f14c9 to
a2ed6fa
Compare
docgenerator/SDKDocGeneratorLib/PlatformMap/PlatformAvailabilityMap.cs
Outdated
Show resolved
Hide resolved
docgenerator/SDKDocGeneratorLib/PlatformMap/PlatformMapBuilder.cs
Outdated
Show resolved
Hide resolved
docgenerator/SDKDocGeneratorLib/PlatformMap/PlatformAvailabilityMap.cs
Outdated
Show resolved
Hide resolved
docgenerator/SDKDocGeneratorLib/PlatformMap/PlatformMapBuilder.cs
Outdated
Show resolved
Hide resolved
docgenerator/SDKDocGeneratorLib/PlatformMap/PlatformMapBuilder.cs
Outdated
Show resolved
Hide resolved
b6ee456 to
2cae95d
Compare
|
can you include screenshots of the before/after docs that get generated |
GarrettBeatty
left a comment
There was a problem hiding this comment.
one other small comment
docgenerator/SDKDocGeneratorLib/PlatformMap/PlatformMapBuilder.cs
Outdated
Show resolved
Hide resolved
c4c92f3 to
177b501
Compare
|
Is this in the dry-run output expected?
|
GarrettBeatty
left a comment
There was a problem hiding this comment.
talked via slack and showed screenshot of the diff. alex will upload to pr description.
can you re-run the dry run before merging
Yes expected. New from this pr. The platform scanner loads DLLs to reflect over types, (unlike the current generator which only reads XML doc files). netcoreapp3.1 throws a ReflectionTypeLoadException because of missing dependencies in the build env. The catch block at PlatformMapBuilder.cs:117 handles it and moves on. net8.0 and net472 both load normally |
The SDK doc generator previously used net472 as the sole source of all APIs. H2 eventstream APIs (e.g., TranscribeStreaming's StartTranscription) only exist in the net8.0 target and get zero API reference documentation. This adds a PlatformMap subsystem that scans multiple target frameworks and generates documentation for platform-exclusive APIs: - PlatformMapBuilder: Scans assemblies from each target framework using isolated assembly load contexts to build a cross-platform member index - PlatformAvailabilityMap: Queryable map of which members exist on which platforms, with wrapper-based lookup for page generation - PlatformAssemblyContext: Manages per-platform assembly loading with proper isolation and disposal - MemberSignature: Deterministic signature generation for cross-platform member identity comparison - PlatformMemberEntry: Per-member platform availability tracking Key design decisions: - Uses FullName comparison for cross-assembly type identity (Equals() fails across assembly load contexts) - Inherited members attributed to their declaring type, not every derived class, preventing false exclusive method proliferation - Per-service exception handling wraps map building for resilience - First-wins cache strategy in NDocUtilities prevents cross-platform assembly interference Also includes minor NDocUtilities improvement for rendering <list>, <item>, <term>, and <description> XML doc elements to HTML. Addresses DOTNET-8085. Design: DOTNET-8116.
Tests cover: - MemberSignature utility methods (GetMemberType, GetMemberName, GetDeclaringTypeName, ExtractMethodName) and delegation consistency - PlatformAvailabilityMap query behavior with hand-crafted test data: universal members, exclusive members, platform case insensitivity, statistics, disposal, and edge cases - NDoc signature generation gaps: array parameters, nested generics, parameterless and parameterized constructor signatures Adds InternalsVisibleTo for test access to internal PlatformAvailabilityMap constructor.
- Add null check for coreManifest before accessing its assembly context to prevent NullReferenceException when Core assembly is absent - Correct misleading "first-wins ensures primary platform precedence" comment: docIds are per-service+platform, so cache entries never collide across platforms; the guard is a de-duplication check for same (service, platform) pair
- Remove unused methodName variable in FindMethodInAssembly (PlatformMapBuilder) - Replace ad-hoc signature format with MemberSignature.ForMethod in ClassWriter supplemental method dedup (guards against null FullName on generic type params) - Revert unrelated using System addition in GeneratorOptions.cs - Revert whitespace-only changes in sdkstyle.css
- Prevent discarding ManifestAssemblyContext when platform map has exclusive members that need it for page generation (NullReferenceException) - Remove unused ExclusivePlatform property from PlatformMemberEntry - Simplify platform lookup in ResolveExclusiveMethodWrappers using FirstOrDefault (all platforms already filtered to non-primary) - Remove unused InfoVerbose overloads from SdkDocGenerator
4d15116 to
3bf966b
Compare
| bool isVerbose) | ||
| { | ||
| if (string.IsNullOrEmpty(serviceName)) | ||
| throw new ArgumentNullException(nameof(serviceName)); |
There was a problem hiding this comment.
Non-blocking but ArgumentNullException is misleading because it can also be empty on all of these except platformsToScan. ArgumentException with information that it could be null or empty would have been more accurate.
Description
Adds PlatformAvailabilityMap infrastructure for tracking API availability across .NET platforms (net472, netstandard2.0, netcoreapp3.1, net8.0). Enables documentation of platform-exclusive APIs like H2 eventstream methods that only exist in net8.0.
Motivation and Context
Fixes #3938 - Customers see documented APIs that don't exist on their target platform, wasting time trying to use APIs that won't compile.
This PR ships the infrastructure only. Badge UX deferred to follow-up PR pending design review.
Testing
Dryruns (03/31/26):
dotnetv4 (passed) - a4511f2c-a7d8-49ce-813a-f685abc46ed0
powershell5 (passed) - 6c0420ce-829e-42f9-a3a3-560b5dd86684
dotnet build SDKDocGenerator/SDKDocGenerator.csprojBreaking Changes Assessment
None. This is additive infrastructure with no changes to existing doc output behavior.
Screenshots (if appropriate)
TTranscribeStreamingClient.html methods section:

Before (live docs):
After (artifacts from dryrun of this branch):

Example of New Individual Method Page:

Beyond Compare

Comparing the latest release build's doc build output to the doc build output from the dryrun of this feature branch:
Types of changes
Checklist
License