Skip to content

fix(wpf): use UTF-8 for native compilation - #11997

Open
ProjektMing wants to merge 1 commit into
dotnet:mainfrom
ProjektMing:codex/wpf-utf8-compilation
Open

ProjektMing wants to merge 1 commit into
dotnet:mainfrom
ProjektMing:codex/wpf-utf8-compilation

Conversation

@ProjektMing

@ProjektMing ProjektMing commented Oct 5, 2026 •

Copy link
Copy Markdown

Append /source-charset:utf-8 /execution-charset:utf-8 to inherited compiler options in the shared Wpf.Cpp.props. Also replace the em dash with an ASCII -.

Fixes #11996

Description

On Windows code page 936, MSVC interprets UTF-8 source files without a BOM using the host code page. The em dashes in DirectWriteForwarder's TtfDelta comments trigger C4819/C2220 and stop the WPF build.

Append /source-charset:utf-8 /execution-charset:utf-8 to inherited compiler options in the shared Wpf.Cpp.props. Source-only UTF-8 settings expose C4566 for © in generated C++ assembly attributes on this machine; explicitly selecting the execution charset preserves the copyright text.

Replace three comment em dashes with ASCII hyphens. The three-file patch changes the common compiler configuration and comments.

Customer Impact

Contributors using affected Windows code pages cannot build WPF from source. An explicit encoding makes this build behavior independent of the host code page. End-user application impact has not been demonstrated.

Regression

Reproduces at WPF commit e89a851c5792c8777a7115cc7a797fd0c045fdd4. The first affected release or commit has not been established.

Testing

  • WPF Windows x64 Release restore/build/pack/publish through the VMR passed with 0 warnings and 0 errors; dependencies were reused, and the native projects actually recompiled.
  • All 29 actual compiler command logs include both charset options.
  • CLR metadata in DirectWriteForwarder.dll and System.Printing.dll preserves © Microsoft Corporation. All rights reserved..
  • Inspected 1,382 WPF-owned source/header inputs, including generated files. The only non-ASCII or Unicode-escape literal candidates were the two copyright attributes.
  • Exported with darc vmr diff and applied to an independent WPF checkout at the synchronized revision. The resulting sources match the validated sources; patch application and whitespace checks passed.

Standalone builds, other architectures/configurations, and runtime regression tests were not run.

Risk

Expected risk to existing WPF code is low based on the inspection and successful build. The execution charset can change the bytes of future non-ASCII ordinary narrow literals; callers must use the matching encoding. The input inspection excludes Windows SDK/toolchain headers and does not establish runtime equivalence across all configurations.

Note

This change and PR description were AI-generated with OpenAI Codex.

Microsoft Reviewers: Open in CodeFlow

Set source and execution charsets in the shared Wpf.Cpp.props compiler
options while preserving inherited options.

Avoid C4819/C2220 on Windows code page 936 and C4566 in generated
copyright attributes. Replace three comment em dashes with ASCII
hyphens so those comments do not depend on the source encoding.

Validation:
- VMR WPF Windows x64 Release restore/build/pack/publish passed with no
  warnings or errors.
- All 29 compiler command logs contain both UTF-8 charset options.
- DirectWriteForwarder and System.Printing copyright metadata is correct.
- darc vmr diff exported the three-file patch; it matches the validated
  VMR patch and applies cleanly to the WPF synchronization baseline.
- git diff --check passed.

AI-generated with OpenAI Codex.
@ProjektMing
ProjektMing requested review from a team and a balanced review from Copilot October 5, 2026 17:03
@ProjektMing
ProjektMing requested a review from a team as a code owner October 5, 2026 17:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 Oct 5, 2026
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.

WPF native build fails with C4819 on Windows code page 936

2 participants