Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 148 additions & 70 deletions .github/copilot-instructions.md

Large diffs are not rendered by default.

57 changes: 37 additions & 20 deletions .github/skills/update-copilot-instructions/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Read `.github/copilot-instructions.md` in full. Take note of every factual claim

### Step 2: analyze each project in depth

Launch parallel explore agents for each of the 8 CsWinRT 3.0 projects listed in the instructions. For each project, verify:
Launch parallel explore agents for each of the 11 CsWinRT 3.0 projects listed in the instructions. For each project, verify:

1. **WinRT.Runtime (`src/WinRT.Runtime2/`)**
- Directory structure matches what's documented
Expand All @@ -30,46 +30,63 @@ Launch parallel explore agents for each of the 8 CsWinRT 3.0 projects listed in

2. **WinRT.SourceGenerator2 (`src/Authoring/WinRT.SourceGenerator2/`)**
- Source generators listed still exist and generate what's described
- Diagnostic analyzer list is complete and IDs are correct (check `DiagnosticDescriptors.cs`)
- Diagnostic analyzer list is complete and IDs are correct (check `DiagnosticDescriptors.cs` and `AnalyzerReleases.Shipped.md`)
- Diagnostic ID range is accurate
- Project dependencies are current
- Assembly name is current (it is `WinRT.SourceGenerator`, **not** `WinRT.SourceGenerator2` — the project folder has `2` for repo history, but the produced .dll does not)

3. **cswinrt.exe (`src/cswinrt/`)**
- Key files listed still exist
- Command-line options are current (check `settings.h`)
- Namespace additions in `strings/additions/` are up to date
- Generated code patterns are accurately described
3. **Projection writer (`src/WinRT.Projection.Writer/`)**
- Directory structure and namespaces match (`Attributes/`, `Builders/`, `Errors/`, `Extensions/`, `Factories/`, `Generation/`, `Helpers/`, `Metadata/`, `Models/`, `References/`, `Resolvers/`, `Resources/`, `Writers/`)
- Public API surface (`ProjectionWriter.Run`, `ProjectionWriterOptions` shape) is accurate
- Error ID range (5xxx in `Errors/WellKnownProjectionWriterExceptions.cs`) is accurate
- Resources structure (`Additions/` per-namespace + `Base/` baseline) matches

4. **Impl generator (`src/WinRT.Impl.Generator/`)**
4. **Reference projection generator (`src/WinRT.Projection.Ref.Generator/`)**
- CLI parameters on `ReferenceProjectionGeneratorArgs` are current
- Error ID range (`CSWINRTPROJECTIONREFGENxxxx`) in `Errors/WellKnownReferenceProjectionGeneratorExceptions.cs` is accurate
- Project settings (Native AOT, dependencies) are current
- MSBuild integration via `nuget/Microsoft.Windows.CsWinRT.targets` (CsWinRTGenerateProjection target → `RunCsWinRTProjectionRefGenerator`) is wired

5. **Impl generator (`src/WinRT.Impl.Generator/`)**
- Type forward routing logic is current
- Project settings and dependencies are current
- CLI parameters are current

5. **Projection generator (`src/WinRT.Projection.Generator/`)**
6. **Projection generator (`src/WinRT.Projection.Generator/`)**
- Three projection modes are accurately described
- Namespace filter logic is current
- Project settings and dependencies are current
- Project settings and dependencies (project reference to `WinRT.Projection.Writer`) are current
- The pipeline is documented as in-process (the projection writer is invoked as a library)
- `ProjectionGeneratorArgs` no longer contains any leftover `CsWinRTExePath` field

6. **Interop generator (`src/WinRT.Interop.Generator/`)**
7. **Interop generator (`src/WinRT.Interop.Generator/`)**
- Generated content categories are current
- Directory structure and key types are accurate
- Project settings and dependencies are current

7. **WinMD generator (`src/WinRT.WinMD.Generator/`)**
8. **WinMD generator (`src/WinRT.WinMD.Generator/`)**
- CLI parameters on `WinMDGeneratorArgs` are current
- Error ID range (`CSWINRTWINMDGENxxxx`) in `Errors/WellKnownWinMDExceptions.cs` is accurate
- Project settings and dependencies are current
- MSBuild integration via `nuget/Microsoft.Windows.CsWinRT.Authoring.WinMD.targets` is wired (gated on `CsWinRTComponent`)

8. **Generator tasks (`src/WinRT.Generator.Tasks/`)**
- MSBuild task classes are accurately listed (including `RunCsWinRTWinMDGenerator`)
9. **Generator tasks (`src/WinRT.Generator.Tasks/`)**
- MSBuild task classes are accurately listed (including `RunCsWinRTProjectionRefGenerator` and `RunCsWinRTWinMDGenerator`)
- Task-to-tool mappings are current

9. **SDK projection builds (`src/WinRT.Sdk.Projection/`)**
- Assembly name logic (base vs XAML) is current
- Windows SDK package download and WinMD sourcing is accurate
- Build parameters (`WindowsSdkBuild`, `WindowsSdkXaml`) are current
- Project settings are current
- No leftover `CsWinRTExePath` parameter on `RunCsWinRTMergedProjectionGenerator`

10. **SDK projection builds (`src/WinRT.Sdk.Projection/`)**
- Assembly name logic (base vs XAML) is current
- Windows SDK package download and WinMD sourcing is accurate
- Build parameters (`WindowsSdkBuild`, `WindowsSdkXaml`, `SdkPackageVersion`) are current
- Project settings are current

11. **WinRT.Internal (`src/WinRT.Internal/`)**
- Hand-authored C# source files mirror the historical IDL interop interfaces (HWND struct, `[ProjectionInternal]` attribute, all 14 `I*Interop` interfaces with their original IIDs)
- Project TFM uses the CsWinRT 3.0 revision (`net10.0-windows10.0.X.1`) so the `cswinrt3` SDK projection reference assemblies are selected, and `WindowsSdkPackageVersion` is pinned to match
- CsWinRT integration is disabled on the project itself (`CsWinRTEnabled`, `CsWinRTGenerateProjection`, `CsWinRTGenerateInteropAssembly[2]` all `false`)
- `GenerateWindowsRuntimeInternalWinMD` target invokes `cswinrtwinmdgen.exe` directly via `<Exec>` (not via the `UsingTask` mechanism) to avoid `MSB3027` file-lock contention in Visual Studio
- Output `.winmd` lands at `$(TargetDir)$(AssemblyName).winmd` (`WindowsRuntime.Internal.winmd`), and `src/Directory.Build.props` exposes it via `$(CsWinRTInteropMetadata)` for downstream consumers

### Step 3: verify the test projects

Expand Down
11 changes: 0 additions & 11 deletions build/AzurePipelineTemplates/CsWinRT-Build-Steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,6 @@ steps:
sevenZipCompression: 5
archiveFile: $(StagingFolder)\Windows\sources.zip

# Stage CsWinRT
- task: CopyFiles@2
displayName: Stage CsWinRT
condition: and(succeeded(), and(eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')))
inputs:
SourceFolder: $(Build.SourcesDirectory)\src\_build\$(BuildPlatform)\$(BuildConfiguration)\cswinrt\bin
Contents: |
cswinrt.exe
cswinrt.pdb
TargetFolder: $(StagingFolder)\native

# Stage WindowsRuntime.Internal.winmd
- task: CopyFiles@2
displayName: Stage WindowsRuntime.Internal.winmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
command: sign
signing_profile: external_distribution
files_to_sign: |
native/cswinrt.exe;
net10.0/WinRT.SourceGenerator.dll;
net10.0/WinRT.Host.Shim.dll;
net10.0/WinRT.Runtime.dll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ steps:
command: pack
searchPatternPack: nuget/Microsoft.Windows.CsWinRT.nuspec
configurationToPack: Release
buildProperties: cswinrt_nuget_version=$(NugetVersion);cswinrt_exe=$(Build.SourcesDirectory)\release_x86\native\cswinrt.exe;interop_winmd=$(Build.SourcesDirectory)\release_x86\native\WindowsRuntime.Internal.winmd;net10_runtime=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.Runtime.dll;net10_runtime_xml=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.Runtime.xml;source_generator=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.SourceGenerator.dll;winrt_shim=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.Host.Shim.dll;winrt_host_x86=$(Build.SourcesDirectory)\release_x86\native\WinRT.Host.dll;winrt_host_x64=$(Build.SourcesDirectory)\release_x64\native\WinRT.Host.dll;winrt_host_arm64=$(Build.SourcesDirectory)\release_arm64\native\WinRT.Host.dll;winrt_host_resource_x86=$(Build.SourcesDirectory)\release_x86\native\WinRT.Host.dll.mui;winrt_host_resource_x64=$(Build.SourcesDirectory)\release_x64\native\WinRT.Host.dll.mui;winrt_host_resource_arm64=$(Build.SourcesDirectory)\release_arm64\native\WinRT.Host.dll.mui;cswinrtinteropgen_x64=$(Build.SourcesDirectory)\release_x64\net10.0\native\cswinrtinteropgen.exe;cswinrtinteropgen_arm64=$(Build.SourcesDirectory)\release_arm64\net10.0\native\cswinrtinteropgen.exe;cswinrtimplgen_x64=$(Build.SourcesDirectory)\release_x64\net10.0\native\cswinrtimplgen.exe;cswinrtimplgen_arm64=$(Build.SourcesDirectory)\release_arm64\net10.0\native\cswinrtimplgen.exe;cswinrtprojectiongen_x64=$(Build.SourcesDirectory)\release_x64\net10.0\native\cswinrtprojectiongen.exe;cswinrtprojectiongen_arm64=$(Build.SourcesDirectory)\release_arm64\net10.0\native\cswinrtprojectiongen.exe;run_cswinrt_generator_task=$(Build.SourcesDirectory)\release_x86\netstandard2.0\WinRT.Generator.Tasks.dll;branch=$(Build.SourceBranchName);commit=$(Build.SourceVersion)
buildProperties: cswinrt_nuget_version=$(NugetVersion);interop_winmd=$(Build.SourcesDirectory)\release_x86\native\WindowsRuntime.Internal.winmd;net10_runtime=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.Runtime.dll;net10_runtime_xml=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.Runtime.xml;source_generator=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.SourceGenerator.dll;winrt_shim=$(Build.SourcesDirectory)\release_x86\net10.0\WinRT.Host.Shim.dll;winrt_host_x86=$(Build.SourcesDirectory)\release_x86\native\WinRT.Host.dll;winrt_host_x64=$(Build.SourcesDirectory)\release_x64\native\WinRT.Host.dll;winrt_host_arm64=$(Build.SourcesDirectory)\release_arm64\native\WinRT.Host.dll;winrt_host_resource_x86=$(Build.SourcesDirectory)\release_x86\native\WinRT.Host.dll.mui;winrt_host_resource_x64=$(Build.SourcesDirectory)\release_x64\native\WinRT.Host.dll.mui;winrt_host_resource_arm64=$(Build.SourcesDirectory)\release_arm64\native\WinRT.Host.dll.mui;cswinrtinteropgen_x64=$(Build.SourcesDirectory)\release_x64\net10.0\native\cswinrtinteropgen.exe;cswinrtinteropgen_arm64=$(Build.SourcesDirectory)\release_arm64\net10.0\native\cswinrtinteropgen.exe;cswinrtimplgen_x64=$(Build.SourcesDirectory)\release_x64\net10.0\native\cswinrtimplgen.exe;cswinrtimplgen_arm64=$(Build.SourcesDirectory)\release_arm64\net10.0\native\cswinrtimplgen.exe;cswinrtprojectiongen_x64=$(Build.SourcesDirectory)\release_x64\net10.0\native\cswinrtprojectiongen.exe;cswinrtprojectiongen_arm64=$(Build.SourcesDirectory)\release_arm64\net10.0\native\cswinrtprojectiongen.exe;run_cswinrt_generator_task=$(Build.SourcesDirectory)\release_x86\netstandard2.0\WinRT.Generator.Tasks.dll;branch=$(Build.SourceBranchName);commit=$(Build.SourceVersion)
packDestination: $(ob_outputDirectory)\packages

- ${{ if eq(parameters.IsGitHub, false) }}:
Expand Down
4 changes: 2 additions & 2 deletions docs/diagnostics/cswinrt30001.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CsWinRT warning CSWINRT3001

This type or method is a private implementation detail, and it's only meant to be consumed by generated projections (produced by 'cswinrt.exe') and by generated interop code (produced by 'cswinrtinteropgen.exe'). Private implementation detail types are not considered part of the versioned API surface, and they are ignored when determining the assembly version following semantic versioning. Types might be modified or removed across any version change for 'WinRT.Runtime.dll', and using them in user code is undefined behavior and not supported.
This type or method is a private implementation detail, and it's only meant to be consumed by generated projections (produced by the CsWinRT projection writer at build time) and by generated interop code (produced by 'cswinrtinteropgen.exe'). Private implementation detail types are not considered part of the versioned API surface, and they are ignored when determining the assembly version following semantic versioning. Types might be modified or removed across any version change for 'WinRT.Runtime.dll', and using them in user code is undefined behavior and not supported.

For instance, the following sample generates CSWINRT3001:

Expand All @@ -22,7 +22,7 @@ Using any private implementation detail API is not supported, and should be cons

`CSWINRT30001` is emitted when user code tries to reference a type that is marked as a **private implementation detail** within `WinRT.Runtime.dll` or the generated `WinRT.Interop.dll`. These private implementation detail types exist solely to support the marshalling pipeline that CsWinRT and the .NET SDK generate at build time. They are not part of the public, versioned API surface, and consuming them from application code is unsupported.

While all of these types are public (as they are used across assembglies), they are intentionally hidden from IntelliSense and decorated with `[Obsolete]` (with `CSWINRT3001` as the diagnostic id) to warn when they are referenced. Their names often include `Impl`, `Helpers`, or other internal wording, and their diagnostic message explicitly states that they are private implementation details. During a build, `cswinrt.exe` produces projections and `cswinrtinteropgen.exe` produces `WinRT.Interop.dll`. The generated code inside these tools uses private implementation detail types to perform marshalling work. See `docs/winrt-interop-dll-spec.md` for a description of the generated interop assembly. Because the tooling controls all references to these types, their shape can change whenever needed without breaking consumers. This flexibility is what allows performance and reliability improvements across releases.
While all of these types are public (as they are used across assembglies), they are intentionally hidden from IntelliSense and decorated with `[Obsolete]` (with `CSWINRT3001` as the diagnostic id) to warn when they are referenced. Their names often include `Impl`, `Helpers`, or other internal wording, and their diagnostic message explicitly states that they are private implementation details. During a build, the CsWinRT projection writer produces the projection sources for component libraries and Windows SDK / WinUI projections, and `cswinrtinteropgen.exe` produces `WinRT.Interop.dll`. The generated code inside these tools uses private implementation detail types to perform marshalling work. See `docs/winrt-interop-dll-spec.md` for a description of the generated interop assembly. Because the tooling controls all references to these types, their shape can change whenever needed without breaking consumers. This flexibility is what allows performance and reliability improvements across releases.

## Recommended action

Expand Down
2 changes: 1 addition & 1 deletion docs/interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

CsWinRT 3.0 provides a complete COM interop layer for Windows Runtime types on .NET 10+. All interop types are in the `WindowsRuntime.InteropServices` namespace (assembly: `WinRT.Runtime.dll`). Most marshalling is handled automatically by the generated projection and interop assemblies, but advanced scenarios may require direct use of the APIs below.

> **Note:** CsWinRT exposes many types and methods marked `[Obsolete]` with diagnostic `CSWINRT3001`. These are **private implementation details** consumed only by generated code (`cswinrt.exe` and `cswinrtinteropgen.exe`). They are not part of the versioned API surface, may change without notice, and should not be used in application code. This guide covers only the supported public APIs.
> **Note:** CsWinRT exposes many types and methods marked `[Obsolete]` with diagnostic `CSWINRT3001`. These are **private implementation details** consumed only by generated code (produced by the projection writer and `cswinrtinteropgen.exe`). They are not part of the versioned API surface, may change without notice, and should not be used in application code. This guide covers only the supported public APIs.

## Summary

Expand Down
Loading