Centralize build properties and clean up project files - #2472
Merged
Sergio0694 merged 28 commits intoJul 25, 2026
Conversation
Sergio0694
force-pushed
the
user/sergiopedri/centralize-build-props
branch
3 times, most recently
from
June 26, 2026 00:03
64be0a5 to
9043c1b
Compare
Add centralized global properties and stricter defaults in Directory.Build.props/targets: enable embedded debug symbols, set DotNetVersion/net10.0 and LangVersion=14.0, enforce warnings-as-errors in Release, enable strict/analysis levels and code-style enforcement, add common NoWarn entries (CS8500, NETSDK1229), generate documentation files. In Directory.Build.targets enable AOT/marshalling-friendly settings for net10.0 projects (IsAotCompatible for libraries, DisableRuntimeMarshalling, EmitSkipLocalsInitAttribute), NativeAOT publish optimizations (InvariantGlobalization, OptimizationPreference, IlcDehydrate=false, IlcResilient=false, ControlFlowGuard) and other build folder/FrameworkReference adjustments. Also cleaned up comments and formatting.
…d.props These build properties are now set centrally for all C# projects in src/Directory.Build.props, so the per-project copies are redundant: LangVersion, TreatWarningsAsErrors/CodeAnalysisTreatWarningsAsErrors, AnalysisLevel, AnalysisLevelStyle, EnforceCodeStyleInBuild, Features=strict, GenerateDocumentationFile, and the centralized NoWarn entries CS8500 and NETSDK1229. Removing the stray LangVersion overrides also drops the leftover 'preview' override in WinRT.Impl.Generator (a leftover from before C# 14.0 shipped), so every project now picks up the centralized LangVersion=14.0 instead of accidentally compiling with the preview language version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…y.Build.targets
These properties are now applied centrally to all net10.0 C# projects (and, for
the NativeAOT options, to all net10.0 projects that set PublishAot=true) in
src/Directory.Build.targets, so the per-project copies are redundant:
- IsAotCompatible, DisableRuntimeMarshalling, EmitSkipLocalsInitAttribute
- InvariantGlobalization, OptimizationPreference, StackTraceSupport,
UseSystemResourceKeys, ControlFlowGuard, IlcDehydrate, IlcResilient
The build tools keep their own PublishAot=true (which is what gates the
centralized NativeAOT options), so the generated binaries are unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Directory.Build.props now defines a single DotNetVersion property (net10.0) so
the .NET version used across the repo can be changed in one place. Point the
core projects' TargetFramework at it instead of hardcoding net10.0:
- The runtime, projection writer, generator core, source generator and the
five CLI build tools now use <TargetFramework>$(DotNetVersion)</TargetFramework>.
- WinRT.Internal uses $(DotNetVersion)-windows10.0.26100.1 (it keeps its
CsWinRT 3.0 Windows TFM revision).
The resolved framework is unchanged (net10.0), so build outputs land in the
same folders that existing HintPath/tool-directory references rely on.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Several project-level NoWarn suppressions no longer fire and can be dropped
(verified with Release --no-incremental builds, where warnings are errors):
- WinRT.Interop.Generator: remove IDE0028 and IDE0370. IDE0028 no longer
fires. IDE0370 ("suppression is unnecessary") was firing on a redundant
null-forgiving operator 'type.FullName!' in SignatureGenerator.cs; FullName
is a non-nullable string, so the '!' is removed and the suppression dropped.
- WinRT.Impl.Generator / WinRT.WinMD.Generator: remove IDE0028 (no longer fires).
- WinRT.Projection.Generator: drop IDE0028 from the NoWarn list (no longer
fires), keeping only the IL* trim/AOT suppressions for the Roslyn reference.
The Writer's IDE suppressions and the projection generator's IL* suppressions
are intentionally retained because they still fire.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The centralized properties added in Directory.Build.props/targets surfaced two
build breaks in projects that don't allow unsafe code (e.g. WinRT.Internal):
- EmitSkipLocalsInitAttribute was enabled for every net10.0 C# project, but the
C# compiler requires AllowUnsafeBlocks to use '[module: SkipLocalsInit]'
(CS0227). Condition the centralized property on AllowUnsafeBlocks so only
projects that opt into unsafe code emit it. This matches the pre-centralization
behavior (only the unsafe runtime/build-tool projects ever set it) and fixes
WinRT.Internal plus any other non-unsafe net10.0 project.
- GenerateDocumentationFile is now enabled everywhere, which makes the compiler
validate XML doc comments. ProjectionInternalAttribute had a <para> closed by
</remarks> (CS1570), which becomes an error under the centralized
Release warnings-as-errors. Add the missing </para>.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Every C# project in the repo allows unsafe code (the runtime and build tools rely heavily on pointers and other unsafe constructs for interop), so set AllowUnsafeBlocks=true once in the centralized Globals property group, right after LangVersion, and remove the now-redundant per-project copies (the nine core projects plus UnitTest, DiagnosticTests, BuildDeterminismComponent, WinRT.Host.Shim, and the FunctionalTests Directory.Build.props). The conditional override in the NonWinRT functional test (AllowUnsafeBlocks=false when TestUnsafeDisabled is set) is kept, since it still correctly overrides the centralized default for that test scenario. The previously added EmitSkipLocalsInitAttribute guard (gated on AllowUnsafeBlocks) keeps composing correctly: projects that opt out of unsafe code also won't emit SkipLocalsInit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The centralized analysis settings now apply to WinRT.Host.Shim, which surfaced
trim/AOT, documentation and code-style warnings (treated as errors by the
Authoring Directory.Build.props):
- IL2026/IL2075: this project is meant to be used for hosting scenarios with
CoreCLR, so trimming/AOT aren't supported by design. The centralized
IsAotCompatible default is now only applied when a project hasn't set it,
and WinRT.Host.Shim explicitly opts out (IsAotCompatible=false), which
disables the trim/AOT analyzers for it.
- CS1591: add XML docs for the public Shim type, GetActivationFactoryDelegate
and GetActivationFactory.
- IDE0073/IDE0008/IDE0047/IDE0046 (and the IDE0300/IDE0350/IDE0058 already
applied by dotnet format): add the file header, use explicit types, drop
redundant parentheses, and use a conditional expression.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…is rules
The centralized code-style enforcement now applies to WinRT.Generator.Tasks,
surfacing warnings that are treated as errors in Release:
- IDE0073: replace the '.NET Foundation' file header with the repo's
'Copyright (c) Microsoft Corporation.' header in the five task files.
- IDE0370: remove the redundant null-forgiving operator on the non-nullable
CsWinRTToolsDirectory property in the Path.Combine calls.
- IDE0005: remove unnecessary using directives (applied via dotnet format).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Perf/ResultsComparer is a local-only benchmark results comparer (not shipped and not part of cswinrt.slnx), so the repo's centralized strict analysis doesn't add value there. Suppress CS1591 (missing XML docs) and disable EnforceCodeStyleInBuild for it, with a comment, rather than churning a ported tool to satisfy the CsWinRT code-style rules. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Helpers.cs used 'AnalyzerConfigOptionsProvider?' parameters, but the project isn't in a nullable-enabled context, so under the centralized Release warnings-as-errors these produced CS8632 errors. The project is non-nullable, so the annotation has no effect on behavior; drop the '?' on both parameters. The pre-existing CS0246 in UnitTesting.cs (a stale 'using WinRT;' from the 2.x namespace) is left as-is, to be addressed separately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The generated projection sources surface evaluation-only ([Experimental]) Windows Runtime APIs (e.g. Windows.Storage.Provider.StorageProviderShareLinkState, Windows.ApplicationModel.DataTransfer.TransferTarget), which produce CS8305 and fail under the projections' warnings-as-errors. These APIs are expected in a full SDK projection, so add a NoWarn for CS8305 in the shared Projections Directory.Build.props. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
Remove several obsolete/strict build properties and consolidate projection settings. This removes TreatWarningsAsErrors, DisableRuntimeMarshalling, CsWinRTAotOptimizerEnabled, EnableTrimAnalyzer, IsTrimmable and IsAotCompatible, adds a "Projection settings" comment, and moves SimulateCsWinRTNugetReference into the projections PropertyGroup for clearer organization.
Add CS1591 to the WarningsNotAsErrors list in src/Projections/Directory.Build.props so missing XML comment warnings (e.g. for CoreDragDropManager) are not treated as build errors. Also update the nearby comment block to document the CS1591 entry.
The centralized GenerateDocumentationFile=true applied to every project, which
enforced CS1591 (missing XML comment) on all public members of non-product
projects and on generated projection code (e.g. SourceGenerator2Test produced
~74k CS1591). We only care about XML docs for the actual product projects, which
are all named with a 'WinRT.' prefix, so gate GenerateDocumentationFile behind
MSBuildProjectName.StartsWith('WinRT.').
This removes the documentation warnings (CS1591/CS1573) from tests, samples,
benchmarks, the local projection projects, etc., while keeping docs enabled for
the product projects (which already build clean with them on).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Building SourceGenerator2Test failed via its Projections\Windows dependency on
two IDE diagnostics: IDE0073 (missing file header on Module.cs) and the
EnableGenerateDocumentationFile error (IDE0005 requires GenerateDocumentationFile
to be on, which the previous commit turned off for non-product projects).
These are all driven by the centralized EnforceCodeStyleInBuild +
AnalysisLevelStyle=latest-all applying to every project. As with the
documentation files, we only care about the repo's strict code-style rules for
the actual product projects (those named with a 'WinRT.' prefix), so gate both
properties behind MSBuildProjectName.StartsWith('WinRT.').
This makes SourceGenerator2Test (and its Projections\Windows / WinAppSDK
dependencies) build clean, while product projects keep full code-style
enforcement.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The 'WinRT.' project-name prefix check used to scope documentation generation
and code-style enforcement to product projects was duplicated across three
conditions. Define it once as an IsPublicProject property (in the Globals group)
and reference it from GenerateDocumentationFile, AnalysisLevelStyle and
EnforceCodeStyleInBuild.
This is a pure refactor: IsPublicProject resolves to the same true/false the
inline MSBuildProjectName.StartsWith('WinRT.') checks produced, so all three
properties evaluate identically to before.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
UnitTest deliberately exercises private-implementation-detail APIs from WinRT.Runtime (HStringMarshaller, WellKnownInterfaceIIDs, WindowsRuntimeObjectReferenceValue, UriMarshaller, etc.) that are marked obsolete via the CSWINRT3001 diagnostic. Under the centralized Release warnings-as-errors these became build errors, so suppress CSWINRT3001 for this test project. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Microsoft.Windows.CsWin32 source generator emits a 'winmdroot' namespace, which trips CS8981 ('the type name only contains lower-cased ascii characters'). This is generated code we don't control, and under the centralized Release warnings-as-errors it became a build error, so suppress CS8981 in the two projects that reference CsWin32.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The component uses Windows-only APIs (Windows.Foundation.Point/Rect, Microsoft.UI.Xaml), which trip CA1416 because the project targets a platform-agnostic net10.0 TFM. We can't switch to a -windows TFM to satisfy the analyzer because the determinism test harness (BuildDeterminismTest/Program.cs) hard-codes the net10.0 TFM and output path, so suppress CA1416 instead. The component is only ever built and run on Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address the non-suppressed warnings that became errors under the centralized Release warnings-as-errors: - UnitTest CS0693: 'TestMethod<T>' shadowed the 'ITestCSharp<T>' type parameter. The method is unused filler (only the type name of 'ITestCSharp<double>' is asserted), so rename its type parameter to 'TMethod'. - UnitTest CS0672: the 'TestIDICInspectable' test class intentionally overrides obsolete (CSWINRT3001) private-implementation base members; wrap those overrides in a scoped '#pragma warning disable CS0672' with a comment (we don't want to mark test overrides obsolete). - Benchmarks CS0162: two 'GC.KeepAlive(s)' calls were placed after 'return', making them unreachable. Move them before the 'return' so they keep the delegate alive as intended. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
UnitTest deliberately calls Windows Runtime APIs annotated with [SupportedOSPlatform] for a higher Windows version than the project minimum: the 'Warning*' types exercised by TestSupportedOSPlatformWarnings exist specifically to verify those platform warnings fire, and ComInteropTests calls the DisplayInformation interop extensions (22621). Under the centralized Release warnings-as-errors these CA1416 warnings became errors. Suppress CA1416 for this test project rather than raising the minimum target platform, which would defeat the purpose of TestSupportedOSPlatformWarnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Microsoft.Windows.CsWin32 source generator emits a CoRegisterClassObject P/Invoke (Windows.Win32.PInvoke.Ole32) that uses COM marshalling. This trips IL2050 (COM interop correctness cannot be guaranteed after trimming) and CA1420 (managed parameter/return types require runtime marshalling, which is disabled repo-wide via the centralized DisableRuntimeMarshalling). This is generated code we don't control, so suppress both in UnitTest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TestPnpPropertiesInLoop is a manual stress helper kept private so MSTest doesn't auto-run it (PnP enumeration is environment-dependent). The MSTest analyzer flags MSTEST0003 ('test method signature is invalid') because a [TestMethod] must be public. Keep the method private (preserving behavior - it is never auto-discovered) and the [TestMethod] for easy ad-hoc runs, wrapping it in a scoped pragma to suppress MSTEST0003 with an explanatory comment.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
OOPExe: suppress CA1416, since it's a Windows-only out-of-process COM/WinRT test harness that targets plain net10.0 (a Windows TFM would pull the CsWinRT 2.x SDK projection and clash with the 3.0 Test projection it references). UnitTest: fix CA2022 inexact stream reads via ReadExactly/ReadExactlyAsync; replace always-failing Assert.IsTrue(false) with Assert.Fail() (MSTEST0025); drop redundant Assert.IsTrue(true) (MSTEST0032); make TestInterfaceGeneric public (MSTEST0003); make Estruct.value public (CS0169); drop a stray nullable annotation (CS8632); and locally suppress the intentional test patterns CSWINRT2009 (cast to a [ComImport] interface) and CS8305 (experimental API). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sergio0694
force-pushed
the
user/sergiopedri/centralize-build-props
branch
from
July 24, 2026 18:13
caaa168 to
4c00e8a
Compare
Sergio0694
marked this pull request as ready for review
July 24, 2026 18:15
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
The XAML compiler emits a backing field for every 'x:Name'-d element into the generated '*.g.i.cs' files. 'ObjectLifetimePage' deliberately drops its strong references to 'MoveCanvas' and '_itemsControlLeakTest' (both are set to null right after 'InitializeComponent()', so the leak tests can actually collect them) and then looks them back up with 'FindName(...)'. Those fields are therefore only ever assigned, which trips CS0414 and fails release builds through 'TreatWarningsAsErrors'. Suppress CS0414 in ObjectLifetimeTests.Lifted.csproj, since this is generated code we don't control. This replaces the previous CS1591/EnforceCodeStyleInBuild suppression, which was a no-op for this project: XML documentation generation and code-style enforcement are only enabled for the repo's public (WinRT.*) projects. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 207d6819-eb58-4c93-bf98-dcef373fe5c1
Sergio0694
force-pushed
the
user/sergiopedri/centralize-build-props
branch
from
July 24, 2026 21:05
ee1cdf4 to
67ca605
Compare
'BasicTest1' ended with an 'Assert.IsTrue(true)' after '_asyncQueue.Run()', which trips MSTEST0032 ("review or remove the assertion as its condition is known to be always true") and fails release builds through 'TreatWarningsAsErrors'. The assertion carries no value: the test's real verification happens inside the queued UI-thread callbacks via 'Verify(...)', which throws 'TestException' on failure. Remove it, so the method now ends with '_asyncQueue.Run()' like the sibling 'BasicTest2'/'BasicTest3'/'BasicTest4' methods.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 207d6819-eb58-4c93-bf98-dcef373fe5c1
Sergio0694
enabled auto-merge (squash)
July 25, 2026 00:15
manodasanW
approved these changes
Jul 25, 2026
Sergio0694
added a commit
that referenced
this pull request
Jul 28, 2026
The custom overload names change (#2454) took error ids 0011 and 0012 for 'WindowsSdkNotFound' and 'CannotReadWindowsSdkXml', so renumber the new by-reference array/span parameter errors to 0013 and 0014 and update the tests and the testing skill accordingly. Also update the new test project for the build changes on staging: drop 'LangVersion' (now centralized in 'src/Directory.Build.props') and drop the removed 'ARM' platform from the solution entry (#2472, #2489). Finally, fix the stale 'GlobalPropertiesToRemove' mention in the testing skill, which the project file replaced with 'UndefineProperties'. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ec1fee3-01c2-4213-baf0-bed82d056068
Sergio0694
added a commit
that referenced
this pull request
Jul 28, 2026
… tests (#2443) * Fix custom-modifier type erasure in the WinMD generator type mapping MapTypeSignatureToOutput had no handling for CustomModifierTypeSignature, so any modifier-wrapped type fell through to the 'System.Object' fallback and was silently erased. This affects 'in' parameters on abstract/virtual/interface/delegate members, where the C# compiler emits a 'modreq(InAttribute)' on the by-reference type. For example, a COM interop 'in Guid riid' was emitted as '[in] object' instead of '[in] Guid&'. Strip leading custom modifiers before dispatching on the underlying type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Validate unsupported array/span parameter conventions in the WinMD generator Windows Runtime arrays use one of three conventions (ReadOnlySpan<T> for PassArray, Span<T> for FillArray, or 'out T[]' for ReceiveArray), and spans are always passed by value. The generator previously emitted invalid metadata for a few shapes: 'ref T[]'/'in T[]' became '[in] T[]&', and 'out Span<T>'/'out ReadOnlySpan<T>' became a ReceiveArray. Reject these with clear errors (CSWINRTWINMDGEN0011 for by-reference arrays, CSWINRTWINMDGEN0012 for by-reference spans), while preserving the deliberate COM interop 'ref'/'in' scalar behavior (e.g. 'ref Guid riid' -> '[in]') and the by-value array PassArray default. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add WinMD generator parameter-convention failure tests Add a WinMDGeneratorTest project that runs the actual cswinrtwinmdgen tool end-to-end: it compiles small C# inputs with Roslyn, invokes the generator as a subprocess, and asserts a non-zero exit code plus the expected CSWINRTWINMDGEN error. The project deliberately focuses on failure cases (unsupported 'ref'/'in' arrays and 'out' spans), which can be exercised here without failing the build; the supported '.winmd' shapes (PassArray/FillArray/ReceiveArray) are covered by the authoring tests. The generator exposes no internals to the test project. Registers the project in the solution. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add WinMD generator invocation and invalid-input failure tests Extend the WinMDGeneratorTest harness with a custom-response-file overload and a public CompileComponent helper, then add Test_InvalidInputs covering the generator's remaining end-to-end failure modes: a missing response file (CSWINRTWINMDGEN0001), a malformed or duplicate-argument response file (0002), a missing required or unparseable argument (0003), a missing or corrupt input assembly (0004), an unwritable output path (0006), and a missing debug-repro directory (0008). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Move WinMD generator TypeSignature helpers into an extension file Move StripCustomModifiers (previously a private method in WinMDWriter.TypeMapping) and the span predicates into a new Extensions/TypeSignatureExtensions.cs, matching the existing TypeDefinitionExtensions pattern. Rename IsSpan/IsReadOnlySpan to IsTypeOfSpan/IsTypeOfReadOnlySpan as extension methods, consistent with the interop generator's IsTypeOf* extensions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add AssertSuccess/AssertFailure helpers to collapse WinMD generator tests Rename the test helper to WinMDGeneratorRunner and give it AssertSuccess/AssertFailure entry points that run the generator and make the exit-code and error-output assertions, so each test is a single call. The run mechanics (Run, RunTool, GetGeneratorPath, the failure-result assertion, cleanup) are private; only the assertion entry points and CompileComponent (used by the response-file factory scenarios) are public. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Take full response file content as a single string in WinMD generator tests Change the AssertFailure response-file factory from Func<string, IReadOnlyList<string>> to Func<string, string> so callers provide the entire '.rsp' content as one multiline raw interpolated string instead of a list of per-line expressions. The runner now writes the content verbatim with File.WriteAllText. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Document the WinMDGeneratorTest project in the testing skill Add a 'WinMD generator tests' section describing the new src/Tests/WinMDGeneratorTest project (end-to-end failure-case tests for cswinrtwinmdgen), add a routing-table row, and bump the primary test area count to 6. Also add a matching per-project verification step to the update-testing-instructions skill and renumber the subsequent steps. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix stale comment in WinMDGeneratorTest project file The tests run the generator tool end-to-end as a subprocess rather than exercising its managed logic in-process, so update the comment that justifies 'CsWinRTEnabled=false' to match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Move new WinMD generator errors after the existing ones Define the by-reference array/span parameter errors (0011/0012) after the debug-repro errors (0008-0010) instead of in the middle, so the methods appear in ascending error-id order. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Build the WinMD generator framework-dependent in the test project (NETSDK1151) The generator's PublishAot build is self-contained, which a non self-contained executable cannot reference (NETSDK1151). Replace GlobalPropertiesToRemove for RuntimeIdentifier with UndefineProperties for BuildToolArch, PublishBuildTool, RuntimeIdentifier and SelfContained so the tool is built framework-dependent for the build host, matching the proven WinRT.Internal reference pattern. The output stays under net10.0 (no RID subfolder), so the tool path used by the tests is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Wrap long exception messages for readability Split long interpolated exception message strings into multi-line concatenated strings in src/WinRT.WinMD.Generator/Errors/WellKnownWinMDExceptions.cs (ByReferenceArrayParameterNotSupported and ByReferenceSpanParameterNotSupported) to improve readability and line-length compliance; no functional behavior changes. * Adapt the WinMD generator parameter validation to staging/3.0 The custom overload names change (#2454) took error ids 0011 and 0012 for 'WindowsSdkNotFound' and 'CannotReadWindowsSdkXml', so renumber the new by-reference array/span parameter errors to 0013 and 0014 and update the tests and the testing skill accordingly. Also update the new test project for the build changes on staging: drop 'LangVersion' (now centralized in 'src/Directory.Build.props') and drop the removed 'ARM' platform from the solution entry (#2472, #2489). Finally, fix the stale 'GlobalPropertiesToRemove' mention in the testing skill, which the project file replaced with 'UndefineProperties'. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ec1fee3-01c2-4213-baf0-bed82d056068 * Update the WinMD generator error id range in the instructions The range was already stale at '0001'-'0010': the custom overload names change (#2454) added 0011 and 0012. This adds 0013 and 0014, so bump the documented range to '0001'-'0014'. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ec1fee3-01c2-4213-baf0-bed82d056068 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ec1fee3-01c2-4213-baf0-bed82d056068
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Centralize the common MSBuild properties for all C# projects into
Directory.Build.props/Directory.Build.targets, then remove the now-redundant per-project copies, fix the C# language version that was accidentally pinned toprevieweverywhere, and point the core projects at a single shared$(DotNetVersion).Motivation
Properties such as
LangVersion,AllowUnsafeBlocks, warnings-as-errors, analysis levels, code-style enforcement, and the AOT/NativeAOT settings were copy-pasted across roughly a dozen project files, which is noisy and easy to drift. A strayLangVersion=previewinDirectory.Build.targets(imported after each project body) was also silently overriding every project back to the preview language version, even the ones that explicitly set14.0. Centralizing these settings removes the duplication, makes it possible to try a different .NET version or language version from one place, and fixes the accidentalpreviewlanguage version. While validating the result, the centralization also surfaced two latent build breaks that are fixed here.Changes
Centralized build configuration
src/Directory.Build.props: add aGlobalsproperty group (scoped to.csproj) that definesDotNetVersion(net10.0),LangVersion=14.0,AllowUnsafeBlocks=true, Release-onlyTreatWarningsAsErrors/CodeAnalysisTreatWarningsAsErrors,AnalysisLevel/AnalysisLevelStyle,EnforceCodeStyleInBuild,Features=strict,GenerateDocumentationFile, and the commonNoWarnentries (CS8500,NETSDK1229).src/Directory.Build.targets: apply the AOT/marshalling settings (IsAotCompatiblefor libraries,DisableRuntimeMarshalling,EmitSkipLocalsInitAttribute,TrimmerSingleWarn) to net10.0 projects, and the NativeAOT publish options (InvariantGlobalization,OptimizationPreference,StackTraceSupport,UseSystemResourceKeys,ControlFlowGuard,IlcDehydrate,IlcResilient) to net10.0PublishAotprojects.Project file cleanup
WinRT.Runtime2,WinRT.Generator.Core,WinRT.Projection.Writer,WinRT.SourceGenerator2,WinRT.Sdk.Projection,WinRT.Internal, and the five build tools (cswinrtinteropgen,cswinrtimplgen,cswinrtprojectiongen,cswinrtprojectionrefgen,cswinrtwinmdgen). This also drops the leftoverLangVersion=previewoverride inWinRT.Impl.Generator.AllowUnsafeBlocks=truecopies from the core projects plusUnitTest,DiagnosticTests,BuildDeterminismComponent,WinRT.Host.Shim, and theFunctionalTestsDirectory.Build.props. TheNonWinRTtest keeps its conditionalAllowUnsafeBlocks=false(whenTestUnsafeDisabled) since it still overrides the centralized default for that scenario.TargetFrameworkat$(DotNetVersion)(WinRT.Internaluses$(DotNetVersion)-windows10.0.26100.1). The resolved framework is unchanged (net10.0), so output folders and existingHintPath/tool-directory references are unaffected.Suppressions no longer necessary
NoWarnentries that no longer fire, verified withRelease --no-incrementalbuilds (where warnings are errors):IDE0028fromcswinrtinteropgen/cswinrtimplgen/cswinrtwinmdgen/cswinrtprojectiongen, andIDE0370fromcswinrtinteropgen.WinRT.Interop.Generator/Helpers/SignatureGenerator.cs:IDE0370was firing on a redundant null-forgiving operatortype.FullName!(FullNameis a non-nullablestring); removed the!so the suppression is genuinely unnecessary. The Writer's IDE suppressions and the projection generator'sIL*(Roslyn trim/AOT) suppressions are retained because they still apply.Build-break fixes surfaced by the centralization
src/Directory.Build.targets: only emit[module: SkipLocalsInit]for projects that setAllowUnsafeBlocks(the C# compiler requires unsafe code for[SkipLocalsInit]or it producesCS0227). This matches the pre-centralization behavior and unbreaks non-unsafe net10.0 projects such asWinRT.Internal. (WithAllowUnsafeBlocksnow centralized totrue, this guard continues to do the right thing for any project that opts back out.)src/WinRT.Internal/ProjectionInternalAttribute.cs: fix a malformed XML doc comment (a<para>closed by</remarks>,CS1570) that became an error onceGenerateDocumentationFilewas enabled under Release warnings-as-errors.Validation
All core projects plus
WinRT.Internalbuild green in Release (--no-incremental, warnings-as-errors active).WinRT.Sdk.Projectioncannot be restored locally (NU1102forMicrosoft.Windows.SDK.Contracts, which CI supplies via an explicitSdkPackageVersion); this is pre-existing and unrelated to these changes. Test and sample projectTargetFrameworkvalues were intentionally left untouched, so a CI Release run is worth doing to confirm nothing else relies on the previously per-project settings.