Skip to content

Add 'RunCsWinRTGenerator' task and target #49417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

Sergio0694
Copy link
Contributor

This PR adds supporting infra for CsWinRT 3.0 (see here):

  • A RunCsWinRTGenerator task that runs cswinrtgen
  • A target that loads and invokes the task as needed

Everything is opt-in and off-by-default.

@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/cswinrtgen-task branch from e40a0c5 to 3e38237 Compare July 15, 2025 18:43
@Sergio0694 Sergio0694 marked this pull request as ready for review July 15, 2025 18:43
@Copilot Copilot AI review requested due to automatic review settings July 29, 2025 03:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds infrastructure for CsWinRT 3.0 support by introducing a new MSBuild task and target for running the cswinrtgen tool. The feature is opt-in and disabled by default to support the preview nature of CsWinRT 3.0.

Key Changes:

  • Added RunCsWinRTGenerator MSBuild task that wraps the cswinrtgen tool execution
  • Created _RunCsWinRTGenerator target with incremental build support and proper dependency management
  • Implemented automatic tool path resolution based on the WinRT.Runtime.dll assembly location

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets Adds MSBuild targets and properties for CsWinRT generator integration with incremental build support
src/Tasks/Microsoft.NET.Build.Tasks/RunCsWinRTGenerator.cs Implements the MSBuild task that invokes the cswinrtgen tool with comprehensive parameter validation
Comments suppressed due to low confidence (1)

src/Tasks/Microsoft.NET.Build.Tasks/RunCsWinRTGenerator.cs:109

  • NET10_0_OR_GREATER is not a valid .NET target framework version. The highest released version as of my knowledge cutoff is .NET 8.0. Consider using NET8_0_OR_GREATER or remove this conditional compilation if it's intended for future versions.
#if NET10_0_OR_GREATER

}

if (CsWinRTToolsArchitecture is not null &&
!CsWinRTToolsArchitecture.Equals("x86", StringComparison.OrdinalIgnoreCase) &&
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The architecture validation logic could be simplified using a collection-based approach. Consider using a HashSet or array with Contains() for better maintainability.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants