diff --git a/src/Authoring/WinRT.Host.Shim/Module.cs b/src/Authoring/WinRT.Host.Shim/Module.cs index cf0e5b38c2..4b83f6441e 100644 --- a/src/Authoring/WinRT.Host.Shim/Module.cs +++ b/src/Authoring/WinRT.Host.Shim/Module.cs @@ -1,4 +1,7 @@ -// TODO: consider embedding this as a resource into WinRT.Host.dll, +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// TODO: consider embedding this as a resource into WinRT.Host.dll, // to simplify deployment using System; @@ -15,25 +18,34 @@ namespace WinRT.Host; +/// +/// Provides the activation factory entry point used by the native WinRT.Host shim to host managed Windows Runtime components. +/// public static class Shim { private const int S_OK = 0; private const int E_NOINTERFACE = unchecked((int)0x80004002); private const int REGDB_E_READREGDB = unchecked((int)0x80040150); - private const int CLASS_E_CLASSNOTAVAILABLE = unchecked((int)(0x80040111)); + private const int CLASS_E_CLASSNOTAVAILABLE = unchecked((int)0x80040111); + /// + /// Delegate matching the native signature used to retrieve an activation factory from a hosted component. + /// public unsafe delegate int GetActivationFactoryDelegate(IntPtr hstrTargetAssembly, IntPtr hstrRuntimeClassId, IntPtr* activationFactory); private unsafe delegate void* ManagedExportsGetActivationFactoryDelegate(ReadOnlySpan activatableClassId); private static HashSet _InitializedResolvers; + /// + /// Retrieves the activation factory for a runtime class from the specified target assembly, loading it into the default load context. + /// public static unsafe int GetActivationFactory(IntPtr hstrTargetAssembly, IntPtr hstrRuntimeClassId, IntPtr* activationFactory) { *activationFactory = IntPtr.Zero; - var targetAssembly = HStringMarshaller.ConvertToManaged((void*)hstrTargetAssembly); - var runtimeClassId = HStringMarshaller.ConvertToManaged((void*)hstrRuntimeClassId); + string targetAssembly = HStringMarshaller.ConvertToManaged((void*)hstrTargetAssembly); + string runtimeClassId = HStringMarshaller.ConvertToManaged((void*)hstrRuntimeClassId); try { @@ -41,19 +53,19 @@ public static unsafe int GetActivationFactory(IntPtr hstrTargetAssembly, IntPtr // ABI..ManagedExports.GetActivationFactory(ReadOnlySpan) -> void* string moduleName = Path.GetFileNameWithoutExtension(targetAssembly); - var managedExportsType = assembly.GetType($"ABI.{moduleName}.ManagedExports"); + Type managedExportsType = assembly.GetType($"ABI.{moduleName}.ManagedExports"); if (managedExportsType == null) { return REGDB_E_READREGDB; } - var GetActivationFactory = managedExportsType.GetMethod("GetActivationFactory", new Type[] { typeof(ReadOnlySpan) }); + MethodInfo GetActivationFactory = managedExportsType.GetMethod("GetActivationFactory", [typeof(ReadOnlySpan)]); if (GetActivationFactory == null) { return REGDB_E_READREGDB; } // ReadOnlySpan is a ref struct and can't be used with MethodInfo.Invoke. // Use a delegate to call the method directly. - var del = GetActivationFactory.CreateDelegate(); + ManagedExportsGetActivationFactoryDelegate del = GetActivationFactory.CreateDelegate(); void* factory = del(runtimeClassId.AsSpan()); if (factory == null) { @@ -72,25 +84,21 @@ private static Assembly LoadInDefaultContext(string targetAssembly) { if (_InitializedResolvers == null) { - Interlocked.CompareExchange(ref _InitializedResolvers, new HashSet(StringComparer.OrdinalIgnoreCase), null); + _ = Interlocked.CompareExchange(ref _InitializedResolvers, new HashSet(StringComparer.OrdinalIgnoreCase), null); } lock (_InitializedResolvers) { if (!_InitializedResolvers.Contains(targetAssembly)) { - var resolver = new AssemblyDependencyResolver(targetAssembly); - AssemblyLoadContext.Default.Resolving += (AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName) => + AssemblyDependencyResolver resolver = new(targetAssembly); + AssemblyLoadContext.Default.Resolving += (assemblyLoadContext, assemblyName) => { string assemblyPath = resolver.ResolveAssemblyToPath(assemblyName); - if (assemblyPath != null) - { - return assemblyLoadContext.LoadFromAssemblyPath(assemblyPath); - } - return null; + return assemblyPath != null ? assemblyLoadContext.LoadFromAssemblyPath(assemblyPath) : null; }; - _InitializedResolvers.Add(targetAssembly); + _ = _InitializedResolvers.Add(targetAssembly); } } diff --git a/src/Authoring/WinRT.Host.Shim/WinRT.Host.Shim.csproj b/src/Authoring/WinRT.Host.Shim/WinRT.Host.Shim.csproj index 2bf9c06ffa..dd1e95d058 100644 --- a/src/Authoring/WinRT.Host.Shim/WinRT.Host.Shim.csproj +++ b/src/Authoring/WinRT.Host.Shim/WinRT.Host.Shim.csproj @@ -2,10 +2,13 @@ net10.0 - - - true + + false diff --git a/src/Authoring/WinRT.SourceGenerator2/WinRT.SourceGenerator2.csproj b/src/Authoring/WinRT.SourceGenerator2/WinRT.SourceGenerator2.csproj index fe5d3cb066..b378eaf840 100644 --- a/src/Authoring/WinRT.SourceGenerator2/WinRT.SourceGenerator2.csproj +++ b/src/Authoring/WinRT.SourceGenerator2/WinRT.SourceGenerator2.csproj @@ -1,9 +1,7 @@  - net10.0 - 14.0 + $(DotNetVersion) enable - true embedded - - true - true - - - latest - - - latest-all - - - true - - - $(NoWarn);CS8500 - - - strict - - - true - true true diff --git a/src/Benchmarks/EventPerf.cs b/src/Benchmarks/EventPerf.cs index ced3c635ce..27703b1f6b 100644 --- a/src/Benchmarks/EventPerf.cs +++ b/src/Benchmarks/EventPerf.cs @@ -59,8 +59,8 @@ public object IntEventOverhead() ClassWithMarshalingRoutines instance = new ClassWithMarshalingRoutines(); int z; System.EventHandler s = (object sender, int value) => z = value; - return instance; GC.KeepAlive(s); + return instance; } [Benchmark] @@ -134,8 +134,8 @@ public object AddAndRemoveIntEventOnNewEventSource() System.EventHandler s = (object sender, int value) => z = value; instance.IntPropertyChanged += s; instance.IntPropertyChanged -= s; - return instance; GC.KeepAlive(s); + return instance; } [Benchmark] diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e05e1c2668..f70ed9cf6d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -11,10 +11,11 @@ 1.8.251104001 1.8.251104000 1.0.3179.45 + + embedded true - preview - 8305;0618 + true false $(GenerateTestProjection) @@ -37,6 +38,89 @@ high + + + + $(MSBuildProjectName.StartsWith('WinRT.')) + + + net10.0 + + + 14.0 + + + true + + + true + true + + + latest + + + latest-all + true + + + $(NoWarn);CS8500 + + + $(NoWarn);NETSDK1229 + + + $(Features);strict + + + true + + $(MSBuildThisFileDirectory)WinRT.Generator.Tasks\bin\$(Configuration)\netstandard2.0\WinRT.Generator.Tasks.dll diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 10c00ed6ea..4aad18e953 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,15 +1,81 @@ - - preview + + + + + false + + + true + + + true + + + true + + + + + true + Speed + false + true + + + Guard + + + false + + + false + + + $([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)', 'Generated Files')) $([MSBuild]::NormalizeDirectory('$(GeneratedFilesRootDir)', '$(TargetFramework)')) + <_TargetPlatformVersionUsesCsWinRT3>true @@ -21,16 +87,18 @@ - + + - + @@ -50,9 +118,10 @@ which is incompatible with CastGuard (/guard:cast). Using a target to override the Link metadata ensures it takes effect after all ItemDefinitionGroup processing. --> - + UseLinkTimeCodeGeneration @@ -105,8 +174,10 @@ - + @@ -131,5 +202,4 @@ - diff --git a/src/Perf/ResultsComparer/ResultsComparer.csproj b/src/Perf/ResultsComparer/ResultsComparer.csproj index ba1248fe44..5d59b22405 100644 --- a/src/Perf/ResultsComparer/ResultsComparer.csproj +++ b/src/Perf/ResultsComparer/ResultsComparer.csproj @@ -4,6 +4,13 @@ $(PERFLAB_TARGET_FRAMEWORKS) net8.0 latest + + + $(NoWarn);CS1591 + false diff --git a/src/Projections/Directory.Build.props b/src/Projections/Directory.Build.props index 51c066c82c..ebfcccf01c 100644 --- a/src/Projections/Directory.Build.props +++ b/src/Projections/Directory.Build.props @@ -1,9 +1,5 @@ - - true - true - - $(WarningsNotAsErrors);CS0108;CS0109;CS0114;CS0219;CS0628;CS0660;CA2257 + $(WarningsNotAsErrors);CS0108;CS0109;CS0114;CS1591;CS0219;CS0628;CS0660;CA2257 - - True - Auto + + $(NoWarn);CS8305 - true - true - true + true + true - diff --git a/src/Tests/BuildDeterminismTest/BuildDeterminismComponent/BuildDeterminismComponent.csproj b/src/Tests/BuildDeterminismTest/BuildDeterminismComponent/BuildDeterminismComponent.csproj index 5e77f189d1..0f5b6e023d 100644 --- a/src/Tests/BuildDeterminismTest/BuildDeterminismComponent/BuildDeterminismComponent.csproj +++ b/src/Tests/BuildDeterminismTest/BuildDeterminismComponent/BuildDeterminismComponent.csproj @@ -5,7 +5,15 @@ x64;x86 BuildDeterminismComponent 1701;1702;0436;1658 - true + + + $(NoWarn);CA1416 false true diff --git a/src/Tests/DiagnosticTests/DiagnosticTests.csproj b/src/Tests/DiagnosticTests/DiagnosticTests.csproj index d171546910..5d3dda4995 100644 --- a/src/Tests/DiagnosticTests/DiagnosticTests.csproj +++ b/src/Tests/DiagnosticTests/DiagnosticTests.csproj @@ -3,7 +3,6 @@ $(TestsBuildTFMs) false - true diff --git a/src/Tests/DiagnosticTests/Helpers.cs b/src/Tests/DiagnosticTests/Helpers.cs index 870daec0c3..80b353cddd 100644 --- a/src/Tests/DiagnosticTests/Helpers.cs +++ b/src/Tests/DiagnosticTests/Helpers.cs @@ -28,7 +28,7 @@ private static Compilation CreateCompilation(string source) /// /// /// - private static GeneratorDriver CreateDriver(Compilation compilation, AnalyzerConfigOptionsProvider? options, params ISourceGenerator[] generators) + private static GeneratorDriver CreateDriver(Compilation compilation, AnalyzerConfigOptionsProvider options, params ISourceGenerator[] generators) => CSharpGeneratorDriver.Create( generators: ImmutableArray.Create(generators), additionalTexts: ImmutableArray.Empty, @@ -42,7 +42,7 @@ private static GeneratorDriver CreateDriver(Compilation compilation, AnalyzerCon /// /// /// - private static Compilation RunGenerators(Compilation compilation, out ImmutableArray diagnostics, out GeneratorDriverRunResult result, AnalyzerConfigOptionsProvider? options, params ISourceGenerator[] generators) + private static Compilation RunGenerators(Compilation compilation, out ImmutableArray diagnostics, out GeneratorDriverRunResult result, AnalyzerConfigOptionsProvider options, params ISourceGenerator[] generators) { var driver = CreateDriver(compilation, options, generators).RunGeneratorsAndUpdateCompilation(compilation, out var updatedCompilation, out diagnostics); result = driver.GetRunResult(); diff --git a/src/Tests/FunctionalTests/Directory.Build.props b/src/Tests/FunctionalTests/Directory.Build.props index bf8b4dc243..462d5aefdc 100644 --- a/src/Tests/FunctionalTests/Directory.Build.props +++ b/src/Tests/FunctionalTests/Directory.Build.props @@ -9,7 +9,6 @@ true false - true true true true diff --git a/src/Tests/OOPExe/OOPExe.csproj b/src/Tests/OOPExe/OOPExe.csproj index aebcfea6e9..e997884211 100644 --- a/src/Tests/OOPExe/OOPExe.csproj +++ b/src/Tests/OOPExe/OOPExe.csproj @@ -6,6 +6,20 @@ x64;x86 true false + + + $(NoWarn);CS8981 + + + $(NoWarn);CA1416 diff --git a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs index 78a2db97de..c732e74253 100644 --- a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs +++ b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs @@ -52,7 +52,7 @@ namespace UnitTest public interface ITestCSharp { - void TestMethod(); + void TestMethod(); } [TestClass] @@ -64,7 +64,7 @@ public enum E { A, B, C } public struct Estruct { - E value; + public E value; } [TestMethod] @@ -777,7 +777,6 @@ async Task InvokeStreamWriteAsync() var winRTBuffer = new Windows.Storage.Streams.Buffer(capacity: 0); await winRTStream.WriteAsync(winRTBuffer); - Assert.IsTrue(true); } [TestMethod] @@ -806,7 +805,7 @@ async Task InvokeStreamWriteAndReadAsync() stream.Seek(0, SeekOrigin.Begin); byte[] read = new byte[256]; - await stream.ReadAsync(read, 0, read.Length); + await stream.ReadExactlyAsync(read, 0, read.Length); CollectionAssert.AreEqual(data, read); CollectionAssert.AreEqual(read, data); } @@ -827,7 +826,11 @@ public void TestStreamWriteAndRead() [TestMethod] public void TestDynamicInterfaceCastingOnInvalidInterface() { + // This test intentionally casts to a '[ComImport]' interface to verify it throws 'InvalidCastException', + // which is exactly the unsupported scenario that 'CSWINRT2009' flags, so suppress it just for this test. +#pragma warning disable CSWINRT2009 Assert.ThrowsExactly(() => (IStringableInterop)(WindowsRuntimeObject)TestObject); +#pragma warning restore CSWINRT2009 } [TestMethod] @@ -896,7 +899,7 @@ public void TestStreamWriteSpan() stream.Seek(0, SeekOrigin.Begin); byte[] read = new byte[256]; - stream.Read(read, 0, read.Length); + stream.ReadExactly(read, 0, read.Length); CollectionAssert.AreEqual(data, read); } @@ -981,7 +984,7 @@ async Task TestAsync() stream.Seek(0, SeekOrigin.Begin); byte[] read = new byte[256]; - await stream.ReadAsync(read, 0, read.Length); + await stream.ReadExactlyAsync(read, 0, read.Length); CollectionAssert.AreEqual(data, read); } @@ -1185,7 +1188,7 @@ async Task TestAsync() stream.Seek(0, SeekOrigin.Begin); byte[] read = new byte[256]; - await stream.ReadAsync(read, 0, read.Length); + await stream.ReadExactlyAsync(read, 0, read.Length); CollectionAssert.AreEqual(data, read); } @@ -2475,7 +2478,7 @@ public void TestValueUnboxing() } [TestMethod] - void TestInterfaceGeneric() + public void TestInterfaceGeneric() { var objs = TestObject.GetInterfaceVector(); Assert.AreEqual(3, objs.Count); @@ -2850,7 +2853,7 @@ static void VerifyException(Action action, string expectedMessage) where T : try { action(); - Assert.IsTrue(false); + Assert.Fail(); } catch (T ex) { @@ -2858,7 +2861,7 @@ static void VerifyException(Action action, string expectedMessage) where T : } catch (Exception) { - Assert.IsTrue(false); + Assert.Fail(); } } } @@ -3931,7 +3934,7 @@ public void WeakReferenceOfNativeObjectRehydratedAfterWrapperIsCollected() unsafe static (WeakReference winrt, WeakReference net, WindowsRuntimeObjectReference objRef) GetWeakReferences() { var obj = new Class(); - Assert.IsTrue(WindowsRuntimeComWrappersMarshal.TryUnwrapObjectReference(obj, out WindowsRuntimeObjectReference? objRef)); + Assert.IsTrue(WindowsRuntimeComWrappersMarshal.TryUnwrapObjectReference(obj, out WindowsRuntimeObjectReference objRef)); return (new WeakReference(obj), new WeakReference(obj), objRef); } @@ -4409,6 +4412,10 @@ public void TestEventRemovalByEventSource() // } //} + // 'TestPnpPropertiesInLoop' is a manual stress helper kept 'private' so MSTest doesn't auto-run it + // (PnP enumeration is environment-dependent). The '[TestMethod]' is retained for easy ad-hoc runs, so + // suppress MSTEST0003 ("test method signature is invalid") for this intentionally-private method. +#pragma warning disable MSTEST0003 [TestMethod] private async Task TestPnpPropertiesInLoop() { @@ -4417,6 +4424,7 @@ private async Task TestPnpPropertiesInLoop() await TestPnpPropertiesAsync(); } } +#pragma warning restore MSTEST0003 private async Task TestPnpPropertiesAsync() { @@ -4600,8 +4608,12 @@ public void TestObjectFunctions() // Manually verify warning for experimental. private void TestExperimentAttribute() { + // This method intentionally uses an '[Experimental]' API to manually verify the warning, so suppress + // 'CS8305' here to keep the intentional usage from breaking the build (warnings are treated as errors). +#pragma warning disable CS8305 CustomExperimentClass custom = new CustomExperimentClass(); custom.f(); +#pragma warning restore CS8305 } void OnDeviceAdded(DeviceWatcher sender, DeviceInformation args) diff --git a/src/Tests/UnitTest/TestComponent_Tests.cs b/src/Tests/UnitTest/TestComponent_Tests.cs index 7b23bcd003..9509c17193 100644 --- a/src/Tests/UnitTest/TestComponent_Tests.cs +++ b/src/Tests/UnitTest/TestComponent_Tests.cs @@ -606,12 +606,16 @@ public unsafe TestIDICInspectable(void* ptr) { } + // These intentionally override private-implementation-detail base members that are marked + // obsolete (CSWINRT3001), to test 'IDynamicInterfaceCastable' behavior, so suppress CS0672. +#pragma warning disable CS0672 // Member overrides obsolete member protected override bool HasUnwrappableNativeObjectReference => true; protected override bool IsOverridableInterface(in Guid iid) { return false; } +#pragma warning restore CS0672 // Member overrides obsolete member } // Workaround for .NET bug (https://github.com/dotnet/runtime/issues/125577) until it is resolved. diff --git a/src/Tests/UnitTest/UnitTest.csproj b/src/Tests/UnitTest/UnitTest.csproj index 6882413d9b..9b2148c258 100644 --- a/src/Tests/UnitTest/UnitTest.csproj +++ b/src/Tests/UnitTest/UnitTest.csproj @@ -5,8 +5,37 @@ x64;x86 UnitTest 1701;1702;0436;1658 + + + $(NoWarn);CSWINRT3001 + + + $(NoWarn);CS8981 + + + $(NoWarn);CA1416 + + + $(NoWarn);IL2050;CA1420 true - true false exe true diff --git a/src/WinRT.Generator.Core/WinRT.Generator.Core.csproj b/src/WinRT.Generator.Core/WinRT.Generator.Core.csproj index 5e0d083a0e..8c766f740a 100644 --- a/src/WinRT.Generator.Core/WinRT.Generator.Core.csproj +++ b/src/WinRT.Generator.Core/WinRT.Generator.Core.csproj @@ -1,11 +1,7 @@  - net10.0 - 14.0 + $(DotNetVersion) enable - true - true - true C#/WinRT Generator core shared infrastructure v$(VersionString) @@ -14,20 +10,8 @@ $(AssemblyVersionNumber) $(VersionNumber) - - true - WindowsRuntime.Generator - - - true - true - latest - latest-all - true - strict - true diff --git a/src/WinRT.Generator.Tasks/RunCsWinRTForwarderImplGenerator.cs b/src/WinRT.Generator.Tasks/RunCsWinRTForwarderImplGenerator.cs index 4338b20463..30851876fd 100644 --- a/src/WinRT.Generator.Tasks/RunCsWinRTForwarderImplGenerator.cs +++ b/src/WinRT.Generator.Tasks/RunCsWinRTForwarderImplGenerator.cs @@ -1,5 +1,5 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -154,7 +154,7 @@ protected override string GenerateFullPathToTool() // This makes it easy to run the task against a local build of 'cswinrtimplgen'. if (effectiveArchitecture?.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase) is true) { - return Path.Combine(CsWinRTToolsDirectory!, ToolName); + return Path.Combine(CsWinRTToolsDirectory, ToolName); } // If the architecture is not specified, determine it based on the current process architecture @@ -168,7 +168,7 @@ protected override string GenerateFullPathToTool() // The tool is inside an architecture-specific subfolder, as it's a native binary string architectureDirectory = $"win-{effectiveArchitecture}"; - return Path.Combine(CsWinRTToolsDirectory!, architectureDirectory, ToolName); + return Path.Combine(CsWinRTToolsDirectory, architectureDirectory, ToolName); } /// diff --git a/src/WinRT.Generator.Tasks/RunCsWinRTInteropGenerator.cs b/src/WinRT.Generator.Tasks/RunCsWinRTInteropGenerator.cs index df3cda15c3..a5ada59a27 100644 --- a/src/WinRT.Generator.Tasks/RunCsWinRTInteropGenerator.cs +++ b/src/WinRT.Generator.Tasks/RunCsWinRTInteropGenerator.cs @@ -1,10 +1,7 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using Microsoft.Build.Framework; @@ -233,7 +230,7 @@ protected override string GenerateFullPathToTool() // This makes it easy to run the task against a local build of 'cswinrtinteropgen'. if (effectiveArchitecture?.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase) is true) { - return Path.Combine(CsWinRTToolsDirectory!, ToolName); + return Path.Combine(CsWinRTToolsDirectory, ToolName); } // If the architecture is not specified, determine it based on the current process architecture @@ -247,7 +244,7 @@ protected override string GenerateFullPathToTool() // The tool is inside an architecture-specific subfolder, as it's a native binary string architectureDirectory = $"win-{effectiveArchitecture}"; - return Path.Combine(CsWinRTToolsDirectory!, architectureDirectory, ToolName); + return Path.Combine(CsWinRTToolsDirectory, architectureDirectory, ToolName); } /// diff --git a/src/WinRT.Generator.Tasks/RunCsWinRTMergedProjectionGenerator.cs b/src/WinRT.Generator.Tasks/RunCsWinRTMergedProjectionGenerator.cs index ccc1b15585..81a69b94eb 100644 --- a/src/WinRT.Generator.Tasks/RunCsWinRTMergedProjectionGenerator.cs +++ b/src/WinRT.Generator.Tasks/RunCsWinRTMergedProjectionGenerator.cs @@ -1,5 +1,5 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -179,7 +179,7 @@ protected override string GenerateFullPathToTool() // This makes it easy to run the task against a local build of 'cswinrtprojectiongen'. if (effectiveArchitecture?.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase) is true) { - return Path.Combine(CsWinRTToolsDirectory!, ToolName); + return Path.Combine(CsWinRTToolsDirectory, ToolName); } // If the architecture is not specified, determine it based on the current process architecture @@ -193,7 +193,7 @@ protected override string GenerateFullPathToTool() // The tool is inside an architecture-specific subfolder, as it's a native binary string architectureDirectory = $"win-{effectiveArchitecture}"; - return Path.Combine(CsWinRTToolsDirectory!, architectureDirectory, ToolName); + return Path.Combine(CsWinRTToolsDirectory, architectureDirectory, ToolName); } /// diff --git a/src/WinRT.Generator.Tasks/RunCsWinRTProjectionRefGenerator.cs b/src/WinRT.Generator.Tasks/RunCsWinRTProjectionRefGenerator.cs index 6a38055fd5..8a9c6cc881 100644 --- a/src/WinRT.Generator.Tasks/RunCsWinRTProjectionRefGenerator.cs +++ b/src/WinRT.Generator.Tasks/RunCsWinRTProjectionRefGenerator.cs @@ -1,5 +1,5 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -186,7 +186,7 @@ protected override string GenerateFullPathToTool() // This makes it easy to run the task against a local build of 'cswinrtprojectionrefgen'. if (effectiveArchitecture?.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase) is true) { - return Path.Combine(CsWinRTToolsDirectory!, ToolName); + return Path.Combine(CsWinRTToolsDirectory, ToolName); } // If the architecture is not specified, determine it based on the current process architecture @@ -200,7 +200,7 @@ protected override string GenerateFullPathToTool() // The tool is inside an architecture-specific subfolder, as it's a native binary string architectureDirectory = $"win-{effectiveArchitecture}"; - return Path.Combine(CsWinRTToolsDirectory!, architectureDirectory, ToolName); + return Path.Combine(CsWinRTToolsDirectory, architectureDirectory, ToolName); } /// @@ -296,4 +296,4 @@ private static void AppendResponseFileOptionalCommand(StringBuilder args, string AppendResponseFileCommand(args, commandName, commandValue); } } -} +} \ No newline at end of file diff --git a/src/WinRT.Generator.Tasks/RunCsWinRTWinMDGenerator.cs b/src/WinRT.Generator.Tasks/RunCsWinRTWinMDGenerator.cs index 64817c827c..9bd31a85c8 100644 --- a/src/WinRT.Generator.Tasks/RunCsWinRTWinMDGenerator.cs +++ b/src/WinRT.Generator.Tasks/RunCsWinRTWinMDGenerator.cs @@ -1,9 +1,7 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using Microsoft.Build.Framework; @@ -128,7 +126,7 @@ protected override string GenerateFullPathToTool() // Special case for when 'AnyCPU' is specified (mostly for testing scenarios). if (effectiveArchitecture?.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase) is true) { - return Path.Combine(CsWinRTToolsDirectory!, ToolName); + return Path.Combine(CsWinRTToolsDirectory, ToolName); } // If the architecture is not specified, determine it based on the current process architecture @@ -141,7 +139,7 @@ protected override string GenerateFullPathToTool() string architectureDirectory = $"win-{effectiveArchitecture}"; - return Path.Combine(CsWinRTToolsDirectory!, architectureDirectory, ToolName); + return Path.Combine(CsWinRTToolsDirectory, architectureDirectory, ToolName); } /// @@ -181,4 +179,4 @@ private static void AppendResponseFileOptionalCommand(StringBuilder args, string AppendResponseFileCommand(args, commandName, commandValue); } } -} +} \ No newline at end of file diff --git a/src/WinRT.Impl.Generator/WinRT.Impl.Generator.csproj b/src/WinRT.Impl.Generator/WinRT.Impl.Generator.csproj index c34119d260..2c0b25efbd 100644 --- a/src/WinRT.Impl.Generator/WinRT.Impl.Generator.csproj +++ b/src/WinRT.Impl.Generator/WinRT.Impl.Generator.csproj @@ -1,12 +1,9 @@  Exe - net10.0 - preview + $(DotNetVersion) enable - true true - true C#/WinRT Impl Generator v$(VersionString) @@ -15,44 +12,16 @@ $(AssemblyVersionNumber) $(VersionNumber) - - true - WindowsRuntime.ImplGenerator cswinrtimplgen - - true - true - latest - latest-all - true - strict - true - true win-$(BuildToolArch) true - - - $(NoWarn);IDE0028 - - - - - true - Speed - false - true - Guard - false - false diff --git a/src/WinRT.Internal/ProjectionInternalAttribute.cs b/src/WinRT.Internal/ProjectionInternalAttribute.cs index 21980be466..528c8e8090 100644 --- a/src/WinRT.Internal/ProjectionInternalAttribute.cs +++ b/src/WinRT.Internal/ProjectionInternalAttribute.cs @@ -13,6 +13,7 @@ namespace WindowsRuntime.Internal; /// CsWinRT generates an projection for any interface marked with this attribute /// (rather than the default projection). User-friendly wrappers over the internal /// projection are exposed via hand-authored extension methods (see e.g. ComInteropExtensions). +/// /// [AttributeUsage(AttributeTargets.Interface, Inherited = false, AllowMultiple = false)] public sealed class ProjectionInternalAttribute : Attribute; diff --git a/src/WinRT.Internal/WinRT.Internal.csproj b/src/WinRT.Internal/WinRT.Internal.csproj index cf114c6f0e..de8f3fdd30 100644 --- a/src/WinRT.Internal/WinRT.Internal.csproj +++ b/src/WinRT.Internal/WinRT.Internal.csproj @@ -8,7 +8,7 @@ some of the C# source files in this project reference Windows Runtime types (e.g. 'Windows.UI.ApplicationSettings.AccountsSettingsPane') as well. --> - net10.0-windows10.0.26100.1 + $(DotNetVersion)-windows10.0.26100.1 10.0.17763.0 false - - $(NoWarn);CS1591;1701;CS1702;NETSDK1229 + + $(NoWarn);CS1591;1701;CS1702 C#/WinRT Interop Generator v$(VersionString) @@ -15,72 +12,16 @@ $(AssemblyVersionNumber) $(VersionNumber) - - true - WindowsRuntime.InteropGenerator cswinrtinteropgen - - true - true - latest - latest-all - true - strict - true - true win-$(BuildToolArch) true - - - $(NoWarn);IDE0028;IDE0370 - - - - - true - Speed - false - true - - - Guard - - - false - - - false diff --git a/src/WinRT.Projection.Generator/WinRT.Projection.Generator.csproj b/src/WinRT.Projection.Generator/WinRT.Projection.Generator.csproj index 0068c222ce..0f92d71ebe 100644 --- a/src/WinRT.Projection.Generator/WinRT.Projection.Generator.csproj +++ b/src/WinRT.Projection.Generator/WinRT.Projection.Generator.csproj @@ -1,12 +1,9 @@ Exe - net10.0 - 14.0 + $(DotNetVersion) enable - true true - true C#/WinRT Projection Generator v$(VersionString) @@ -15,42 +12,19 @@ $(AssemblyVersionNumber) $(VersionNumber) - - true - WindowsRuntime.ProjectionGenerator cswinrtprojectiongen - - true - true - latest - latest-all - true - strict - true - true win-$(BuildToolArch) true - - $(NoWarn);IL2091;IL2050;IL2072;IL2075;IL2026;IDE0028 - - - - - true - Speed - false - true - Guard - false - false + + $(NoWarn);IL2091;IL2050;IL2072;IL2075;IL2026 diff --git a/src/WinRT.Projection.Ref.Generator/WinRT.Projection.Ref.Generator.csproj b/src/WinRT.Projection.Ref.Generator/WinRT.Projection.Ref.Generator.csproj index 6f68a999b9..928d2b13a5 100644 --- a/src/WinRT.Projection.Ref.Generator/WinRT.Projection.Ref.Generator.csproj +++ b/src/WinRT.Projection.Ref.Generator/WinRT.Projection.Ref.Generator.csproj @@ -1,12 +1,9 @@ Exe - net10.0 - 14.0 + $(DotNetVersion) enable - true true - true C#/WinRT Reference Projection Generator v$(VersionString) @@ -15,41 +12,18 @@ $(AssemblyVersionNumber) $(VersionNumber) - - true - WindowsRuntime.ReferenceProjectionGenerator cswinrtprojectionrefgen - - true - true - latest - latest-all - true - strict - true - true win-$(BuildToolArch) true - - - true - Speed - false - true - Guard - false - false - - diff --git a/src/WinRT.Projection.Writer/WinRT.Projection.Writer.csproj b/src/WinRT.Projection.Writer/WinRT.Projection.Writer.csproj index 3c100fcc61..8a3c40f890 100644 --- a/src/WinRT.Projection.Writer/WinRT.Projection.Writer.csproj +++ b/src/WinRT.Projection.Writer/WinRT.Projection.Writer.csproj @@ -1,15 +1,8 @@ - net10.0 - 14.0 + $(DotNetVersion) enable - true - true - true - - true - WindowsRuntime.ProjectionWriter @@ -19,15 +12,6 @@ --> $(VersionString) - - true - true - latest - latest-all - true - strict - true - C#/WinRT Runtime v$(VersionString) @@ -14,12 +10,6 @@ $(AssemblyVersionNumber) $(VersionNumber) - - true - WindowsRuntime @@ -29,51 +19,6 @@ --> WinRT.Runtime - - true - true - - - latest - - - latest-all - - - true - - - $(NoWarn);CS8500 - - - strict - - - true - $(NoWarn);CSWINRT3001 diff --git a/src/WinRT.Sdk.Projection/WinRT.Sdk.Projection.csproj b/src/WinRT.Sdk.Projection/WinRT.Sdk.Projection.csproj index 6332d84096..05d08d658d 100644 --- a/src/WinRT.Sdk.Projection/WinRT.Sdk.Projection.csproj +++ b/src/WinRT.Sdk.Projection/WinRT.Sdk.Projection.csproj @@ -1,9 +1,7 @@  - net10.0 - true - true + $(DotNetVersion) C#/WinRT WinMD Generator v$(VersionString) @@ -15,44 +12,16 @@ $(AssemblyVersionNumber) $(VersionNumber) - - true - WindowsRuntime.WinMDGenerator cswinrtwinmdgen - - true - true - latest - latest-all - true - strict - true - true win-$(BuildToolArch) true - - - $(NoWarn);IDE0028 - - - - - true - Speed - false - true - Guard - false - false