Skip to content

[MilCodeGen] Optimize generated ValueSerializers code style and usings #10648

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 1 commit into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Mar 25, 2025

Description

Resolves numerous IDE warnings and reflects more closely current code-style in derived ValueSerializers.

Also removes redundant usings. Instead of using the collection from the resource tree, we only really need the managed namespace for the resource itself and System.Windows.Markup for ValueSerializer, this is static dependency so the definition doesn't need to be in the resource model itself (same thing as System.Windows.Markup.TypeConverterHelper is directly linked in generator code).

Reviewing ManagedStruct.cs shall be enough to get the grip of the changes, also the changes are always consistent per-folder so 1 file gives you overview of full set of changes for that particular set of resources.

Customer Impact

Cleaner codebase for developers.

Regression

No.

Testing

Local build.

Risk

Low.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners March 25, 2025 21:30
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Mar 25, 2025
@pchaurasia14 pchaurasia14 requested a review from Copilot March 25, 2025 21:38
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 optimizes the generated ValueSerializers code style by simplifying conditional logic and removing redundant using statements.

  • Consolidates usings by removing the dynamic iteration over namespaces in favor of static references.
  • Streamlines conversion logic with inline ternary operators and pattern matching.
Comments suppressed due to low confidence (1)

src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/generators/ManagedStruct.cs:981

  • This line uses '[[lowerName]]' assuming it refers to the pattern-matched instance from a previous check; however, it might accidentally reference the earlier declared string variable. A distinct name for the pattern variable would improve clarity and prevent potential conflicts.
return [[lowerName]].ConvertToString(null, ConverterHelper.InvariantEnglishUS);

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 90 lines in your changes missing coverage. Please review.

Project coverage is 11.26680%. Comparing base (6514196) to head (2468f58).
Report is 3 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10648         +/-   ##
===================================================
+ Coverage   11.22814%   11.26680%   +0.03866%     
===================================================
  Files           3352        3353          +1     
  Lines         668000      667874        -126     
  Branches       74980       74956         -24     
===================================================
+ Hits           75004       75248        +244     
+ Misses        591745      591371        -374     
- Partials        1251        1255          +4     
Flag Coverage Δ
Debug 11.26680% <25.00000%> (+0.03866%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dipeshmsft dipeshmsft self-assigned this Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants