From 86099bfd5303c06ac671499c379b1007cbc2a050 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 14 Jun 2026 11:35:42 -0700 Subject: [PATCH 1/8] Use a dedicated attribute to mark implementation-only members (#2434) * Add WindowsRuntimeImplementationOnlyMemberAttribute Introduce an internal sealed attribute to mark implementation-only members for WinRT runtime. The attribute targets all members, is non-inherited, and is conditional on WINDOWS_RUNTIME_REFERENCE_ASSEMBLY so it is emitted only in reference assemblies; this makes it explicit which members are implementation-only and allows them to be stripped from the runtime DLL. Added at src/WinRT.Runtime2/Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs. * Use [WindowsRuntimeImplementationOnlyMember] for implementation-only members Replace the combination of [EditorBrowsable(Never)] and [Obsolete(...)] with the single [WindowsRuntimeImplementationOnlyMember] attribute on implementation-only members across WinRT.Runtime. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Remove WindowsRuntimeConstants.cs Delete WindowsRuntimeConstants.cs which contained constants for WinRT private implementation detail messaging, the PrivateImplementationDetailObsoleteDiagnosticId (CSWINRT3001), and the CsWinRT diagnostics URL format. These constants have been removed from the project. * Remove CSWINRT3001 NoWarn suppression Delete the NoWarn entry and its comment for CSWINRT3001 from src/WinRT.Runtime2/WinRT.Runtime.csproj so warnings about '[Obsolete]' private implementation details are no longer suppressed. This change surfaces those warnings for visibility during builds. * Delete CSWINRT3001 diagnostic documentation This diagnostic is no longer applicable now that the private implementation detail [Obsolete] attributes have been removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use [WindowsRuntimeImplementationOnlyMember] in IActivationFactoryImpl This file was missed in the bulk conversion to the new attribute; it still referenced the now-deleted WindowsRuntimeConstants type, which would break the build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove CSWINRT3001 warning suppressions Remove pragma suppressions and documentation references for the CSWINRT3001 diagnostic. Deleted several "#pragma warning disable CSWINRT3001" (and matching restores) from source files and code-generation templates, and removed CSWINRT3001 from the suppressed warnings list and obsolete-marker table in docs. Affected files include .github/copilot-instructions.md, docs/interop.md, various tests and shim sources, and cswinrt code/template headers. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 3 +- docs/diagnostics/cswinrt30001.md | 34 ------------ docs/interop.md | 2 - src/Authoring/WinRT.Host.Shim/Module.cs | 2 - src/Tests/FunctionalTests/CCW/Program.cs | 2 - .../FunctionalTests/Collections/Program.cs | 2 - src/Tests/UnitTest/TestComponent_Tests.cs | 2 - src/WinRT.Runtime2/ABI/System/Boolean.cs | 8 +-- src/WinRT.Runtime2/ABI/System/Byte.cs | 8 +-- src/WinRT.Runtime2/ABI/System/Char.cs | 8 +-- .../ABI/System/Collections/IEnumerable.cs | 21 ++------ .../ABI/System/Collections/IEnumerator.cs | 23 ++------ .../ABI/System/Collections/IList.cs | 23 ++------ .../ABI/System/Collections/IReadOnlyList.cs | 9 +--- .../Specialized/INotifyCollectionChanged.cs | 18 ++----- .../NotifyCollectionChangedAction.cs | 13 ++--- .../NotifyCollectionChangedEventArgs.cs | 13 ++--- .../NotifyCollectionChangedEventHandler.cs | 13 ++--- ...ollectionChangedEventHandlerEventSource.cs | 9 +--- .../DataErrorsChangedEventArgs.cs | 8 +-- .../ComponentModel/INotifyDataErrorInfo.cs | 15 ++---- .../ComponentModel/INotifyPropertyChanged.cs | 15 ++---- .../PropertyChangedEventArgs.cs | 13 ++--- .../PropertyChangedEventHandler.cs | 10 +--- .../PropertyChangedEventHandlerEventSource.cs | 8 +-- .../ABI/System/DateTimeOffset.cs | 13 ++--- src/WinRT.Runtime2/ABI/System/Double.cs | 8 +-- src/WinRT.Runtime2/ABI/System/EventHandler.cs | 8 +-- src/WinRT.Runtime2/ABI/System/Exception.cs | 13 ++--- src/WinRT.Runtime2/ABI/System/Guid.cs | 8 +-- src/WinRT.Runtime2/ABI/System/IDisposable.cs | 18 ++----- .../ABI/System/IServiceProvider.cs | 18 ++----- src/WinRT.Runtime2/ABI/System/Int16.cs | 8 +-- src/WinRT.Runtime2/ABI/System/Int32.cs | 8 +-- src/WinRT.Runtime2/ABI/System/Int64.cs | 8 +-- .../ABI/System/Numerics/Matrix3x2.cs | 8 +-- .../ABI/System/Numerics/Matrix4x4.cs | 8 +-- .../ABI/System/Numerics/Plane.cs | 8 +-- .../ABI/System/Numerics/Quaternion.cs | 8 +-- .../ABI/System/Numerics/Vector2.cs | 8 +-- .../ABI/System/Numerics/Vector3.cs | 8 +-- .../ABI/System/Numerics/Vector4.cs | 8 +-- src/WinRT.Runtime2/ABI/System/Single.cs | 8 +-- src/WinRT.Runtime2/ABI/System/String.cs | 8 +-- src/WinRT.Runtime2/ABI/System/TimeSpan.cs | 13 ++--- src/WinRT.Runtime2/ABI/System/Type.cs | 13 ++--- src/WinRT.Runtime2/ABI/System/UInt16.cs | 8 +-- src/WinRT.Runtime2/ABI/System/UInt32.cs | 8 +-- src/WinRT.Runtime2/ABI/System/UInt64.cs | 8 +-- src/WinRT.Runtime2/ABI/System/Uri.cs | 8 +-- .../ABI/System/Windows.Input/ICommand.cs | 18 ++----- .../AsyncActionCompletedHandler.cs | 8 +-- .../ABI/Windows.Foundation/AsyncStatus.cs | 8 +-- .../Collections/CollectionChange.cs | 8 +-- .../Collections/IVectorChangedEventArgs.cs | 18 ++----- ...MapChangedEventHandlerEventSource{K, V}.cs | 9 +--- ...VectorChangedEventHandlerEventSource{T}.cs | 9 +--- .../ABI/Windows.Foundation/IAsyncAction.cs | 18 ++----- .../ABI/Windows.Foundation/IAsyncInfo.cs | 18 ++----- .../IMemoryBufferReference.cs | 18 ++----- .../ABI/Windows.Foundation/IStringable.cs | 28 +++------- .../ABI/Windows.Foundation/Point.cs | 8 +-- .../ABI/Windows.Foundation/PropertyType.cs | 8 +-- .../ABI/Windows.Foundation/Rect.cs | 8 +-- .../ABI/Windows.Foundation/Size.cs | 8 +-- .../ABI/Windows.Storage.Streams/IBuffer.cs | 18 ++----- .../Windows.Storage.Streams/IInputStream.cs | 18 ++----- .../Windows.Storage.Streams/IOutputStream.cs | 18 ++----- .../IRandomAccessStream.cs | 18 ++----- .../InputStreamOptions.cs | 8 +-- .../Bindables/BindableIReadOnlyListAdapter.cs | 8 +-- .../EventRegistrationToken.cs | 8 +-- ...WindowsRuntimeDefaultInterfaceAttribute.cs | 8 +-- ...owsRuntimeExclusiveToInterfaceAttribute.cs | 8 +-- ...untimeImplementationOnlyMemberAttribute.cs | 20 +++++++ .../WindowsRuntimeMappedMetadataAttribute.cs | 8 +-- .../WindowsRuntimeMetadataAttribute.cs | 8 +-- ...WindowsRuntimeMetadataTypeNameAttribute.cs | 8 +-- .../WindowsRuntimeReferenceTypeAttribute.cs | 8 +-- .../WindowsRuntimeActivationArgsReference.cs | 6 +-- ...WindowsRuntimeActivationFactoryCallback.cs | 20 ++----- .../WindowsRuntimeActivationTypes.cs | 20 ++----- .../IAsyncActionWithProgressMethods.cs | 9 +--- ...ctionWithProgressMethodsImpl{TProgress}.cs | 9 +--- .../IAsyncOperationMethodsImpl{TResult}.cs | 9 +--- ...ProgressMethodsImpl{TResult, TProgress}.cs | 9 +--- ...amicInterfaceCastableForwarderAttribute.cs | 8 +-- ...indowsRuntimeActivationFactoryAttribute.cs | 8 +-- ...wsRuntimeComWrappersMarshallerAttribute.cs | 8 +-- ...indowsRuntimeComponentAssemblyAttribute.cs | 8 +-- ...meComponentAssemblyExportsTypeAttribute.cs | 8 +-- .../WindowsRuntimeMappedTypeAttribute.cs | 8 +-- ...indowsRuntimeReferenceAssemblyAttribute.cs | 8 +-- .../Bindables/BindableIReadOnlyListAdapter.cs | 8 +-- ...IWindowsRuntimeArrayComWrappersCallback.cs | 8 +-- ...WindowsRuntimeObjectComWrappersCallback.cs | 9 +--- ...untimeUnsealedObjectComWrappersCallback.cs | 8 +-- .../IDictionaryAdapterExtensions.cs | 8 +-- .../IDictionaryAdapter{TKey, TValue}.cs | 9 +--- .../Collections/IDictionaryMethods.cs | 10 +--- .../IDictionaryMethods{TKey, TValue}.cs | 8 +-- .../Collections/IEnumerableAdapter{T}.cs | 8 +-- .../Collections/IEnumerableMethods{T}.cs | 9 +--- .../IEnumeratorAdapterExtensions.cs | 38 +++---------- .../Collections/IEnumeratorAdapter{T}.cs | 8 +-- .../Collections/IIterableMethodsImpl{T}.cs | 9 +--- .../Collections/IIteratorMethods.cs | 9 +--- .../Collections/IIteratorMethodsImpl{T}.cs | 10 +--- .../Collections/IListAdapterExtensions.cs | 38 +++---------- .../Collections/IListAdapter{T}.cs | 8 +-- .../Collections/IListMethods.cs | 8 +-- .../Collections/IListMethods{T}.cs | 8 +-- .../IMapChangedEventArgsMethods.cs | 9 +--- .../IMapChangedEventArgsMethodsImpl{K}.cs | 10 +--- .../Collections/IMapMethods.cs | 9 +--- .../Collections/IMapMethodsImpl{K, V}.cs | 10 +--- .../Collections/IMapViewMethods.cs | 10 +--- .../Collections/IMapViewMethodsImpl{K, V}.cs | 10 +--- ...ableMapEventSourceFactory{TKey, TValue}.cs | 10 +--- .../IObservableVectorEventSourceFactory{T}.cs | 10 +--- .../IReadOnlyDictionaryAdapterExtensions.cs | 8 +-- ...ReadOnlyDictionaryAdapter{TKey, TValue}.cs | 9 +--- .../Collections/IReadOnlyDictionaryMethods.cs | 10 +--- ...ReadOnlyDictionaryMethods{TKey, TValue}.cs | 8 +-- ...nlyDictionarySplitAdapter{TKey, TValue}.cs | 8 +-- .../IReadOnlyListAdapterExtensions.cs | 38 +++---------- .../Collections/IReadOnlyListAdapter{T}.cs | 8 +-- .../Collections/IReadOnlyListMethods.cs | 8 +-- .../Collections/IReadOnlyListMethods{T}.cs | 8 +-- .../Collections/IVectorMethods.cs | 9 +--- .../Collections/IVectorMethodsImpl{T}.cs | 10 +--- .../Collections/IVectorViewMethods.cs | 9 +--- .../Collections/IVectorViewMethodsImpl{T}.cs | 10 +--- .../DispatcherQueueSynchronizationContext.cs | 8 +-- .../Events/EventHandlerEventSource.cs | 8 +-- .../EventHandlerEventSource{TEventArgs}.cs | 8 +-- ...tHandlerEventSource{TSender,TEventArgs}.cs | 8 +-- .../Events/EventRegistrationTokenTable{T}.cs | 8 +-- .../Events/EventSourceState{T}.cs | 8 +-- .../InteropServices/Events/EventSource{T}.cs | 8 +-- .../Exceptions/RestrictedErrorInfo.cs | 6 +-- .../IWindowsRuntimeInterface.cs | 8 +-- .../IWindowsRuntimeInterface{T}.cs | 10 +--- ...PairTypeElementMarshaller{TKey, TValue}.cs | 7 +-- ...agedValueTypeElementMarshaller{T, TAbi}.cs | 8 +-- ...RuntimeNullableTypeElementMarshaller{T}.cs | 6 +-- ...untimeReferenceTypeElementMarshaller{T}.cs | 8 +-- ...agedValueTypeElementMarshaller{T, TAbi}.cs | 8 +-- .../Marshalling/HStringHeader.cs | 10 +--- .../Marshalling/HStringMarshaller.cs | 8 +-- .../Marshalling/HStringReference.cs | 10 +--- .../SzArrays/ExceptionArrayMarshaller.cs | 8 +-- .../SzArrays/HStringArrayMarshaller.cs | 8 +-- ...ypeArrayElementMarshaller{TKey, TValue}.cs | 7 +-- ...alueTypeArrayElementMarshaller{T, TAbi}.cs | 8 +-- ...meNullableTypeArrayElementMarshaller{T}.cs | 6 +-- ...eReferenceTypeArrayElementMarshaller{T}.cs | 8 +-- ...alueTypeArrayElementMarshaller{T, TAbi}.cs | 8 +-- .../SzArrays/TypeArrayMarshaller.cs | 8 +-- ...untimeBlittableValueTypeArrayMarshaller.cs | 8 +-- ...imeBlittableValueTypeArrayMarshaller{T}.cs | 8 +-- ...uePairTypeArrayMarshaller{TKey, TValue}.cs | 8 +-- ...anagedValueTypeArrayMarshaller{T, TAbi}.cs | 8 +-- ...wsRuntimeNullableTypeArrayMarshaller{T}.cs | 6 +-- .../WindowsRuntimeObjectArrayMarshaller.cs | 8 +-- ...sRuntimeReferenceTypeArrayMarshaller{T}.cs | 8 +-- .../WindowsRuntimeUnknownArrayMarshaller.cs | 8 +-- ...anagedValueTypeArrayMarshaller{T, TAbi}.cs | 8 +-- .../Marshalling/TypeReference.cs | 8 +-- .../WindowsRuntimeArrayMarshaller.cs | 8 +-- .../WindowsRuntimeDelegateMarshaller.cs | 8 +-- .../WindowsRuntimeInterfaceMarshaller{T}.cs | 8 +-- ...indowsRuntimeKeyValuePairTypeMarshaller.cs | 8 +-- .../WindowsRuntimeObjectMarshaller.cs | 8 +-- .../WindowsRuntimeUnknownMarshaller.cs | 8 +-- .../WindowsRuntimeUnsealedObjectMarshaller.cs | 10 +--- .../WindowsRuntimeValueTypeMarshaller.cs | 8 +-- .../CreateObjectReferenceMarshalingType.cs | 10 +--- .../WindowsRuntimeObjectReference.cs | 8 +-- .../WindowsRuntimeObjectReferenceValue.cs | 8 +-- .../ProjectionDllExports/TokenizerHelper.cs | 8 +-- .../ProjectionImpls/IActivationFactoryImpl.cs | 6 +-- .../ProjectionImpls/IAgileObjectImpl.cs | 9 +--- .../ProjectionImpls/IInspectableImpl.cs | 8 +-- .../ProjectionImpls/IMarshalImpl.cs | 8 +-- .../ProjectionImpls/IPropertyValueImpl.cs | 10 +--- .../IReferenceImpl.Int32Enum.cs | 8 +-- .../ProjectionImpls/IStringableImpl.cs | 8 +-- .../ProjectionImpls/IUnknownImpl.cs | 9 +--- .../IWeakReferenceSourceImpl.cs | 8 +-- .../IStorageFolderHandleAccessMethods.cs | 6 +-- .../IStorageItemHandleAccessMethods.cs | 6 +-- .../Streams/WindowsRuntimeIOHelpers.cs | 6 +-- ...rfaceCastableImplementationTypeMapGroup.cs | 10 +--- .../WindowsRuntimeComWrappersTypeMapGroup.cs | 10 +--- .../WindowsRuntimeMetadataTypeMapGroup.cs | 8 +-- .../WellKnownInterfaceIIDs.g.cs | 5 +- .../InteropServices/WellKnownInterfaceIIDs.tt | 5 +- .../WindowsRuntimeComWrappersMarshal.cs | 8 +-- .../AsyncInfo/WindowsRuntimeAsyncAction.cs | 13 ++--- ...ntimeAsyncActionWithProgress{TProgress}.cs | 18 ++----- ...erationWithProgress{TResult, TProgress}.cs | 18 ++----- .../WindowsRuntimeAsyncOperation{TResult}.cs | 18 ++----- .../Bindables/WindowsRuntimeEnumerable.cs | 13 ++--- .../Bindables/WindowsRuntimeEnumerator.cs | 13 ++--- .../Bindables/WindowsRuntimeList.cs | 13 ++--- .../Bindables/WindowsRuntimeReadOnlyList.cs | 13 ++--- .../DictionaryKeyCollection{TKey, TValue}.cs | 13 ++--- ...DictionaryValueCollection{TKey, TValue}.cs | 13 ++--- ...lyDictionaryKeyCollection{TKey, TValue}.cs | 13 ++--- ...DictionaryValueCollection{TKey, TValue}.cs | 13 ++--- .../WindowsRuntimeDictionary{TKey, TValue}.cs | 18 ++----- .../WindowsRuntimeEnumerable{T}.cs | 18 ++----- .../WindowsRuntimeEnumerator{T}.cs | 18 ++----- .../Collections/WindowsRuntimeList{T}.cs | 18 ++----- ...WindowsRuntimeMapChangedEventArgs{TKey}.cs | 18 ++----- ...ndowsRuntimeObservableMap{TKey, TValue}.cs | 18 ++----- .../WindowsRuntimeObservableVector{T}.cs | 18 ++----- ...RuntimeReadOnlyDictionary{TKey, TValue}.cs | 18 ++----- .../WindowsRuntimeReadOnlyList{T}.cs | 18 ++----- .../WindowsRuntimeMemoryBufferReference.cs | 11 +--- .../Streams/WindowsRuntimeBuffer.cs | 11 +--- .../Streams/WindowsRuntimeInputStream.cs | 11 +--- .../Streams/WindowsRuntimeOutputStream.cs | 11 +--- .../WindowsRuntimeRandomAccessStream.cs | 11 +--- .../Properties/WindowsRuntimeConstants.cs | 32 ----------- src/WinRT.Runtime2/WinRT.Runtime.csproj | 3 -- .../Windows.Foundation/TrustLevel.cs | 9 +--- .../Windows.UI.Xaml.Interop/TypeKind.cs | 8 +-- .../WindowsRuntimeInspectable.cs | 13 ++--- src/WinRT.Runtime2/WindowsRuntimeObject.cs | 53 ++++--------------- src/cswinrt/code_writers.h | 4 -- src/cswinrt/strings/ComInteropExtensions.cs | 2 - src/cswinrt/strings/InspectableVftbl.cs | 2 - src/cswinrt/type_writers.h | 1 - 235 files changed, 555 insertions(+), 1940 deletions(-) delete mode 100644 docs/diagnostics/cswinrt30001.md create mode 100644 src/WinRT.Runtime2/Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs delete mode 100644 src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 46b0969681..603de2ff65 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -555,7 +555,7 @@ The MSBuild integration is orchestrated through several `.props` and `.targets` - **Compiler strict mode**: `strict` in all projects - **XML documentation**: generated for all projects - **`SkipLocalsInit`**: enabled in runtime and build tools for performance -- **Suppressed warnings**: `CS8500` (ref safety in unsafe contexts), `AD0001` (analyzer crashes), `CSWINRT3001` (obsolete internal members) +- **Suppressed warnings**: `CS8500` (ref safety in unsafe contexts), `AD0001` (analyzer crashes) - **Strong-name signing**: all assemblies signed with `src/WinRT.Runtime2/key.snk` ### C++ project (cswinrt) @@ -598,7 +598,6 @@ All four .NET build tools (`cswinrtimplgen`, `cswinrtprojectiongen`, `cswinrtint | Projection Generator | `CSWINRTPROJECTIONGENxxxx` | `0001`–`0008`, `9999` | | Interop Generator | `CSWINRTINTEROPGENxxxx` | Various, `9999` | | WinMD Generator | `CSWINRTWINMDGENxxxx` | `0001`–`0007` | -| Runtime (obsolete markers) | `CSWINRT3xxx` | `CSWINRT3001` | --- diff --git a/docs/diagnostics/cswinrt30001.md b/docs/diagnostics/cswinrt30001.md deleted file mode 100644 index c9877706fe..0000000000 --- a/docs/diagnostics/cswinrt30001.md +++ /dev/null @@ -1,34 +0,0 @@ -# CsWinRT warning CSWINRT3001 - -This type or method is a private implementation detail, and it's only meant to be consumed by generated projections (produced by 'cswinrt.exe') and by generated interop code (produced by 'cswinrtinteropgen.exe'). Private implementation detail types are not considered part of the versioned API surface, and they are ignored when determining the assembly version following semantic versioning. Types might be modified or removed across any version change for 'WinRT.Runtime.dll', and using them in user code is undefined behavior and not supported. - -For instance, the following sample generates CSWINRT3001: - -```csharp -using Microsoft.UI.Xaml; -using WindowsRuntime.InteropServices; - -namespace MyProgram; - -Window window = Window.Current; - -// CSWINRT3001: 'GetObjectReferenceForInterface' is a private implementation detail API -WindowsRuntimeObjectReference objectReference = window.GetObjectReferenceForInterface(typeof(object).TypeHandle); -``` - -Using any private implementation detail API is not supported, and should be considered undefined behavior. - -## Additional resources - -`CSWINRT30001` is emitted when user code tries to reference a type that is marked as a **private implementation detail** within `WinRT.Runtime.dll` or the generated `WinRT.Interop.dll`. These private implementation detail types exist solely to support the marshalling pipeline that CsWinRT and the .NET SDK generate at build time. They are not part of the public, versioned API surface, and consuming them from application code is unsupported. - -While all of these types are public (as they are used across assembglies), they are intentionally hidden from IntelliSense and decorated with `[Obsolete]` (with `CSWINRT3001` as the diagnostic id) to warn when they are referenced. Their names often include `Impl`, `Helpers`, or other internal wording, and their diagnostic message explicitly states that they are private implementation details. During a build, `cswinrt.exe` produces projections and `cswinrtinteropgen.exe` produces `WinRT.Interop.dll`. The generated code inside these tools uses private implementation detail types to perform marshalling work. See `docs/winrt-interop-dll-spec.md` for a description of the generated interop assembly. Because the tooling controls all references to these types, their shape can change whenever needed without breaking consumers. This flexibility is what allows performance and reliability improvements across releases. - -## Recommended action - -- Remove all references to any private implementation detail types. -- Look for supported alternatives in `WinRT.Runtime.dll`, the Windows SDK projections, or your own code. -- If you are authoring source generators or tooling, never take a dependency on private implementation detail types. -- When in doubt, file an issue describing the scenario so the CsWinRT team can help identify a stable API or consider exposing a supported helper. - -Keeping private implementation detail types exclusive to generated code is what allows CsWinRT to deliver fast, safe interop while evolving rapidly. Respecting the diagnostic ensures your applications remain stable across updates (and also avoids accidentally breaking builds when updating the CsWinRT version). diff --git a/docs/interop.md b/docs/interop.md index fd5b24d9c9..6b53c04b14 100644 --- a/docs/interop.md +++ b/docs/interop.md @@ -4,8 +4,6 @@ CsWinRT 3.0 provides a complete COM interop layer for Windows Runtime types on .NET 10+. All interop types are in the `WindowsRuntime.InteropServices` namespace (assembly: `WinRT.Runtime.dll`). Most marshalling is handled automatically by the generated projection and interop assemblies, but advanced scenarios may require direct use of the APIs below. -> **Note:** CsWinRT exposes many types and methods marked `[Obsolete]` with diagnostic `CSWINRT3001`. These are **private implementation details** consumed only by generated code (`cswinrt.exe` and `cswinrtinteropgen.exe`). They are not part of the versioned API surface, may change without notice, and should not be used in application code. This guide covers only the supported public APIs. - ## Summary | Scenario | CsWinRT 3.0 API | diff --git a/src/Authoring/WinRT.Host.Shim/Module.cs b/src/Authoring/WinRT.Host.Shim/Module.cs index cf0e5b38c2..31a64e6221 100644 --- a/src/Authoring/WinRT.Host.Shim/Module.cs +++ b/src/Authoring/WinRT.Host.Shim/Module.cs @@ -11,8 +11,6 @@ [assembly: global::System.Runtime.Versioning.SupportedOSPlatform("Windows")] -#pragma warning disable CSWINRT3001 // Type or member is obsolete - namespace WinRT.Host; public static class Shim diff --git a/src/Tests/FunctionalTests/CCW/Program.cs b/src/Tests/FunctionalTests/CCW/Program.cs index ffb7407323..792c5061ef 100644 --- a/src/Tests/FunctionalTests/CCW/Program.cs +++ b/src/Tests/FunctionalTests/CCW/Program.cs @@ -10,8 +10,6 @@ using WindowsRuntime.InteropServices; using WindowsRuntime.InteropServices.Marshalling; -#pragma warning disable CSWINRT3001 // Type or member is obsolete - var managedProperties = new ManagedProperties(42); var instance = new Class(); diff --git a/src/Tests/FunctionalTests/Collections/Program.cs b/src/Tests/FunctionalTests/Collections/Program.cs index 082f641683..e204c60fdf 100644 --- a/src/Tests/FunctionalTests/Collections/Program.cs +++ b/src/Tests/FunctionalTests/Collections/Program.cs @@ -80,7 +80,6 @@ return 101; } -#pragma warning disable CSWINRT3001 // Type or member is obsolete TestComponent.Nested[] nestedArr = new TestComponent.Nested[]{ new TestComponent.Nested( new TestComponent.Blittable(1, 2, 3, 4, -5, -6, -7, 8.0f, 9.0, typeof(TestComponent.ITests).GUID), @@ -92,7 +91,6 @@ new TestComponent.Blittable(1, 2, 3, 4, -5, -6, -7, 8.0f, 9.0, WellKnownInterfaceIIDs.IID_IInspectable), new TestComponent.NonBlittable(false, 'Z', "Third", (long?)PropertyValue.CreateInt64(789))) }; -#pragma warning restore CSWINRT3001 // Type or member is obsolete TestComponent.Nested[] nestedArr2 = new TestComponent.Nested[nestedArr.Length]; TestComponent.Nested[] outNestedArr; TestComponent.Nested[] retNestedArr = instance2.Array15(nestedArr, nestedArr2, out outNestedArr); diff --git a/src/Tests/UnitTest/TestComponent_Tests.cs b/src/Tests/UnitTest/TestComponent_Tests.cs index 7b23bcd003..2581b6517b 100644 --- a/src/Tests/UnitTest/TestComponent_Tests.cs +++ b/src/Tests/UnitTest/TestComponent_Tests.cs @@ -599,10 +599,8 @@ public void Collections_Dictionary() class TestIDICInspectable : WindowsRuntimeObject { -#pragma warning disable CSWINRT3001 // Type or member is obsolete public unsafe TestIDICInspectable(void* ptr) : base(WindowsRuntimeComWrappersMarshal.CreateObjectReferenceUnsafe(ptr, WellKnownInterfaceIIDs.IID_IInspectable, out _)) -#pragma warning restore CSWINRT3001 // Type or member is obsolete { } diff --git a/src/WinRT.Runtime2/ABI/System/Boolean.cs b/src/WinRT.Runtime2/ABI/System/Boolean.cs index 6c668aa2c1..6d993add02 100644 --- a/src/WinRT.Runtime2/ABI/System/Boolean.cs +++ b/src/WinRT.Runtime2/ABI/System/Boolean.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class BooleanMarshaller { /// @@ -288,4 +284,4 @@ private static HRESULT get_Type(void* thisPtr, PropertyType* value) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Byte.cs b/src/WinRT.Runtime2/ABI/System/Byte.cs index 4cbe373176..d9cbee4b33 100644 --- a/src/WinRT.Runtime2/ABI/System/Byte.cs +++ b/src/WinRT.Runtime2/ABI/System/Byte.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class ByteMarshaller { /// @@ -456,4 +452,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Char.cs b/src/WinRT.Runtime2/ABI/System/Char.cs index 9161ddd52d..f6d3f6a9a5 100644 --- a/src/WinRT.Runtime2/ABI/System/Char.cs +++ b/src/WinRT.Runtime2/ABI/System/Char.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class CharMarshaller { /// @@ -288,4 +284,4 @@ private static HRESULT get_Type(void* thisPtr, PropertyType* value) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/IEnumerable.cs b/src/WinRT.Runtime2/ABI/System/Collections/IEnumerable.cs index 7c1601d3de..4b964b1b1d 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/IEnumerable.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/IEnumerable.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -23,10 +22,7 @@ namespace ABI.System.Collections; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IEnumerableMarshaller { /// @@ -87,10 +83,7 @@ public static unsafe object CreateObject(void* value, out CreatedWrapperFlags wr /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class IEnumerableComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -108,10 +101,7 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumerableMethods { /// @@ -124,10 +114,7 @@ public static IEnumerator GetEnumerator(WindowsRuntimeObjectReference thisRefere /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IEnumerableImpl { /// diff --git a/src/WinRT.Runtime2/ABI/System/Collections/IEnumerator.cs b/src/WinRT.Runtime2/ABI/System/Collections/IEnumerator.cs index b6138a3353..48eeb6e6e0 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/IEnumerator.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/IEnumerator.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -23,10 +22,7 @@ namespace ABI.System.Collections; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IEnumeratorMarshaller { /// @@ -87,10 +83,7 @@ public static unsafe object CreateObject(void* value, out CreatedWrapperFlags wr /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class IEnumeratorComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -108,10 +101,7 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorMethods { /// @@ -131,10 +121,7 @@ public static bool MoveNext(WindowsRuntimeObjectReference thisReference) /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IEnumeratorImpl { /// @@ -275,4 +262,4 @@ void IEnumerator.Reset() { throw new NotSupportedException(); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/IList.cs b/src/WinRT.Runtime2/ABI/System/Collections/IList.cs index 87fea7a820..9668d4203f 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/IList.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/IList.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -27,10 +26,7 @@ namespace ABI.System.Collections; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IListMarshaller { /// @@ -91,10 +87,7 @@ public static unsafe object CreateObject(void* value, out CreatedWrapperFlags wr /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class IListComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -112,10 +105,7 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListMethods { /// @@ -188,10 +178,7 @@ public static void Clear(WindowsRuntimeObjectReference thisReference) /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IListImpl { /// @@ -551,4 +538,4 @@ void ICollection.CopyTo(Array array, int index) BindableIListMethods.CopyTo(thisReference, array, index); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/IReadOnlyList.cs b/src/WinRT.Runtime2/ABI/System/Collections/IReadOnlyList.cs index fce2dcfe05..64f35fbc78 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/IReadOnlyList.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/IReadOnlyList.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.InteropServices; using WindowsRuntime; using WindowsRuntime.InteropServices; @@ -22,10 +20,7 @@ namespace ABI.System.Collections; /// type will be generated at compile time, as its runtime class name will depend on the XAML configuration being used. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class IReadOnlyListComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -38,4 +33,4 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper return new WindowsRuntimeReadOnlyList(valueReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/INotifyCollectionChanged.cs b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/INotifyCollectionChanged.cs index cb4bd9c62d..cc3459d28b 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/INotifyCollectionChanged.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/INotifyCollectionChanged.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Specialized; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; @@ -20,10 +19,7 @@ namespace ABI.System.Collections.Specialized; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class INotifyCollectionChangedMarshaller { /// @@ -44,10 +40,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(INotifyColle /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class INotifyCollectionChangedMethods { /// @@ -99,10 +92,7 @@ internal unsafe struct INotifyCollectionChangedVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class INotifyCollectionChangedImpl { /// @@ -193,4 +183,4 @@ private static HRESULT remove_CollectionChanged(void* thisPtr, EventRegistration return e.HResult; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedAction.cs b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedAction.cs index 21ee72f226..106641303d 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedAction.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedAction.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Specialized; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime; @@ -18,10 +17,7 @@ namespace ABI.System.Collections.Specialized; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class NotifyCollectionChangedActionMarshaller { /// @@ -90,10 +86,7 @@ static NotifyCollectionChangedActionInterfaceEntriesImpl() /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class NotifyCollectionChangedActionComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -117,4 +110,4 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper return WindowsRuntimeValueTypeMarshaller.UnboxToManagedUnsafe(value, in WellKnownXamlInterfaceIIDs.IID_IReferenceOfNotifyCollectionChangedAction); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventArgs.cs b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventArgs.cs index c63bfeebb1..5177806fa9 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventArgs.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventArgs.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Specialized; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime; @@ -17,10 +16,7 @@ namespace ABI.System.Collections.Specialized; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class NotifyCollectionChangedEventArgsMarshaller { /// @@ -151,10 +147,7 @@ static int GetOldStartingIndex(void* value) /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class NotifyCollectionChangedEventArgsComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -236,4 +229,4 @@ file static unsafe class NotifyCollectionChangedEventArgsRuntimeClassFactory return defaultInterface; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandler.cs b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandler.cs index 9dcfdef519..3a0552fcd4 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandler.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandler.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Specialized; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -19,10 +18,7 @@ namespace ABI.System.Collections.Specialized; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class NotifyCollectionChangedEventHandlerMarshaller { /// @@ -146,10 +142,7 @@ static NotifyCollectionChangedEventHandlerInterfaceEntriesImpl() /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class NotifyCollectionChangedEventHandlerComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -307,4 +300,4 @@ private static HRESULT get_Value(void* thisPtr, void** result) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandlerEventSource.cs b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandlerEventSource.cs index f763851ff2..09a42382f4 100644 --- a/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandlerEventSource.cs +++ b/src/WinRT.Runtime2/ABI/System/Collections/Specialized/NotifyCollectionChangedEventHandlerEventSource.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.Collections.Specialized; -using System.ComponentModel; using WindowsRuntime; using WindowsRuntime.InteropServices; @@ -12,10 +10,7 @@ namespace ABI.System.Collections.Specialized; /// /// An implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class NotifyCollectionChangedEventHandlerEventSource : EventSource { /// @@ -53,4 +48,4 @@ protected override NotifyCollectionChangedEventHandler GetEventInvoke() return (obj, e) => TargetDelegate?.Invoke(obj, e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/ComponentModel/DataErrorsChangedEventArgs.cs b/src/WinRT.Runtime2/ABI/System/ComponentModel/DataErrorsChangedEventArgs.cs index 3583b0b1c9..19925235f7 100644 --- a/src/WinRT.Runtime2/ABI/System/ComponentModel/DataErrorsChangedEventArgs.cs +++ b/src/WinRT.Runtime2/ABI/System/ComponentModel/DataErrorsChangedEventArgs.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -35,10 +34,7 @@ namespace ABI.System.ComponentModel; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class DataErrorsChangedEventArgsMarshaller { /// @@ -135,4 +131,4 @@ file static unsafe class DataErrorsChangedEventArgsRuntimeClassFactory return defaultInterface; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyDataErrorInfo.cs b/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyDataErrorInfo.cs index 2eb948f3a2..7a22da264b 100644 --- a/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyDataErrorInfo.cs +++ b/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyDataErrorInfo.cs @@ -44,10 +44,7 @@ namespace ABI.System.ComponentModel; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class INotifyDataErrorInfoMarshaller { /// @@ -68,10 +65,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(global::Syst /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class INotifyDataErrorInfoMethods { /// @@ -174,10 +168,7 @@ internal unsafe struct INotifyDataErrorInfoVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class INotifyDataErrorInfoImpl { /// diff --git a/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyPropertyChanged.cs b/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyPropertyChanged.cs index 1b80d25526..e7984b5ac5 100644 --- a/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyPropertyChanged.cs +++ b/src/WinRT.Runtime2/ABI/System/ComponentModel/INotifyPropertyChanged.cs @@ -19,10 +19,7 @@ namespace ABI.System.ComponentModel; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class INotifyPropertyChangedMarshaller { /// @@ -43,10 +40,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(INotifyPrope /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class INotifyPropertyChangedMethods { /// @@ -98,10 +92,7 @@ internal unsafe struct INotifyPropertyChangedVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class INotifyPropertyChangedImpl { /// diff --git a/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventArgs.cs b/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventArgs.cs index 6574166cc8..f22bd1fb56 100644 --- a/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventArgs.cs +++ b/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventArgs.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -14,10 +13,7 @@ namespace ABI.System.ComponentModel; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class PropertyChangedEventArgsMarshaller { /// @@ -55,10 +51,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(PropertyChan /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class PropertyChangedEventArgsComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -121,4 +114,4 @@ file static unsafe class PropertyChangedEventArgsRuntimeClassFactory return defaultInterface; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandler.cs b/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandler.cs index d457f3e19d..8a01f4e472 100644 --- a/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandler.cs +++ b/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandler.cs @@ -18,10 +18,7 @@ namespace ABI.System.ComponentModel; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class PropertyChangedEventHandlerMarshaller { /// @@ -145,10 +142,7 @@ static PropertyChangedEventHandlerInterfaceEntriesImpl() /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class PropertyChangedEventHandlerComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// diff --git a/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandlerEventSource.cs b/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandlerEventSource.cs index 23ce3bda8e..679680f3d6 100644 --- a/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandlerEventSource.cs +++ b/src/WinRT.Runtime2/ABI/System/ComponentModel/PropertyChangedEventHandlerEventSource.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.ComponentModel; using WindowsRuntime; using WindowsRuntime.InteropServices; @@ -11,10 +10,7 @@ namespace ABI.System.ComponentModel; /// /// An implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class PropertyChangedEventHandlerEventSource : EventSource { /// @@ -52,4 +48,4 @@ protected override PropertyChangedEventHandler GetEventInvoke() return (obj, e) => TargetDelegate?.Invoke(obj, e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/DateTimeOffset.cs b/src/WinRT.Runtime2/ABI/System/DateTimeOffset.cs index e0e9ff87bd..0f0b6b18b7 100644 --- a/src/WinRT.Runtime2/ABI/System/DateTimeOffset.cs +++ b/src/WinRT.Runtime2/ABI/System/DateTimeOffset.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -39,10 +38,7 @@ namespace ABI.System; [WindowsRuntimeMappedType(typeof(global::System.DateTimeOffset))] [WindowsRuntimeReferenceType(typeof(global::System.DateTimeOffset?))] [DateTimeOffsetComWrappersMarshaller] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public struct DateTimeOffset { /// @@ -55,10 +51,7 @@ public struct DateTimeOffset /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class DateTimeOffsetMarshaller { /// @@ -335,4 +328,4 @@ private static HRESULT get_Type(void* thisPtr, PropertyType* value) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Double.cs b/src/WinRT.Runtime2/ABI/System/Double.cs index 3cb89fb29f..aaee82f743 100644 --- a/src/WinRT.Runtime2/ABI/System/Double.cs +++ b/src/WinRT.Runtime2/ABI/System/Double.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class DoubleMarshaller { /// @@ -512,4 +508,4 @@ private static HRESULT GetSingle(void* thisPtr, float* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/EventHandler.cs b/src/WinRT.Runtime2/ABI/System/EventHandler.cs index 84568d3760..d65e9c9cd5 100644 --- a/src/WinRT.Runtime2/ABI/System/EventHandler.cs +++ b/src/WinRT.Runtime2/ABI/System/EventHandler.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -46,10 +45,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class EventHandlerMarshaller { /// @@ -314,4 +310,4 @@ private static HRESULT get_Value(void* thisPtr, void** result) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Exception.cs b/src/WinRT.Runtime2/ABI/System/Exception.cs index f7910c85e3..fb569395f8 100644 --- a/src/WinRT.Runtime2/ABI/System/Exception.cs +++ b/src/WinRT.Runtime2/ABI/System/Exception.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -38,10 +37,7 @@ namespace ABI.System; [WindowsRuntimeMetadataTypeName("Windows.Foundation.HResult")] [WindowsRuntimeMappedType(typeof(global::System.Exception))] [ExceptionComWrappersMarshaller] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public struct Exception { /// @@ -55,10 +51,7 @@ public struct Exception /// Marshaller for . /// /// This marshaller is backed by the infrastructure provided by . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class ExceptionMarshaller { /// @@ -246,4 +239,4 @@ private static HRESULT get_Value(void* thisPtr, Exception* result) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Guid.cs b/src/WinRT.Runtime2/ABI/System/Guid.cs index 726a873554..50eb1e89b2 100644 --- a/src/WinRT.Runtime2/ABI/System/Guid.cs +++ b/src/WinRT.Runtime2/ABI/System/Guid.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class GuidMarshaller { /// @@ -317,4 +313,4 @@ private static HRESULT GetString(void* thisPtr, HSTRING* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/IDisposable.cs b/src/WinRT.Runtime2/ABI/System/IDisposable.cs index fc1b2fdb40..805b02cf73 100644 --- a/src/WinRT.Runtime2/ABI/System/IDisposable.cs +++ b/src/WinRT.Runtime2/ABI/System/IDisposable.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -41,10 +40,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IDisposableMarshaller { /// @@ -63,10 +59,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(global::Syst /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IDisposableMethods { /// @@ -99,10 +92,7 @@ internal unsafe struct IDisposableVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IDisposableImpl { /// @@ -161,4 +151,4 @@ private static HRESULT Close(void* thisPtr) IDisposableMethods.Dispose(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/IServiceProvider.cs b/src/WinRT.Runtime2/ABI/System/IServiceProvider.cs index d963e7d0a2..0f90747c18 100644 --- a/src/WinRT.Runtime2/ABI/System/IServiceProvider.cs +++ b/src/WinRT.Runtime2/ABI/System/IServiceProvider.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -41,10 +40,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IServiceProviderMarshaller { /// @@ -63,10 +59,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(global::Syst /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IServiceProviderMethods { /// @@ -114,10 +107,7 @@ internal unsafe struct IServiceProviderVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IServiceProviderImpl { /// @@ -193,4 +183,4 @@ private static HRESULT GetService(void* thisPtr, Type serviceType, void** result return IServiceProviderMethods.GetService(thisReference, serviceType); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Int16.cs b/src/WinRT.Runtime2/ABI/System/Int16.cs index 737f8f0b24..50a303c21c 100644 --- a/src/WinRT.Runtime2/ABI/System/Int16.cs +++ b/src/WinRT.Runtime2/ABI/System/Int16.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Int16Marshaller { /// @@ -484,4 +480,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Int32.cs b/src/WinRT.Runtime2/ABI/System/Int32.cs index 8027851cbf..bea1b46ad0 100644 --- a/src/WinRT.Runtime2/ABI/System/Int32.cs +++ b/src/WinRT.Runtime2/ABI/System/Int32.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Int32Marshaller { /// @@ -491,4 +487,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Int64.cs b/src/WinRT.Runtime2/ABI/System/Int64.cs index 16e56d3333..621577f8cc 100644 --- a/src/WinRT.Runtime2/ABI/System/Int64.cs +++ b/src/WinRT.Runtime2/ABI/System/Int64.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Int64Marshaller { /// @@ -498,4 +494,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Numerics/Matrix3x2.cs b/src/WinRT.Runtime2/ABI/System/Numerics/Matrix3x2.cs index 749ddbf800..ec958b2a69 100644 --- a/src/WinRT.Runtime2/ABI/System/Numerics/Matrix3x2.cs +++ b/src/WinRT.Runtime2/ABI/System/Numerics/Matrix3x2.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -45,10 +44,7 @@ namespace ABI.System.Numerics; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Matrix3x2Marshaller { /// @@ -207,4 +203,4 @@ private static HRESULT get_Value(void* thisPtr, global::System.Numerics.Matrix3x return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Numerics/Matrix4x4.cs b/src/WinRT.Runtime2/ABI/System/Numerics/Matrix4x4.cs index 9f94ecaf3f..d7a3ff7d5a 100644 --- a/src/WinRT.Runtime2/ABI/System/Numerics/Matrix4x4.cs +++ b/src/WinRT.Runtime2/ABI/System/Numerics/Matrix4x4.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -45,10 +44,7 @@ namespace ABI.System.Numerics; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Matrix4x4Marshaller { /// @@ -207,4 +203,4 @@ private static HRESULT get_Value(void* thisPtr, global::System.Numerics.Matrix4x return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Numerics/Plane.cs b/src/WinRT.Runtime2/ABI/System/Numerics/Plane.cs index fe5ff53236..0246bba713 100644 --- a/src/WinRT.Runtime2/ABI/System/Numerics/Plane.cs +++ b/src/WinRT.Runtime2/ABI/System/Numerics/Plane.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -45,10 +44,7 @@ namespace ABI.System.Numerics; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class PlaneMarshaller { /// @@ -207,4 +203,4 @@ private static HRESULT get_Value(void* thisPtr, global::System.Numerics.Plane* r return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Numerics/Quaternion.cs b/src/WinRT.Runtime2/ABI/System/Numerics/Quaternion.cs index dced508efd..853916a0f6 100644 --- a/src/WinRT.Runtime2/ABI/System/Numerics/Quaternion.cs +++ b/src/WinRT.Runtime2/ABI/System/Numerics/Quaternion.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -45,10 +44,7 @@ namespace ABI.System.Numerics; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class QuaternionMarshaller { /// @@ -207,4 +203,4 @@ private static HRESULT get_Value(void* thisPtr, global::System.Numerics.Quaterni return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Numerics/Vector2.cs b/src/WinRT.Runtime2/ABI/System/Numerics/Vector2.cs index dabd87f769..cd10654163 100644 --- a/src/WinRT.Runtime2/ABI/System/Numerics/Vector2.cs +++ b/src/WinRT.Runtime2/ABI/System/Numerics/Vector2.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -45,10 +44,7 @@ namespace ABI.System.Numerics; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Vector2Marshaller { /// @@ -207,4 +203,4 @@ private static HRESULT get_Value(void* thisPtr, global::System.Numerics.Vector2* return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Numerics/Vector3.cs b/src/WinRT.Runtime2/ABI/System/Numerics/Vector3.cs index e463900f31..f32ae5c989 100644 --- a/src/WinRT.Runtime2/ABI/System/Numerics/Vector3.cs +++ b/src/WinRT.Runtime2/ABI/System/Numerics/Vector3.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -45,10 +44,7 @@ namespace ABI.System.Numerics; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Vector3Marshaller { /// @@ -207,4 +203,4 @@ private static HRESULT get_Value(void* thisPtr, global::System.Numerics.Vector3* return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Numerics/Vector4.cs b/src/WinRT.Runtime2/ABI/System/Numerics/Vector4.cs index 8368e3f2a1..f6fb040d36 100644 --- a/src/WinRT.Runtime2/ABI/System/Numerics/Vector4.cs +++ b/src/WinRT.Runtime2/ABI/System/Numerics/Vector4.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -45,10 +44,7 @@ namespace ABI.System.Numerics; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class Vector4Marshaller { /// @@ -207,4 +203,4 @@ private static HRESULT get_Value(void* thisPtr, global::System.Numerics.Vector4* return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Single.cs b/src/WinRT.Runtime2/ABI/System/Single.cs index a051b2ee1a..5957badf43 100644 --- a/src/WinRT.Runtime2/ABI/System/Single.cs +++ b/src/WinRT.Runtime2/ABI/System/Single.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class SingleMarshaller { /// @@ -505,4 +501,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/String.cs b/src/WinRT.Runtime2/ABI/System/String.cs index 0ae612ae65..8e62c51654 100644 --- a/src/WinRT.Runtime2/ABI/System/String.cs +++ b/src/WinRT.Runtime2/ABI/System/String.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class StringMarshaller { /// @@ -443,4 +439,4 @@ private static HRESULT GetNumeric(void* thisPtr, T* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/TimeSpan.cs b/src/WinRT.Runtime2/ABI/System/TimeSpan.cs index 27fb0b68c9..1763e43dfa 100644 --- a/src/WinRT.Runtime2/ABI/System/TimeSpan.cs +++ b/src/WinRT.Runtime2/ABI/System/TimeSpan.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -39,10 +38,7 @@ namespace ABI.System; [WindowsRuntimeMappedType(typeof(global::System.TimeSpan))] [WindowsRuntimeReferenceType(typeof(global::System.TimeSpan?))] [TimeSpanComWrappersMarshaller] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public struct TimeSpan { /// @@ -55,10 +51,7 @@ public struct TimeSpan /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class TimeSpanMarshaller { /// @@ -326,4 +319,4 @@ private static HRESULT get_Type(void* thisPtr, PropertyType* value) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Type.cs b/src/WinRT.Runtime2/ABI/System/Type.cs index dfca12f52f..eb5e52dab2 100644 --- a/src/WinRT.Runtime2/ABI/System/Type.cs +++ b/src/WinRT.Runtime2/ABI/System/Type.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -45,10 +44,7 @@ namespace ABI.System; [WindowsRuntimeMetadataTypeName("Windows.UI.Xaml.Interop.TypeName")] [WindowsRuntimeMappedType(typeof(global::System.Type))] [TypeComWrappersMarshaller] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe struct Type { /// @@ -67,10 +63,7 @@ public unsafe struct Type /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class TypeMarshaller { /// @@ -1031,4 +1024,4 @@ public override int GetHashCode() { return _fullName.GetHashCode(); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/UInt16.cs b/src/WinRT.Runtime2/ABI/System/UInt16.cs index 236f032b35..10d05a5271 100644 --- a/src/WinRT.Runtime2/ABI/System/UInt16.cs +++ b/src/WinRT.Runtime2/ABI/System/UInt16.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class UInt16Marshaller { /// @@ -470,4 +466,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/UInt32.cs b/src/WinRT.Runtime2/ABI/System/UInt32.cs index 1789d62bf1..da34839df7 100644 --- a/src/WinRT.Runtime2/ABI/System/UInt32.cs +++ b/src/WinRT.Runtime2/ABI/System/UInt32.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class UInt32Marshaller { /// @@ -484,4 +480,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/UInt64.cs b/src/WinRT.Runtime2/ABI/System/UInt64.cs index 66bff493e2..1d92e8f02d 100644 --- a/src/WinRT.Runtime2/ABI/System/UInt64.cs +++ b/src/WinRT.Runtime2/ABI/System/UInt64.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -43,10 +42,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class UInt64Marshaller { /// @@ -498,4 +494,4 @@ private static HRESULT GetDouble(void* thisPtr, double* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Uri.cs b/src/WinRT.Runtime2/ABI/System/Uri.cs index 9917d2fed9..1c0beb64d9 100644 --- a/src/WinRT.Runtime2/ABI/System/Uri.cs +++ b/src/WinRT.Runtime2/ABI/System/Uri.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime; @@ -35,10 +34,7 @@ namespace ABI.System; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class UriMarshaller { /// @@ -130,4 +126,4 @@ file static unsafe class UriRuntimeClassFactory return defaultInterface; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/System/Windows.Input/ICommand.cs b/src/WinRT.Runtime2/ABI/System/Windows.Input/ICommand.cs index faf4ce3941..30e5f1bbed 100644 --- a/src/WinRT.Runtime2/ABI/System/Windows.Input/ICommand.cs +++ b/src/WinRT.Runtime2/ABI/System/Windows.Input/ICommand.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; @@ -20,10 +19,7 @@ namespace ABI.System.Windows.Input; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class ICommandMarshaller { /// @@ -44,10 +40,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(ICommand? va /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class ICommandMethods { /// @@ -128,10 +121,7 @@ internal unsafe struct ICommandVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class ICommandImpl { /// @@ -270,4 +260,4 @@ private static HRESULT Execute(void* thisPtr, void* parameter) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncActionCompletedHandler.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncActionCompletedHandler.cs index 1b28d99b7e..3c4b5cc303 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncActionCompletedHandler.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncActionCompletedHandler.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class AsyncActionCompletedHandlerMarshaller { /// @@ -316,4 +312,4 @@ private static HRESULT get_Value(void* thisPtr, void** result) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncStatus.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncStatus.cs index a48763a1bd..b3904dea2b 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncStatus.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/AsyncStatus.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class AsyncStatusMarshaller { /// @@ -125,4 +121,4 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper return WindowsRuntimeValueTypeMarshaller.UnboxToManagedUnsafe(value, in WellKnownWindowsInterfaceIIDs.IID_IReferenceOfAsyncStatus); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/CollectionChange.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/CollectionChange.cs index 7528ac0295..53482131a4 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/CollectionChange.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/CollectionChange.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation.Collections; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation.Collections; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class CollectionChangeMarshaller { /// @@ -125,4 +121,4 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper return WindowsRuntimeValueTypeMarshaller.UnboxToManagedUnsafe(value, in WellKnownWindowsInterfaceIIDs.IID_IReferenceOfCollectionChange); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/IVectorChangedEventArgs.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/IVectorChangedEventArgs.cs index 2743c2f97f..81c90bbfc9 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/IVectorChangedEventArgs.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/IVectorChangedEventArgs.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation.Collections; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IVectorChangedEventArgsMarshaller { /// @@ -54,10 +50,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(IVectorChang /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IVectorChangedEventArgsMethods { /// @@ -108,10 +101,7 @@ internal unsafe struct IVectorChangedEventArgsVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IVectorChangedEventArgsImpl { /// @@ -205,4 +195,4 @@ uint IVectorChangedEventArgs.Index return IVectorChangedEventArgsMethods.Index(thisReference); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/MapChangedEventHandlerEventSource{K, V}.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/MapChangedEventHandlerEventSource{K, V}.cs index 41c44d3626..ddabb144e1 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/MapChangedEventHandlerEventSource{K, V}.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/MapChangedEventHandlerEventSource{K, V}.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using Windows.Foundation.Collections; using WindowsRuntime; using WindowsRuntime.InteropServices; @@ -14,10 +12,7 @@ namespace ABI.Windows.Foundation.Collections; /// /// The type of keys in the observable map. /// The type of values in the observable map. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe class MapChangedEventHandlerEventSource : EventSource> { /// @@ -49,4 +44,4 @@ protected override MapChangedEventHandler GetEventInvoke() return (obj, e) => TargetDelegate?.Invoke(obj, e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/VectorChangedEventHandlerEventSource{T}.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/VectorChangedEventHandlerEventSource{T}.cs index 0068c00e37..0b0299cda3 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/VectorChangedEventHandlerEventSource{T}.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/Collections/VectorChangedEventHandlerEventSource{T}.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using Windows.Foundation.Collections; using WindowsRuntime; using WindowsRuntime.InteropServices; @@ -13,10 +11,7 @@ namespace ABI.Windows.Foundation.Collections; /// An implementation for . /// /// The type of elements in the observable vector. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe class VectorChangedEventHandlerEventSource : EventSource> { /// @@ -48,4 +43,4 @@ protected override VectorChangedEventHandler GetEventInvoke() return (obj, e) => TargetDelegate?.Invoke(obj, e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncAction.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncAction.cs index f24d87c628..42b270406e 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncAction.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncAction.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IAsyncActionMarshaller { /// @@ -95,10 +91,7 @@ public static object CreateObject(void* value, out CreatedWrapperFlags wrapperFl /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IAsyncActionMethods { /// @@ -172,10 +165,7 @@ internal unsafe struct IAsyncActionVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IAsyncActionImpl { /// @@ -296,4 +286,4 @@ void IAsyncAction.GetResults() IAsyncActionMethods.GetResults(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncInfo.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncInfo.cs index b4d0ab9899..efc4e3e02a 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncInfo.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/IAsyncInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -29,10 +28,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IAsyncInfoMarshaller { /// @@ -51,10 +47,7 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanaged(IAsyncInfo? /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IAsyncInfoMethods { /// @@ -154,10 +147,7 @@ internal unsafe struct IAsyncInfoVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IAsyncInfoImpl { /// @@ -350,4 +340,4 @@ void IAsyncInfo.Close() IAsyncInfoMethods.Close(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/IMemoryBufferReference.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/IMemoryBufferReference.cs index 516a30a0f6..98a39fdf2b 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/IMemoryBufferReference.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/IMemoryBufferReference.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -31,10 +30,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IMemoryBufferReferenceMarshaller { /// @@ -96,10 +92,7 @@ public static object CreateObject(void* value, out CreatedWrapperFlags wrapperFl /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IMemoryBufferReferenceMethods { /// @@ -172,10 +165,7 @@ internal unsafe struct IMemoryBufferReferenceVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IMemoryBufferReferenceImpl { /// @@ -333,4 +323,4 @@ event EventHandler? IMemoryBufferReference.Close IMemoryBufferReferenceMethods.Closed(thisObject, thisReference).Unsubscribe(value); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/IStringable.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/IStringable.cs index 22ac08de74..600fbc53ce 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/IStringable.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/IStringable.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -42,10 +41,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IStringableMarshaller { /// @@ -129,10 +125,7 @@ public WindowsRuntimeStringable(WindowsRuntimeObjectReference nativeObjectRefere } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -148,10 +141,7 @@ public override string ToString() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; @@ -161,10 +151,7 @@ protected override bool IsOverridableInterface(in Guid iid) /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IStringableMethods { /// @@ -208,10 +195,7 @@ internal unsafe struct IStringableVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IStringableImpl { /// @@ -277,4 +261,4 @@ private static HRESULT ToString(void* thisPtr, HSTRING* result) return IStringableMethods.ToString(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/Point.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/Point.cs index f6877757a4..bc656e6492 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/Point.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/Point.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class PointMarshaller { /// @@ -275,4 +271,4 @@ private static HRESULT get_Type(void* thisPtr, PropertyType* value) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/PropertyType.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/PropertyType.cs index 8982afa5aa..10f90c29c6 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/PropertyType.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/PropertyType.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class PropertyTypeMarshaller { /// @@ -125,4 +121,4 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper return WindowsRuntimeValueTypeMarshaller.UnboxToManagedUnsafe(value, in WellKnownWindowsInterfaceIIDs.IID_IReferenceOfPropertyType); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/Rect.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/Rect.cs index 49de7b2656..6b8b039f79 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/Rect.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/Rect.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class RectMarshaller { /// @@ -275,4 +271,4 @@ private static HRESULT get_Type(void* thisPtr, PropertyType* value) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Foundation/Size.cs b/src/WinRT.Runtime2/ABI/Windows.Foundation/Size.cs index 3e502df0aa..a5c950c0e1 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Foundation/Size.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Foundation/Size.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -30,10 +29,7 @@ namespace ABI.Windows.Foundation; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class SizeMarshaller { /// @@ -275,4 +271,4 @@ private static HRESULT get_Type(void* thisPtr, PropertyType* value) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IBuffer.cs b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IBuffer.cs index 00e6a0ef5f..5fd586a111 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IBuffer.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IBuffer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -31,10 +30,7 @@ namespace ABI.Windows.Storage.Streams; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IBufferMarshaller { /// @@ -96,10 +92,7 @@ public static object CreateObject(void* value, out CreatedWrapperFlags wrapperFl /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IBufferMethods { /// @@ -168,10 +161,7 @@ internal unsafe struct IBufferVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IBufferImpl { /// @@ -300,4 +290,4 @@ uint IBuffer.Length IBufferMethods.Length(thisReference, value); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IInputStream.cs b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IInputStream.cs index 7e979c347a..bdf1157623 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IInputStream.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IInputStream.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -31,10 +30,7 @@ namespace ABI.Windows.Storage.Streams; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IInputStreamMarshaller { /// @@ -96,10 +92,7 @@ public static object CreateObject(void* value, out CreatedWrapperFlags wrapperFl /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IInputStreamMethods { /// @@ -159,10 +152,7 @@ internal unsafe struct IInputStreamVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IInputStreamImpl { /// @@ -238,4 +228,4 @@ IAsyncOperationWithProgress IInputStream.ReadAsync(IBuffer buffer return IInputStreamMethods.ReadAsync(thisReference, buffer, count, options); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IOutputStream.cs b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IOutputStream.cs index f87d69866a..f1fb0a2524 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IOutputStream.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IOutputStream.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -31,10 +30,7 @@ namespace ABI.Windows.Storage.Streams; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IOutputStreamMarshaller { /// @@ -96,10 +92,7 @@ public static object CreateObject(void* value, out CreatedWrapperFlags wrapperFl /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IOutputStreamMethods { /// @@ -182,10 +175,7 @@ internal unsafe struct IOutputStreamVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IOutputStreamImpl { /// @@ -297,4 +287,4 @@ IAsyncOperation IOutputStream.FlushAsync() return IOutputStreamMethods.FlushAsync(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IRandomAccessStream.cs b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IRandomAccessStream.cs index ebea98f5b0..920efc39b7 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IRandomAccessStream.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/IRandomAccessStream.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -31,10 +30,7 @@ namespace ABI.Windows.Storage.Streams; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IRandomAccessStreamMarshaller { /// @@ -96,10 +92,7 @@ public static object CreateObject(void* value, out CreatedWrapperFlags wrapperFl /// /// Interop methods for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IRandomAccessStreamMethods { /// @@ -294,10 +287,7 @@ internal unsafe struct IRandomAccessStreamVftbl /// /// The implementation. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IRandomAccessStreamImpl { /// @@ -625,4 +615,4 @@ IRandomAccessStream IRandomAccessStream.CloneStream() return IRandomAccessStreamMethods.CloneStream(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/InputStreamOptions.cs b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/InputStreamOptions.cs index fdb05a299d..2ff9a41be2 100644 --- a/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/InputStreamOptions.cs +++ b/src/WinRT.Runtime2/ABI/Windows.Storage.Streams/InputStreamOptions.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Storage.Streams; @@ -30,10 +29,7 @@ namespace ABI.Windows.Storage.Streams; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class InputStreamOptionsMarshaller { /// @@ -125,4 +121,4 @@ public override object CreateObject(void* value, out CreatedWrapperFlags wrapper return WindowsRuntimeValueTypeMarshaller.UnboxToManagedUnsafe(value, in WellKnownWindowsInterfaceIIDs.IID_IReferenceOfInputStreamOptions); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/Bindables/BindableIReadOnlyListAdapter.cs b/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/Bindables/BindableIReadOnlyListAdapter.cs index 7a0bbee795..b2e99342ef 100644 --- a/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/Bindables/BindableIReadOnlyListAdapter.cs +++ b/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/Bindables/BindableIReadOnlyListAdapter.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime; @@ -87,10 +86,7 @@ static BindableIReadOnlyListAdapterInterfaceEntriesImpl() /// /// A custom implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class BindableIReadOnlyListAdapterComWrappersMarshallerAttribute : WindowsRuntimeComWrappersMarshallerAttribute { /// @@ -212,4 +208,4 @@ private static HRESULT IndexOf(void* thisPtr, void* value, uint* index, bool* re return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(ex); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/EventRegistrationToken.cs b/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/EventRegistrationToken.cs index fbb90b6c1f..0582a161df 100644 --- a/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/EventRegistrationToken.cs +++ b/src/WinRT.Runtime2/ABI/WindowsRuntime.InteropServices/EventRegistrationToken.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -25,10 +24,7 @@ namespace ABI.WindowsRuntime.InteropServices; /// /// Marshaller for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class EventRegistrationTokenMarshaller { /// @@ -187,4 +183,4 @@ private static HRESULT get_Value(void* thisPtr, EventRegistrationToken* result) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs index ba327c4a61..e280fa0702 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime; @@ -12,10 +11,7 @@ namespace WindowsRuntime; /// on the runtime class type itself. This allows the interface type reference to be trimmed away when not needed. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeDefaultInterfaceAttribute : Attribute { /// @@ -38,4 +34,4 @@ public WindowsRuntimeDefaultInterfaceAttribute(Type runtimeClassType, Type inter /// Gets the type of the default interface for the specified Windows Runtime class type. /// public Type InterfaceType { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs index 4f51b1330d..b21c5264f7 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime; @@ -12,10 +11,7 @@ namespace WindowsRuntime; /// placed on the interface type itself. This allows the interface type reference to be trimmed away when not needed. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeExclusiveToInterfaceAttribute : Attribute { /// @@ -38,4 +34,4 @@ public WindowsRuntimeExclusiveToInterfaceAttribute(Type runtimeClassType, Type i /// Gets the type of the exclusive interface for the specified Windows Runtime class type. /// public Type InterfaceType { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs new file mode 100644 index 0000000000..7b9e858c29 --- /dev/null +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; +using System.Diagnostics; + +namespace WindowsRuntime; + +/// +/// Indicates a member that is an implementation-only member, meaning it should only be included in the WinRT.Runtime.dll +/// assembly when producing the implementation .dll (not the reference assemlby) that will be used by downstream tooling too. +/// +/// +/// This attribute is used to make it clearer which members are implementation-only members (rather than just relying on whether +/// they are excluded from the compilation in some way). Additionally, this attribute is actually only emitted when producing +/// reference assemblies (where such members wouldn't be present anyway), so it can be fully stripped in the actual .dll used. +/// +[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)] +[Conditional("WINDOWS_RUNTIME_REFERENCE_ASSEMBLY")] +internal sealed class WindowsRuntimeImplementationOnlyMemberAttribute : Attribute; \ No newline at end of file diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs index abec34fd53..db7d06d96b 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime; @@ -17,10 +16,7 @@ namespace WindowsRuntime; AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeMappedMetadataAttribute : Attribute { /// @@ -36,4 +32,4 @@ public WindowsRuntimeMappedMetadataAttribute(string name) /// Gets the name of the mapped source Windows Runtime metadata file (.winmd) that the current custom-mapped type is from. /// public string Name { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs index ef8d79db32..aff608ee3d 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime; @@ -17,10 +16,7 @@ namespace WindowsRuntime; AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeMetadataAttribute : Attribute { /// @@ -36,4 +32,4 @@ public WindowsRuntimeMetadataAttribute(string name) /// Gets the name of the source Windows Runtime metadata file (.winmd) that the current projected type is from. /// public string Name { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs index 352cae8da7..3e6bceb204 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime; @@ -27,10 +26,7 @@ namespace WindowsRuntime; AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeMetadataTypeNameAttribute : Attribute { /// @@ -46,4 +42,4 @@ public WindowsRuntimeMetadataTypeNameAttribute(string metadataTypeName) /// Gets the metadata type name for the current instance. /// public string MetadataTypeName { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs index 68f1a6e269..e5351a0c4f 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime; @@ -16,10 +15,7 @@ namespace WindowsRuntime; AttributeTargets.Enum, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeReferenceTypeAttribute : Attribute { /// @@ -35,4 +31,4 @@ public WindowsRuntimeReferenceTypeAttribute(Type referenceType) /// Gets the reference type (a constructed type) for the annotated type. /// public Type ReferenceType { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationArgsReference.cs b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationArgsReference.cs index 32f46e3709..30ada9f78c 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationArgsReference.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationArgsReference.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -14,10 +13,7 @@ namespace WindowsRuntime.InteropServices; /// /// This type works around the lack of support for for byref-like types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public readonly ref struct WindowsRuntimeActivationArgsReference { /// diff --git a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactoryCallback.cs b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactoryCallback.cs index cb25f7c927..a7d65e3b97 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactoryCallback.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactoryCallback.cs @@ -1,28 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// Activation factory types to activate Windows Runtime objects with custom logic. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class WindowsRuntimeActivationFactoryCallback { /// /// A type containing logic to activate a composed Windows Runtime object. /// /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public abstract class DerivedComposed { /// @@ -43,10 +34,7 @@ public abstract unsafe void Invoke( /// A type containing logic to activate a sealed Windows Runtime object. /// /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public abstract class DerivedSealed { /// @@ -56,4 +44,4 @@ public abstract class DerivedSealed /// The resulting default interface pointer. public abstract unsafe void Invoke(WindowsRuntimeActivationArgsReference additionalParameters, out void* defaultInterface); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationTypes.cs b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationTypes.cs index fa500e3c97..7aacaae8a7 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationTypes.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationTypes.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// @@ -15,27 +12,18 @@ namespace WindowsRuntime.InteropServices; /// constructor. Activation works differently for composed and sealed types, so these marker types are used to select /// the correct constructor overload to invoke. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class WindowsRuntimeActivationTypes { /// /// The derived type is a composed Windows Runtime type. /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public readonly ref struct DerivedComposed; /// /// The derived type is a sealed Windows Runtime type. /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public readonly ref struct DerivedSealed; -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethods.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethods.cs index b96c494473..ef22c63e7c 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethods.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -10,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IAsyncActionWithProgressMethods { /// @@ -27,4 +22,4 @@ public static void GetResults(WindowsRuntimeObjectReference thisReference) RestrictedErrorInfo.ThrowExceptionForHR(((IAsyncActionWithProgressVftbl*)*(void***)thisPtr)->GetResults(thisPtr)); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethodsImpl{TProgress}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethodsImpl{TProgress}.cs index 95a77664e7..b19197ee40 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethodsImpl{TProgress}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncActionWithProgressMethodsImpl{TProgress}.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using Windows.Foundation; namespace WindowsRuntime.InteropServices; @@ -11,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// An interface for implementations of types. /// /// The type of progress information. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IAsyncActionWithProgressMethodsImpl { /// @@ -55,4 +50,4 @@ public interface IAsyncActionWithProgressMethodsImpl /// The instance to use to invoke the native method. /// static abstract void GetResults(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationMethodsImpl{TResult}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationMethodsImpl{TResult}.cs index 9dc801b08a..fddceac541 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationMethodsImpl{TResult}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationMethodsImpl{TResult}.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using Windows.Foundation; namespace WindowsRuntime.InteropServices; @@ -11,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// An interface for implementations of types. /// /// The result type. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IAsyncOperationMethodsImpl { /// @@ -40,4 +35,4 @@ public interface IAsyncOperationMethodsImpl /// The results of the operation. /// static abstract TResult GetResults(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationWithProgressMethodsImpl{TResult, TProgress}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationWithProgressMethodsImpl{TResult, TProgress}.cs index 5b0fc97bf9..d8f4ccb1ce 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationWithProgressMethodsImpl{TResult, TProgress}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/IAsyncOperationWithProgressMethodsImpl{TResult, TProgress}.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using Windows.Foundation; namespace WindowsRuntime.InteropServices; @@ -12,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// The result type. /// The type of progress information. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IAsyncOperationWithProgressMethodsImpl { /// @@ -57,4 +52,4 @@ public interface IAsyncOperationWithProgressMethodsImpl /// The results of the operation. /// static abstract TResult GetResults(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs index bc1c6475f9..1749195175 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -18,14 +17,11 @@ namespace WindowsRuntime.InteropServices; /// is supported. Implementations are also expected to pre-cache the resulting object references while performing these checks. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class DynamicInterfaceCastableForwarderAttribute : Attribute { /// /// The instance to use to perform QueryInterface calls. /// The resulting for the effective interface, if available. public abstract bool IsInterfaceImplemented(WindowsRuntimeObject thisObject, [NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs index 6e7bbb0ae7..c641ebeb60 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// Indicates the authored Windows Runtime class type that a given activation factory is for. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeActivationFactoryAttribute : Attribute { /// @@ -29,4 +25,4 @@ public WindowsRuntimeActivationFactoryAttribute(Type runtimeClassType) /// Gets the authored Windows Runtime class type that the annotated activation factory is for. /// public Type RuntimeClassType { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs index 77a19c1874..0802e82b94 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -41,10 +40,7 @@ namespace WindowsRuntime.InteropServices; AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe class WindowsRuntimeComWrappersMarshallerAttribute : Attribute { /// @@ -139,4 +135,4 @@ static NotSupportedException GetNotSupportedException() throw GetNotSupportedException(); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs index dd0b2a0a90..7a52538f9c 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -16,10 +15,7 @@ namespace WindowsRuntime.InteropServices; /// /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeComponentAssemblyAttribute : Attribute { /// @@ -28,4 +24,4 @@ public sealed class WindowsRuntimeComponentAssemblyAttribute : Attribute public WindowsRuntimeComponentAssemblyAttribute() { } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs index 9bdc7db4e7..6b1ef71188 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeComponentAssemblyExportsTypeAttribute : Attribute { /// @@ -34,4 +30,4 @@ public WindowsRuntimeComponentAssemblyExportsTypeAttribute(Type exportsType) /// Gets the type that contains the managed GetActivationFactory method to invoke for authoring scenarios. /// public Type ExportsType { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs index 69e72069bc..72916e1bcd 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// Indicates a mapped type for a Windows Runtime type projection (ie. a metadata provider type). /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeMappedTypeAttribute : Attribute { /// @@ -29,4 +25,4 @@ public WindowsRuntimeMappedTypeAttribute(Type publicType) /// Gets the public type associated with the current instance (ie. the type that would be used directly by developers). /// public Type PublicType { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs index 6625d2f27d..ed4b612b7d 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -17,10 +16,7 @@ namespace WindowsRuntime.InteropServices; /// /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class WindowsRuntimeReferenceAssemblyAttribute : Attribute { /// @@ -29,4 +25,4 @@ public sealed class WindowsRuntimeReferenceAssemblyAttribute : Attribute public WindowsRuntimeReferenceAssemblyAttribute() { } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Bindables/BindableIReadOnlyListAdapter.cs b/src/WinRT.Runtime2/InteropServices/Bindables/BindableIReadOnlyListAdapter.cs index 23b2862b0b..67393ee26c 100644 --- a/src/WinRT.Runtime2/InteropServices/Bindables/BindableIReadOnlyListAdapter.cs +++ b/src/WinRT.Runtime2/InteropServices/Bindables/BindableIReadOnlyListAdapter.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// still uses "IReadOnlyList" in its name to match the naming convention of adapter types matching .NET type names. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class BindableIReadOnlyListAdapter : IEnumerable { /// @@ -58,4 +54,4 @@ public IEnumerator GetEnumerator() { return _list.GetEnumerator(); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeArrayComWrappersCallback.cs b/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeArrayComWrappersCallback.cs index 074d3e64d5..aba67353d7 100644 --- a/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeArrayComWrappersCallback.cs +++ b/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeArrayComWrappersCallback.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// /// An interface for callbacks for , for Windows Runtime arrays. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe interface IWindowsRuntimeArrayComWrappersCallback { /// @@ -38,4 +34,4 @@ public unsafe interface IWindowsRuntimeArrayComWrappersCallback /// /// static abstract Array CreateArray(uint count, void* value); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeObjectComWrappersCallback.cs b/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeObjectComWrappersCallback.cs index 8e0e279a0b..3b7a145999 100644 --- a/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeObjectComWrappersCallback.cs +++ b/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeObjectComWrappersCallback.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices; @@ -10,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// An interface for callbacks for , for Windows Runtime objects. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe interface IWindowsRuntimeObjectComWrappersCallback { /// @@ -47,4 +42,4 @@ public unsafe interface IWindowsRuntimeObjectComWrappersCallback /// /// static abstract object CreateObject(void* value, out CreatedWrapperFlags wrapperFlags); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeUnsealedObjectComWrappersCallback.cs b/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeUnsealedObjectComWrappersCallback.cs index 83f5f3d92c..95f65aa878 100644 --- a/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeUnsealedObjectComWrappersCallback.cs +++ b/src/WinRT.Runtime2/InteropServices/Callbacks/IWindowsRuntimeUnsealedObjectComWrappersCallback.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// An interface for callbacks for , for unsealed Windows Runtime objects. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe interface IWindowsRuntimeUnsealedObjectComWrappersCallback { /// @@ -62,4 +58,4 @@ static abstract bool TryCreateObject( /// /// static abstract object CreateObject(void* value, out CreatedWrapperFlags wrapperFlags); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryAdapterExtensions.cs b/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryAdapterExtensions.cs index 47dd367703..b6094cf422 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryAdapterExtensions.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryAdapterExtensions.cs @@ -5,7 +5,6 @@ using System.Collections.Concurrent; using System.Collections.Frozen; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; #pragma warning disable IDE0045, IDE0046 @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// /// Extensions for the type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IDictionaryAdapterExtensions { extension(IDictionaryAdapter) @@ -127,4 +123,4 @@ public static void Remove(IDictionary dictionary, ReadOnlySpanThe type of keys in the dictionary. /// The type of values in the dictionary. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IDictionaryAdapter { /// @@ -115,4 +110,4 @@ public static void Remove(IDictionary dictionary, TKey key) KeyNotFoundException.ThrowKeyNotFound(); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods.cs index e5071cfee0..d8c668980c 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods.cs @@ -1,18 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// Methods for implementations of types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IDictionaryMethods { /// @@ -28,4 +22,4 @@ public static void Clear(WindowsRuntimeObjectReference thisReference) { IMapMethods.Clear(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods{TKey, TValue}.cs index 7de74cf38f..d01adf88c9 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IDictionaryMethods{TKey, TValue}.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; #pragma warning disable CS1573, IDE0046 @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of keys in the dictionary. /// The type of values in the dictionary. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IDictionaryMethods { /// @@ -210,4 +206,4 @@ public static bool Remove(WindowsRuntimeObjectReference thisReference, return true; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableAdapter{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableAdapter{T}.cs index 5a6712311d..64a72601b2 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableAdapter{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableAdapter{T}.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using WindowsRuntime.InteropServices.Marshalling; namespace WindowsRuntime.InteropServices; @@ -13,10 +12,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of objects to enumerate. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumerableAdapter { /// @@ -61,4 +57,4 @@ public static unsafe void First(IEnumerable enumerable, in Guid iid, void** e *enumerator = (void*)WindowsRuntimeComWrappers.GetOrCreateComInterfaceForObjectExact(enumeratorAdapter, in iid); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableMethods{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableMethods{T}.cs index 65ce32a786..82510e0a37 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableMethods{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IEnumerableMethods{T}.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -12,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// Methods for types. /// /// The type of objects to enumerate. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumerableMethods { /// @@ -40,4 +35,4 @@ public static IEnumerator GetEnumerator(WindowsRuntimeObjectReferen // object implementing 'IEnumerator', or a managed object that was passed to native as a CCW. return enumerator; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapterExtensions.cs b/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapterExtensions.cs index 0a8d3cda77..1590c2dddd 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapterExtensions.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapterExtensions.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using WindowsRuntime.InteropServices.Marshalling; namespace WindowsRuntime.InteropServices; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// Extensions for the type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorAdapterExtensions { // Note: all the extensions in this file match the ones in 'IReadOnlyListAdapterExtensions', @@ -170,10 +166,7 @@ public unsafe uint GetMany(uint itemsSize, ABI.System.Type* items) /// /// Extensions for the type for blittable value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorAdapterBlittableValueTypeExtensions { extension(IEnumeratorAdapter adapter) @@ -206,10 +199,7 @@ public unsafe uint GetMany(uint itemsSize, T* items) /// /// Extensions for the type for unmanaged value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorAdapterUnmanagedValueTypeExtensions { extension(IEnumeratorAdapter adapter) @@ -244,10 +234,7 @@ public unsafe uint GetMany(uint itemsSize, TAbi* items) /// /// Extensions for the type for managed value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorAdapterManagedValueTypeExtensions { extension(IEnumeratorAdapter adapter) @@ -294,10 +281,7 @@ public unsafe uint GetMany(uint itemsSize, TAbi* items) /// /// Extensions for the type for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorAdapterKeyValuePairTypeExtensions { extension(IEnumeratorAdapter> adapter) @@ -342,10 +326,7 @@ public unsafe uint GetMany(uint itemsSize, void** items) /// /// Extensions for the type for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorAdapterNullableTypeExtensions { extension(IEnumeratorAdapter adapter) @@ -391,10 +372,7 @@ public unsafe uint GetMany(uint itemsSize, void** items) /// /// Extensions for the type for reference types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IEnumeratorAdapterReferenceTypeExtensions { extension(IEnumeratorAdapter adapter) @@ -435,4 +413,4 @@ public unsafe uint GetMany(uint itemsSize, void** items) return index; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapter{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapter{T}.cs index a50a24218c..3cb1ffe046 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapter{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IEnumeratorAdapter{T}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; #pragma warning disable IDE0032 @@ -16,10 +15,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of objects to enumerate. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class IEnumeratorAdapter : IEnumerator, IEnumeratorAdapter { /// @@ -204,4 +200,4 @@ private IEnumeratorAdapter Create(IEnumerator enumerator) { return new(enumerator); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IIterableMethodsImpl{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IIterableMethodsImpl{T}.cs index 1b7e8eb5e2..85dcf179fd 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IIterableMethodsImpl{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IIterableMethodsImpl{T}.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -11,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// An interface for implementations of Windows.Foundation.Collections.IIterable<T> types. /// /// The type of objects to enumerate. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IIterableMethodsImpl { /// @@ -24,4 +19,4 @@ public interface IIterableMethodsImpl /// The iterator. /// static abstract IEnumerator First(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethods.cs index 63eed64d3f..43b0d88d07 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethods.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -10,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for Windows.Foundation.Collections.IIterator<T> types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IIteratorMethods { /// @@ -54,4 +49,4 @@ public static bool MoveNext(WindowsRuntimeObjectReference thisReference) return result; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethodsImpl{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethodsImpl{T}.cs index 785f129dbc..abe509295c 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethodsImpl{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IIteratorMethodsImpl{T}.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// An interface for implementations of Windows.Foundation.Collections.IIterator<T> types. /// /// The type of objects to enumerate. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IIteratorMethodsImpl { /// @@ -23,4 +17,4 @@ public interface IIteratorMethodsImpl /// The current element. /// static abstract T Current(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IListAdapterExtensions.cs b/src/WinRT.Runtime2/InteropServices/Collections/IListAdapterExtensions.cs index 55238b460a..ddd8fe06d2 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IListAdapterExtensions.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IListAdapterExtensions.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using WindowsRuntime.InteropServices.Marshalling; namespace WindowsRuntime.InteropServices; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// Extensions for the type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapterExtensions { // Note: all the extensions in this file exactly match the ones in 'IReadOnlyListAdapterExtensions'. @@ -226,10 +222,7 @@ public static unsafe uint GetMany(IList list, uint startIndex, uint itemsS /// /// Extensions for the type for blittable value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapterBlittableValueTypeExtensions { extension(IListAdapter) @@ -269,10 +262,7 @@ public static unsafe uint GetMany(IList list, uint startIndex, uint itemsSize /// /// Extensions for the type for unmanaged value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapterUnmanagedValueTypeExtensions { extension(IListAdapter) @@ -314,10 +304,7 @@ public static unsafe uint GetMany(IList list, uint startI /// /// Extensions for the type for managed value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapterManagedValueTypeExtensions { extension(IListAdapter) @@ -374,10 +361,7 @@ public static unsafe uint GetMany(IList list, uint startI /// /// Extensions for the type for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapterKeyValuePairTypeExtensions { extension(IListAdapter>) @@ -432,10 +416,7 @@ public static unsafe uint GetMany(IList /// Extensions for the type for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapterNullableTypeExtensions { extension(IListAdapter) @@ -491,10 +472,7 @@ public static unsafe uint GetMany(IList list, uint start /// /// Extensions for the type for reference types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapterReferenceTypeExtensions { extension(IListAdapter) @@ -543,4 +521,4 @@ public static unsafe uint GetMany(IList list, uint startI return (uint)itemCount; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IListAdapter{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IListAdapter{T}.cs index 23b4ad4dd7..c0f34a5437 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IListAdapter{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IListAdapter{T}.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -14,10 +13,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of objects to enumerate. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListAdapter { /// @@ -203,4 +199,4 @@ public static void RemoveAtEnd(IList list) throw; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IListMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IListMethods.cs index 8ea7bbcf53..cc2fbd85f0 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IListMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IListMethods.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; #pragma warning disable CS1573 @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListMethods { /// @@ -48,4 +44,4 @@ public static void RemoveAt(WindowsRuntimeObjectReference thisReference, int ind throw ArgumentOutOfRangeException.GetArgumentOutOfRangeException(nameof(index)); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IListMethods{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IListMethods{T}.cs index d5e19d09a4..849ecd40de 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IListMethods{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IListMethods{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; #pragma warning disable CS1573 @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// Methods for types. /// /// The type of objects to enumerate. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IListMethods { /// @@ -159,4 +155,4 @@ public static void Insert(WindowsRuntimeObjectReference thisReference, throw ArgumentOutOfRangeException.GetArgumentOutOfRangeException(nameof(index)); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethods.cs index df55acf04a..f4caf1901e 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethods.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using Windows.Foundation.Collections; @@ -11,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for Windows.Foundation.Collections.IMapChangedEventArgs<K> types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IMapChangedEventArgsMethods { /// @@ -35,4 +30,4 @@ public static CollectionChange CollectionChange(WindowsRuntimeObjectReference th return result; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethodsImpl{K}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethodsImpl{K}.cs index 41fe28b9ed..2cfefc2da8 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethodsImpl{K}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IMapChangedEventArgsMethodsImpl{K}.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// An interface for implementations of Windows.Foundation.Collections.IMapChangedEventArgs<K> types. /// /// The type of keys in the map. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IMapChangedEventArgsMethodsImpl { /// @@ -23,4 +17,4 @@ public interface IMapChangedEventArgsMethodsImpl /// The key of the item that changed. /// static abstract K Key(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IMapMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IMapMethods.cs index a59d695f66..7e03466992 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IMapMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IMapMethods.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; #pragma warning disable CS1573 @@ -12,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for Windows.Foundation.Collections.IMap<K, V> types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IMapMethods { /// @@ -39,4 +34,4 @@ public static void Clear(WindowsRuntimeObjectReference thisReference) RestrictedErrorInfo.ThrowExceptionForHR(((IMapVftbl*)*(void***)thisPtr)->Clear(thisPtr)); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IMapMethodsImpl{K, V}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IMapMethodsImpl{K, V}.cs index a8a62dd20e..4942f6ba97 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IMapMethodsImpl{K, V}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IMapMethodsImpl{K, V}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of keys in the map. /// The type of values in the map. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IMapMethodsImpl { /// @@ -52,4 +46,4 @@ public interface IMapMethodsImpl /// The key associated with the item to remove. /// static abstract void Remove(WindowsRuntimeObjectReference thisReference, K key); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethods.cs index 5617a0893e..58e33a5c15 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethods.cs @@ -1,18 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// Methods for Windows.Foundation.Collections.IMapView<K, V> types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IMapViewMethods { /// @@ -26,4 +20,4 @@ public static uint Size(WindowsRuntimeObjectReference thisReference) // The vtable slot for 'get_Size' is identical between 'IMapView' and 'IVectorView' return IVectorViewMethods.Size(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethodsImpl{K, V}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethodsImpl{K, V}.cs index b3e2dfe47c..a6056f38e5 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethodsImpl{K, V}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IMapViewMethodsImpl{K, V}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of keys in the map. /// The type of values in the map. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IMapViewMethodsImpl { /// @@ -34,4 +28,4 @@ public interface IMapViewMethodsImpl /// if the key is found; otherwise, . /// static abstract bool HasKey(WindowsRuntimeObjectReference thisReference, K key); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IObservableMapEventSourceFactory{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IObservableMapEventSourceFactory{TKey, TValue}.cs index 02c97cbd80..579de7533a 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IObservableMapEventSourceFactory{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IObservableMapEventSourceFactory{TKey, TValue}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of keys in the observable map. /// The type of values in the observable map. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IObservableMapEventSourceFactory { /// @@ -24,4 +18,4 @@ public interface IObservableMapEventSourceFactory /// The instance to be used with . /// static abstract ABI.Windows.Foundation.Collections.MapChangedEventHandlerEventSource MapChanged(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IObservableVectorEventSourceFactory{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IObservableVectorEventSourceFactory{T}.cs index 8ba76aa0e9..47a15917c3 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IObservableVectorEventSourceFactory{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IObservableVectorEventSourceFactory{T}.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// An interface for implementations of types. /// /// The type of elements in the observable vector. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IObservableVectorEventSourceFactory { /// @@ -23,4 +17,4 @@ public interface IObservableVectorEventSourceFactory /// The instance to be used with . /// static abstract ABI.Windows.Foundation.Collections.VectorChangedEventHandlerEventSource VectorChanged(WindowsRuntimeObjectReference thisReference); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapterExtensions.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapterExtensions.cs index 08bd42ab30..ab432ba665 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapterExtensions.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapterExtensions.cs @@ -5,7 +5,6 @@ using System.Collections.Concurrent; using System.Collections.Frozen; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; #pragma warning disable IDE0045, IDE0046 @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// /// Extensions for the type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyDictionaryAdapterExtensions { extension(IReadOnlyDictionaryAdapter) @@ -103,4 +99,4 @@ public static bool HasKey(IReadOnlyDictionary dictionary, ReadOn return dictionary.ContainsKey(key.ToString()); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapter{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapter{TKey, TValue}.cs index 74ac8414df..17263d77d3 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapter{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryAdapter{TKey, TValue}.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -15,10 +13,7 @@ namespace WindowsRuntime.InteropServices; /// The type of keys in the dictionary. /// The type of values in the dictionary. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyDictionaryAdapter { /// @@ -84,4 +79,4 @@ public static void Split( splitAdapter.Split(out first, out second); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods.cs index 1d240ffbfc..d4b384d69b 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - #pragma warning disable CS1573 namespace WindowsRuntime.InteropServices; @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyDictionaryMethods { /// @@ -24,4 +18,4 @@ public static int Count(WindowsRuntimeObjectReference thisReference) // The vtable slot for 'get_Size' and the desired semantics are identical between 'IMapView' and 'IVectorView' return IReadOnlyListMethods.Count(thisReference); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods{TKey, TValue}.cs index b0e6986841..6896b78216 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionaryMethods{TKey, TValue}.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; #pragma warning disable CS1573 @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of keys in the read-only dictionary. /// The type of values in the read-only dictionary. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyDictionaryMethods { /// @@ -72,4 +68,4 @@ public static bool TryGetValue(WindowsRuntimeObjectReference thisRefer return true; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionarySplitAdapter{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionarySplitAdapter{TKey, TValue}.cs index 362f95ed7b..0f6104561e 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionarySplitAdapter{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyDictionarySplitAdapter{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; #pragma warning disable IDE0046 @@ -17,10 +16,7 @@ namespace WindowsRuntime.InteropServices; /// The type of keys in the dictionary. /// The type of values in the dictionary. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class IReadOnlyDictionarySplitAdapter : IReadOnlyDictionary { /// @@ -214,4 +210,4 @@ public int Compare(KeyValuePair x, KeyValuePair y) return Comparer.Default.Compare(x.Key, y.Key); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapterExtensions.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapterExtensions.cs index b97b9e4d75..833895d966 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapterExtensions.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapterExtensions.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using WindowsRuntime.InteropServices.Marshalling; namespace WindowsRuntime.InteropServices; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// Extensions for the type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapterExtensions { extension(IReadOnlyListAdapter) @@ -228,10 +224,7 @@ public static unsafe uint GetMany(IReadOnlyList list, uint startIndex, uin /// /// Extensions for the type for blittable value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapterBlittableValueTypeExtensions { extension(IReadOnlyListAdapter) @@ -271,10 +264,7 @@ public static unsafe uint GetMany(IReadOnlyList list, uint startIndex, uint i /// /// Extensions for the type for unmanaged value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapterUnmanagedValueTypeExtensions { extension(IReadOnlyListAdapter) @@ -316,10 +306,7 @@ public static unsafe uint GetMany(IReadOnlyList list, uin /// /// Extensions for the type for managed value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapterManagedValueTypeExtensions { extension(IReadOnlyListAdapter) @@ -376,10 +363,7 @@ public static unsafe uint GetMany(IReadOnlyList list, uin /// /// Extensions for the type for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapterKeyValuePairTypeExtensions { extension(IReadOnlyListAdapter>) @@ -434,10 +418,7 @@ public static unsafe uint GetMany(IReadOnlyList /// Extensions for the type for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapterNullableTypeExtensions { extension(IReadOnlyListAdapter) @@ -493,10 +474,7 @@ public static unsafe uint GetMany(IReadOnlyList list, ui /// /// Extensions for the type for reference types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapterReferenceTypeExtensions { extension(IReadOnlyListAdapter) @@ -545,4 +523,4 @@ public static unsafe uint GetMany(IReadOnlyList list, uin return (uint)itemCount; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapter{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapter{T}.cs index c09c03020a..bbff4742d0 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapter{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListAdapter{T}.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -13,10 +12,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of objects to enumerate. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListAdapter { /// @@ -82,4 +78,4 @@ public static bool IndexOf(IReadOnlyList list, T value, out uint index) return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods.cs index bf27f25986..0dda9ddaea 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods.cs @@ -2,17 +2,13 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; /// /// Methods for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListMethods { /// @@ -26,4 +22,4 @@ public static int Count(WindowsRuntimeObjectReference thisReference) return (int)count; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods{T}.cs index 940404ba05..cdc285438a 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IReadOnlyListMethods{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; #pragma warning disable CS1573 @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// Methods for types. /// /// The type of objects to enumerate. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IReadOnlyListMethods { /// @@ -38,4 +34,4 @@ public static T Item(WindowsRuntimeObjectReference thisReference, int throw ArgumentOutOfRangeException.GetArgumentOutOfRangeException(nameof(index)); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethods.cs index 8ca1491ae6..8a5eeaacfb 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethods.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -10,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for Windows.Foundation.Collections.IVector<T> types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IVectorMethods { /// @@ -58,4 +53,4 @@ public static void Clear(WindowsRuntimeObjectReference thisReference) RestrictedErrorInfo.ThrowExceptionForHR(((IVectorVftbl*)*(void***)thisPtr)->Clear(thisPtr)); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethodsImpl{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethodsImpl{T}.cs index 6ab0679404..bc240c2764 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethodsImpl{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IVectorMethodsImpl{T}.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// An interface for implementations of Windows.Foundation.Collections.IVector<T> types. /// /// The type of objects to enumerate. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IVectorMethodsImpl { /// @@ -60,4 +54,4 @@ public interface IVectorMethodsImpl /// The item to insert. /// static abstract void InsertAt(WindowsRuntimeObjectReference thisReference, uint index, T value); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethods.cs b/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethods.cs index 58f3d4b4ba..57fa1057ab 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethods.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -10,10 +8,7 @@ namespace WindowsRuntime.InteropServices; /// /// Methods for Windows.Foundation.Collections.IVectorView<T> types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IVectorViewMethods { /// @@ -34,4 +29,4 @@ public static uint Size(WindowsRuntimeObjectReference thisReference) return result; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethodsImpl{T}.cs b/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethodsImpl{T}.cs index f99494d5e4..52df49af03 100644 --- a/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethodsImpl{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Collections/IVectorViewMethodsImpl{T}.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// An interface for implementations of Windows.Foundation.Collections.IVectorView<T> types. /// /// The type of objects to enumerate. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IVectorViewMethodsImpl { /// @@ -24,4 +18,4 @@ public interface IVectorViewMethodsImpl /// The item at the specified index. /// static abstract T GetAt(WindowsRuntimeObjectReference thisReference, uint index); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Dispatching/DispatcherQueueSynchronizationContext.cs b/src/WinRT.Runtime2/InteropServices/Dispatching/DispatcherQueueSynchronizationContext.cs index 976ee2634a..20e544160d 100644 --- a/src/WinRT.Runtime2/InteropServices/Dispatching/DispatcherQueueSynchronizationContext.cs +++ b/src/WinRT.Runtime2/InteropServices/Dispatching/DispatcherQueueSynchronizationContext.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Threading; namespace WindowsRuntime.InteropServices; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// the UI thread. It needs to be installed on the UI thread through /// invoked on a wrapping managed object (which is generated in a projection .dll). /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public readonly struct DispatcherQueueSynchronizationContext { /// @@ -100,4 +96,4 @@ public void Send(SendOrPostCallback d, object? state) { throw new NotSupportedException("'SynchronizationContext.Send' is not supported."); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource.cs b/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource.cs index f52596ac36..a4eef5d2a9 100644 --- a/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource.cs +++ b/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource.cs @@ -2,17 +2,13 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; /// /// An implementation for . /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed unsafe class EventHandlerEventSource : EventSource { /// @@ -50,4 +46,4 @@ protected override EventHandler GetEventInvoke() return (obj, e) => TargetDelegate?.Invoke(obj, e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TEventArgs}.cs b/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TEventArgs}.cs index 8c4511ae8e..fd5a015f34 100644 --- a/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TEventArgs}.cs +++ b/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TEventArgs}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// An implementation for . /// /// The type of the event data generated by the event. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe class EventHandlerEventSource : EventSource> { /// @@ -45,4 +41,4 @@ protected override EventHandler GetEventInvoke() return (obj, e) => TargetDelegate?.Invoke(obj, e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TSender,TEventArgs}.cs b/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TSender,TEventArgs}.cs index 9df6c6cff5..8998956a31 100644 --- a/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TSender,TEventArgs}.cs +++ b/src/WinRT.Runtime2/InteropServices/Events/EventHandlerEventSource{TSender,TEventArgs}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of object raising the event. /// The type of the event data generated by the event. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe class EventHandlerEventSource : EventSource> { /// @@ -46,4 +42,4 @@ protected override EventHandler GetEventInvoke() return (obj, e) => TargetDelegate?.Invoke(obj, e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationTokenTable{T}.cs b/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationTokenTable{T}.cs index e7e3124111..e2b198d7c2 100644 --- a/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationTokenTable{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationTokenTable{T}.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -14,10 +13,7 @@ namespace WindowsRuntime.InteropServices; /// sourcing Windows Runtime style events from managed code. This only supports events for CCW objects. /// /// The event handler type to use in the table. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class EventRegistrationTokenTable where T : MulticastDelegate { @@ -177,4 +173,4 @@ private static int GetTypeOfTHashCode() // To work around this, we just check for this edge case and return a magic constant instead. return hashCode == 0 ? 0x5FC74196 : hashCode; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Events/EventSourceState{T}.cs b/src/WinRT.Runtime2/InteropServices/Events/EventSourceState{T}.cs index 976d76cb61..a10632536f 100644 --- a/src/WinRT.Runtime2/InteropServices/Events/EventSourceState{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Events/EventSourceState{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// /// The type of delegate being managed from the associated event. [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe class EventSourceState : IDisposable where T : MulticastDelegate { @@ -212,4 +208,4 @@ private void OnDispose() EventSourceCache.Remove(thisPtr, _index, _weakReferenceToSelf); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Events/EventSource{T}.cs b/src/WinRT.Runtime2/InteropServices/Events/EventSource{T}.cs index 371453befe..12536434e4 100644 --- a/src/WinRT.Runtime2/InteropServices/Events/EventSource{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Events/EventSource{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// A managed wrapper for an event to expose to a native Windows Runtime consumer. /// /// The type of delegate being managed. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe class EventSource where T : MulticastDelegate { @@ -221,4 +217,4 @@ private bool TryGetStateUnsafe([NotNullWhen(true)] out EventSourceState? stat return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs b/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs index 5daf6e3856..b228f3776c 100644 --- a/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs +++ b/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// Handles the IRestrictedErrorInfo infrastructure for .NET exceptions. /// /// . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class RestrictedErrorInfo { /// diff --git a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs index 595875a15f..082c65de26 100644 --- a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs +++ b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -12,14 +11,11 @@ namespace WindowsRuntime.InteropServices; /// /// This interface is only meant to be used to support marshalling code for generic instantiations. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeInterface { /// /// Gets the IID for the implemented interface. /// static abstract ref readonly Guid IID { get; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs index 18b467a373..b306b78023 100644 --- a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// @@ -18,10 +15,7 @@ namespace WindowsRuntime.InteropServices; /// The type must refer to a projected Windows Runtime interface. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeInterface where T : class { @@ -30,4 +24,4 @@ public interface IWindowsRuntimeInterface /// /// The cached instance for the interface . WindowsRuntimeObjectReferenceValue GetInterface(); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeKeyValuePairTypeElementMarshaller{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeKeyValuePairTypeElementMarshaller{TKey, TValue}.cs index 902cd1d7f6..56bd5f1b8c 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeKeyValuePairTypeElementMarshaller{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeKeyValuePairTypeElementMarshaller{TKey, TValue}.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.ComponentModel; namespace WindowsRuntime.InteropServices.Marshalling; @@ -12,10 +10,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of the key. /// The type of the value. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeKeyValuePairTypeElementMarshaller { /// diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeManagedValueTypeElementMarshaller{T, TAbi}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeManagedValueTypeElementMarshaller{T, TAbi}.cs index 3bcfa861cb..827dc6e6fb 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeManagedValueTypeElementMarshaller{T, TAbi}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeManagedValueTypeElementMarshaller{T, TAbi}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of elements in the array. /// The ABI type for type . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeManagedValueTypeElementMarshaller where T : struct where TAbi : unmanaged diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeNullableTypeElementMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeNullableTypeElementMarshaller{T}.cs index 50c1e54e4b..7b8c2f7947 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeNullableTypeElementMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeNullableTypeElementMarshaller{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// An interface for marshalling collection elements to native. /// /// The underlying value type of the nullable type. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeNullableTypeElementMarshaller where T : struct { diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeReferenceTypeElementMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeReferenceTypeElementMarshaller{T}.cs index e5ed85edcc..d7516ed65c 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeReferenceTypeElementMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeReferenceTypeElementMarshaller{T}.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// /// An interface for marshalling collection elements to native. /// /// The type of elements in the array. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeReferenceTypeElementMarshaller where T : class { diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeUnmanagedValueTypeElementMarshaller{T, TAbi}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeUnmanagedValueTypeElementMarshaller{T, TAbi}.cs index 0358ac8975..bfb03fcb8c 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeUnmanagedValueTypeElementMarshaller{T, TAbi}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/Collections/IWindowsRuntimeUnmanagedValueTypeElementMarshaller{T, TAbi}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of elements in the array. /// The ABI type for type . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeUnmanagedValueTypeElementMarshaller where T : unmanaged where TAbi : unmanaged diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/HStringHeader.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/HStringHeader.cs index 1b169310de..3323b674e9 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/HStringHeader.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/HStringHeader.cs @@ -1,18 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// /// Represents a header for a fast-pass HSTRING value (passed without copying). /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public struct HStringHeader { /// @@ -22,4 +16,4 @@ public struct HStringHeader /// Using this field to mirror the layout of with one fewer indirection. /// internal HSTRING_HEADER._Reserved_e__Union _reserved; -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/HStringMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/HStringMarshaller.cs index 0db896dd7c..37dae15ed7 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/HStringMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/HStringMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for the Windows Runtime HSTRING type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class HStringMarshaller { /// @@ -171,4 +167,4 @@ public static void Free(HSTRING value) // We can ignore the return value, as this method always returns 'S_OK' _ = WindowsRuntimeImports.WindowsDeleteString(value); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/HStringReference.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/HStringReference.cs index 832965ac3d..cfd7e9df83 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/HStringReference.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/HStringReference.cs @@ -1,18 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// /// Represents a reference to a fast-pass HSTRING value (passed without copying). /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe ref struct HStringReference { /// @@ -32,4 +26,4 @@ public unsafe ref struct HStringReference /// It is not valid to escape this value outside of the scope of the current instance. /// public readonly HSTRING HString => _hstring; -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/ExceptionArrayMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/ExceptionArrayMarshaller.cs index 436fd7a79b..0a807e42d8 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/ExceptionArrayMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/ExceptionArrayMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for arrays of the Windows Runtime type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class ExceptionArrayMarshaller { /// @@ -104,4 +100,4 @@ public static void CopyToManaged(uint size, ABI.System.Exception* source, Span /// A marshaller for arrays of the Windows Runtime HSTRING type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class HStringArrayMarshaller { /// @@ -271,4 +267,4 @@ public static void Free(uint size, void** array) Marshal.FreeCoTaskMem((nint)array); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeKeyValuePairTypeArrayElementMarshaller{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeKeyValuePairTypeArrayElementMarshaller{TKey, TValue}.cs index 2c6d040212..9c1ae3abc8 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeKeyValuePairTypeArrayElementMarshaller{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeKeyValuePairTypeArrayElementMarshaller{TKey, TValue}.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.ComponentModel; namespace WindowsRuntime.InteropServices.Marshalling; @@ -12,10 +10,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of the key. /// The type of the value. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe interface IWindowsRuntimeKeyValuePairTypeArrayElementMarshaller { /// diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeManagedValueTypeArrayElementMarshaller{T, TAbi}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeManagedValueTypeArrayElementMarshaller{T, TAbi}.cs index 1f2052b0a3..f9a7838d91 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeManagedValueTypeArrayElementMarshaller{T, TAbi}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeManagedValueTypeArrayElementMarshaller{T, TAbi}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of elements in the array. /// The ABI type for type . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeManagedValueTypeArrayElementMarshaller where T : struct where TAbi : unmanaged diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeNullableTypeArrayElementMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeNullableTypeArrayElementMarshaller{T}.cs index 7ade281e51..c39c14d763 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeNullableTypeArrayElementMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeNullableTypeArrayElementMarshaller{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// An interface for marshalling implementations to support . /// /// The underlying value type of the nullable type. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe interface IWindowsRuntimeNullableTypeArrayElementMarshaller where T : struct { diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeReferenceTypeArrayElementMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeReferenceTypeArrayElementMarshaller{T}.cs index bd913731f7..257c505c31 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeReferenceTypeArrayElementMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeReferenceTypeArrayElementMarshaller{T}.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// /// An interface for marshalling implementations to support . /// /// The type of elements in the array. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe interface IWindowsRuntimeReferenceTypeArrayElementMarshaller where T : class { diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeUnmanagedValueTypeArrayElementMarshaller{T, TAbi}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeUnmanagedValueTypeArrayElementMarshaller{T, TAbi}.cs index 11743faf18..b29099b57c 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeUnmanagedValueTypeArrayElementMarshaller{T, TAbi}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/IWindowsRuntimeUnmanagedValueTypeArrayElementMarshaller{T, TAbi}.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// @@ -11,10 +8,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of elements in the array. /// The ABI type for type . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public interface IWindowsRuntimeUnmanagedValueTypeArrayElementMarshaller where T : unmanaged where TAbi : unmanaged diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/TypeArrayMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/TypeArrayMarshaller.cs index dd43538aa2..371d21cfc6 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/TypeArrayMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/TypeArrayMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for arrays of the Windows Runtime type. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class TypeArrayMarshaller { /// @@ -162,4 +158,4 @@ public static void Free(uint size, ABI.System.Type* array) Marshal.FreeCoTaskMem((nint)array); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller.cs index 79fc337642..88d490d4b7 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for arrays of blittable Windows Runtime types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeBlittableValueTypeArrayMarshaller { /// @@ -32,4 +28,4 @@ public static void Free(uint size, void* array) Marshal.FreeCoTaskMem((nint)array); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller{T}.cs index 2867243f5c..2a23149c75 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeBlittableValueTypeArrayMarshaller{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// A marshaller for arrays of blittable Windows Runtime types. /// /// The type of elements in the array. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeBlittableValueTypeArrayMarshaller where T : unmanaged { @@ -97,4 +93,4 @@ public static void CopyToManaged(uint size, T* source, Span destination) new ReadOnlySpan(source, (int)size).CopyTo(destination); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeKeyValuePairTypeArrayMarshaller{TKey, TValue}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeKeyValuePairTypeArrayMarshaller{TKey, TValue}.cs index ec3e5089cb..e3a6eac3dc 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeKeyValuePairTypeArrayMarshaller{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeKeyValuePairTypeArrayMarshaller{TKey, TValue}.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -13,10 +12,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of the key. /// The type of the value. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeKeyValuePairTypeArrayMarshaller { /// @@ -139,4 +135,4 @@ public static void CopyToManaged(uint size, void** source, S destination[(int)i] = TElementMarshaller.ConvertToManaged(source[i]); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeManagedValueTypeArrayMarshaller{T, TAbi}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeManagedValueTypeArrayMarshaller{T, TAbi}.cs index 85180e370a..2e46afd703 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeManagedValueTypeArrayMarshaller{T, TAbi}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeManagedValueTypeArrayMarshaller{T, TAbi}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of elements in the array. /// The ABI type for type . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeManagedValueTypeArrayMarshaller where T : struct where TAbi : unmanaged @@ -179,4 +175,4 @@ public static void Free(uint size, TAbi* array) Marshal.FreeCoTaskMem((nint)array); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeNullableTypeArrayMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeNullableTypeArrayMarshaller{T}.cs index dd9d23d35b..3ff0065c66 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeNullableTypeArrayMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeNullableTypeArrayMarshaller{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// A marshaller for arrays of types. /// /// The underlying value type of the nullable type. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeNullableTypeArrayMarshaller where T : struct { diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeObjectArrayMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeObjectArrayMarshaller.cs index 967752f911..f42baafaae 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeObjectArrayMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeObjectArrayMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for arrays of Windows Runtime objects. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeObjectArrayMarshaller { /// @@ -128,4 +124,4 @@ public static void CopyToManaged(uint size, void** source, Span destina destination[(int)i] = WindowsRuntimeObjectMarshaller.ConvertToManaged(source[i]); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeReferenceTypeArrayMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeReferenceTypeArrayMarshaller{T}.cs index 0ca314f15b..876ced0f7b 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeReferenceTypeArrayMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeReferenceTypeArrayMarshaller{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// A marshaller for arrays of reference Windows Runtime types. /// /// The type of elements in the array. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeReferenceTypeArrayMarshaller where T : class { @@ -138,4 +134,4 @@ public static void CopyToManaged(uint size, void** source, S destination[(int)i] = TElementMarshaller.ConvertToManaged(source[i]); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnknownArrayMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnknownArrayMarshaller.cs index 5fc9b78ec4..a0e617762a 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnknownArrayMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnknownArrayMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -13,10 +12,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// This type mirrors , but for arrays. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeUnknownArrayMarshaller { /// @@ -56,4 +52,4 @@ public static void Free(uint size, void** array) Marshal.FreeCoTaskMem((nint)array); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnmanagedValueTypeArrayMarshaller{T, TAbi}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnmanagedValueTypeArrayMarshaller{T, TAbi}.cs index 97c68fc9a2..25cbcded33 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnmanagedValueTypeArrayMarshaller{T, TAbi}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/SzArrays/WindowsRuntimeUnmanagedValueTypeArrayMarshaller{T, TAbi}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// The type of elements in the array. /// The ABI type for type . -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeUnmanagedValueTypeArrayMarshaller where T : unmanaged where TAbi : unmanaged @@ -119,4 +115,4 @@ public static void CopyToManaged(uint size, TAbi* source, Sp destination[(int)i] = TElementMarshaller.ConvertToManaged(source[i]); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/TypeReference.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/TypeReference.cs index 7f50ef2691..5a947b8303 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/TypeReference.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/TypeReference.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using Windows.UI.Xaml.Interop; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// Represents a reference to a value, for fast marshalling to native. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public unsafe ref struct TypeReference { /// @@ -67,4 +63,4 @@ public readonly ref byte GetPinnableReference() { return ref Unsafe.As(ref Unsafe.AsRef(in Name!.GetPinnableReference())); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeArrayMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeArrayMarshaller.cs index 37f1dad53e..b8ef650a43 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeArrayMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeArrayMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for Windows Runtime arrays. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeArrayMarshaller { /// @@ -59,4 +55,4 @@ public static unsafe class WindowsRuntimeArrayMarshaller WindowsRuntimeUnknownMarshaller.Free(referencePtr); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeDelegateMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeDelegateMarshaller.cs index 932bc84b40..f218a03c79 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeDelegateMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeDelegateMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -13,10 +12,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for Windows Runtime delegates. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeDelegateMarshaller { /// @@ -189,4 +185,4 @@ static void ThrowNotSupportedException(object value) // Now that we have the 'IReference' pointer, unbox it normally return UnboxToManaged(referencePtr); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeInterfaceMarshaller{T}.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeInterfaceMarshaller{T}.cs index bb7d786830..d81dc932d4 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeInterfaceMarshaller{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeInterfaceMarshaller{T}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// A marshaller for Windows Runtime interfaces. /// /// The type of the interface being marshalled. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeInterfaceMarshaller where T : class { @@ -219,4 +215,4 @@ private static void ThrowInvalidCastExceptionManaged(object value, in Guid iid, RestrictedErrorInfo.ThrowExceptionForHR(hresult); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeKeyValuePairTypeMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeKeyValuePairTypeMarshaller.cs index ff1b751f1c..5ac6d59709 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeKeyValuePairTypeMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeKeyValuePairTypeMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeKeyValuePairTypeMarshaller { /// @@ -34,4 +30,4 @@ public static WindowsRuntimeObjectReferenceValue ConvertToUnmanagedUnsafe(object { return new((void*)WindowsRuntimeComWrappers.Default.GetOrCreateComInterfaceForObject(value, flags, in iid)); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeObjectMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeObjectMarshaller.cs index 08c8b115a6..e403f2c9be 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeObjectMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeObjectMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for Windows Runtime objects. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeObjectMarshaller { /// @@ -124,4 +120,4 @@ static void ThrowNotSupportedException(object value) objectComWrappersCallback: WindowsRuntimeObjectComWrappersCallback.GetInstance(), unsealedObjectComWrappersCallback: null); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnknownMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnknownMarshaller.cs index 3bba42d511..dd0b9cfbcc 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnknownMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnknownMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for Windows Runtime or COM objects that does not do any additional QueryInterface calls for specific interfaces. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeUnknownMarshaller { /// @@ -68,4 +64,4 @@ public static void Free(void* value) _ = IUnknownVftbl.ReleaseUnsafe(value); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnsealedObjectMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnsealedObjectMarshaller.cs index 02fd47e608..11929b9633 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnsealedObjectMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeUnsealedObjectMarshaller.cs @@ -1,18 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for unsealed Windows Runtime objects. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeUnsealedObjectMarshaller { /// @@ -41,4 +35,4 @@ public static unsafe class WindowsRuntimeUnsealedObjectMarshaller objectComWrappersCallback: null, unsealedObjectComWrappersCallback: WindowsRuntimeUnsealedObjectComWrappersCallback.GetInstance()); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeValueTypeMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeValueTypeMarshaller.cs index 460e0f4c5e..71269c22f7 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeValueTypeMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/WindowsRuntimeValueTypeMarshaller.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.InteropServices; namespace WindowsRuntime.InteropServices.Marshalling; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// /// A marshaller for Windows Runtime value types. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeValueTypeMarshaller { /// @@ -176,4 +172,4 @@ public static T UnboxToManagedUnsafe(void* value, in Guid iid) return result; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ObjectReference/CreateObjectReferenceMarshalingType.cs b/src/WinRT.Runtime2/InteropServices/ObjectReference/CreateObjectReferenceMarshalingType.cs index efc02e0f53..306b4f66a9 100644 --- a/src/WinRT.Runtime2/InteropServices/ObjectReference/CreateObjectReferenceMarshalingType.cs +++ b/src/WinRT.Runtime2/InteropServices/ObjectReference/CreateObjectReferenceMarshalingType.cs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// /// Specifies the marshaling type to use to marshal a given Windows Runtime object, specifically when creating a instance. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public enum CreateObjectReferenceMarshalingType { /// @@ -31,4 +25,4 @@ public enum CreateObjectReferenceMarshalingType /// CoGetStandardMarshal on all interfaces. /// Standard -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReference.cs b/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReference.cs index ee06ae965e..fba67b7543 100644 --- a/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReference.cs +++ b/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReference.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -11,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// A managed, low-level wrapper for a native Windows Runtime object. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract unsafe partial class WindowsRuntimeObjectReference : IDisposable { /// @@ -152,4 +148,4 @@ internal CreateObjectReferenceFlags CopyFlags(CreateObjectReferenceFlags request /// /// The value to return from . private protected abstract bool DerivedIsInCurrentContext(); -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReferenceValue.cs b/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReferenceValue.cs index 99a2a83704..faaa36bdfe 100644 --- a/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReferenceValue.cs +++ b/src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReferenceValue.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// /// A marshalling-optimized wrapper for a Windows Runtime object. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public readonly unsafe ref struct WindowsRuntimeObjectReferenceValue { /// @@ -157,4 +153,4 @@ public void Dispose() _ = IUnknownVftbl.ReleaseUnsafe(_thisPtr); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionDllExports/TokenizerHelper.cs b/src/WinRT.Runtime2/InteropServices/ProjectionDllExports/TokenizerHelper.cs index 7b9e3a865b..92eb7948b1 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionDllExports/TokenizerHelper.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionDllExports/TokenizerHelper.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Globalization; namespace WindowsRuntime.InteropServices; @@ -10,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// /// Helper class for tokenizing used by generated projections. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class TokenizerHelper { /// @@ -35,4 +31,4 @@ public static char GetNumericListSeparator(IFormatProvider? provider) ? SemicolonSeparator : CommaSeparator; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IActivationFactoryImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IActivationFactoryImpl.cs index 7c6d9491c0..35914fdbea 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IActivationFactoryImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IActivationFactoryImpl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime; @@ -16,10 +15,7 @@ namespace ABI.WindowsRuntime.InteropServices; /// The IActivationFactory implementation for managed types. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IActivationFactoryImpl { /// diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IAgileObjectImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IAgileObjectImpl.cs index f8db6bff2c..8280044d65 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IAgileObjectImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IAgileObjectImpl.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; namespace WindowsRuntime.InteropServices; @@ -11,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// The IAgileObject implementation for managed types. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class IAgileObjectImpl { /// @@ -26,4 +21,4 @@ public static nint Vtable [MethodImpl(MethodImplOptions.AggressiveInlining)] get => IUnknownImpl.Vtable; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IInspectableImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IInspectableImpl.cs index 27d6f3f97a..d52635c326 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IInspectableImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IInspectableImpl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Foundation; @@ -15,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// The IInspectable implementation for managed types. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IInspectableImpl { /// @@ -123,4 +119,4 @@ private static HRESULT GetTrustLevel(void* thisPtr, TrustLevel* trustLevel) return WellKnownErrorCodes.S_OK; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IMarshalImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IMarshalImpl.cs index be7ccae012..6e76109515 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IMarshalImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IMarshalImpl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime.InteropServices.Marshalling; @@ -13,10 +12,7 @@ namespace WindowsRuntime.InteropServices; /// The IMarshal implementation for managed types. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe partial class IMarshalImpl { /// @@ -171,4 +167,4 @@ private static HRESULT DisconnectObject(void* thisPtr, uint dwReserved) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(ex); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IPropertyValueImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IPropertyValueImpl.cs index 02c704fcc1..a8c298a131 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IPropertyValueImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IPropertyValueImpl.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - #pragma warning disable IDE0060, IDE1006 namespace WindowsRuntime.InteropServices; @@ -16,8 +13,5 @@ namespace WindowsRuntime.InteropServices; /// This type provides shared paths for some implementations, and then some specific full implementations. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] -public static partial class IPropertyValueImpl; \ No newline at end of file +[WindowsRuntimeImplementationOnlyMember] +public static partial class IPropertyValueImpl; diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IReferenceImpl.Int32Enum.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IReferenceImpl.Int32Enum.cs index 52be173fe0..7af337570a 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IReferenceImpl.Int32Enum.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IReferenceImpl.Int32Enum.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime.InteropServices.Marshalling; @@ -16,10 +15,7 @@ namespace WindowsRuntime.InteropServices; /// The IReference`1 implementation for managed types that can share an implementation. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe partial class IReferenceImpl { /// @@ -73,4 +69,4 @@ public static HRESULT get_Value(void* thisPtr, int* result) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IStringableImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IStringableImpl.cs index a8db72502b..207467dfcf 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IStringableImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IStringableImpl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WindowsRuntime.InteropServices.Marshalling; @@ -14,10 +13,7 @@ namespace WindowsRuntime.InteropServices; /// The IStringable implementation for managed types. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IStringableImpl { /// @@ -64,4 +60,4 @@ private static HRESULT ToString(void* thisPtr, HSTRING* value) return RestrictedErrorInfoExceptionMarshaller.ConvertToUnmanaged(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IUnknownImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IUnknownImpl.cs index 97fc2ddb15..6b999751c9 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IUnknownImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IUnknownImpl.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -14,10 +12,7 @@ namespace WindowsRuntime.InteropServices; /// The IUnknown implementation for managed types. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IUnknownImpl { /// @@ -49,4 +44,4 @@ public static nint Vtable [MethodImpl(MethodImplOptions.AggressiveInlining)] get => (nint)Unsafe.AsPointer(in Vftbl); } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IWeakReferenceSourceImpl.cs b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IWeakReferenceSourceImpl.cs index 7c4204eb8b..746c7067c0 100644 --- a/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IWeakReferenceSourceImpl.cs +++ b/src/WinRT.Runtime2/InteropServices/ProjectionImpls/IWeakReferenceSourceImpl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; @@ -14,10 +13,7 @@ namespace WindowsRuntime.InteropServices; /// The IWeakReferenceSource implementation for managed types. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IWeakReferenceSourceImpl { /// @@ -69,4 +65,4 @@ private static HRESULT GetWeakReference(void* thisPtr, void** weakReference) return e.HResult; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/Streams/IStorageFolderHandleAccessMethods.cs b/src/WinRT.Runtime2/InteropServices/Streams/IStorageFolderHandleAccessMethods.cs index 61e8fadcc2..5f76fe2255 100644 --- a/src/WinRT.Runtime2/InteropServices/Streams/IStorageFolderHandleAccessMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Streams/IStorageFolderHandleAccessMethods.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.IO; using Microsoft.Win32.SafeHandles; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// Provides methods for interacting with the IStorageFolderHandleAccess COM interface. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IStorageFolderHandleAccessMethods { /// diff --git a/src/WinRT.Runtime2/InteropServices/Streams/IStorageItemHandleAccessMethods.cs b/src/WinRT.Runtime2/InteropServices/Streams/IStorageItemHandleAccessMethods.cs index ac6b3d3332..37383d3159 100644 --- a/src/WinRT.Runtime2/InteropServices/Streams/IStorageItemHandleAccessMethods.cs +++ b/src/WinRT.Runtime2/InteropServices/Streams/IStorageItemHandleAccessMethods.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.IO; using Microsoft.Win32.SafeHandles; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// Provides methods for interacting with the IStorageItemHandleAccess COM interface. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class IStorageItemHandleAccessMethods { /// diff --git a/src/WinRT.Runtime2/InteropServices/Streams/WindowsRuntimeIOHelpers.cs b/src/WinRT.Runtime2/InteropServices/Streams/WindowsRuntimeIOHelpers.cs index 07368a74ae..084787b0c2 100644 --- a/src/WinRT.Runtime2/InteropServices/Streams/WindowsRuntimeIOHelpers.cs +++ b/src/WinRT.Runtime2/InteropServices/Streams/WindowsRuntimeIOHelpers.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Runtime.ExceptionServices; @@ -13,10 +12,7 @@ namespace Windows.Storage.Streams; /// /// Helpers for working with Windows Runtime I/O operations. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class WindowsRuntimeIOHelpers { /// diff --git a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs index 81ce3f8650..dfddd5369b 100644 --- a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs +++ b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// @@ -13,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// This type is only meant to be used as type map group for APIs. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class DynamicInterfaceCastableImplementationTypeMapGroup { /// @@ -25,4 +19,4 @@ public abstract class DynamicInterfaceCastableImplementationTypeMapGroup private DynamicInterfaceCastableImplementationTypeMapGroup() { } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs index 3d14def610..b124e507a5 100644 --- a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs +++ b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; - namespace WindowsRuntime.InteropServices; /// @@ -12,10 +9,7 @@ namespace WindowsRuntime.InteropServices; /// /// This type is only meant to be used as type map group for APIs. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeComWrappersTypeMapGroup { /// @@ -24,4 +18,4 @@ public abstract class WindowsRuntimeComWrappersTypeMapGroup private WindowsRuntimeComWrappersTypeMapGroup() { } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs index 59b512bf8c..31b2121757 100644 --- a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs +++ b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; namespace WindowsRuntime.InteropServices; @@ -12,10 +11,7 @@ namespace WindowsRuntime.InteropServices; /// /// This type is only meant to be used as type map group for APIs. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeMetadataTypeMapGroup { /// @@ -24,4 +20,4 @@ public abstract class WindowsRuntimeMetadataTypeMapGroup private WindowsRuntimeMetadataTypeMapGroup() { } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs index 44ada5a809..ca36198485 100644 --- a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs +++ b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs @@ -10,10 +10,7 @@ namespace WindowsRuntime.InteropServices; /// /// IIDs for well known projected WinRT interfaces. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class WellKnownInterfaceIIDs { /// The IID for IUnknown. diff --git a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt index e4c74fb22a..b730a857d1 100644 --- a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt +++ b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt @@ -14,10 +14,7 @@ namespace WindowsRuntime.InteropServices; /// /// IIDs for well known projected WinRT interfaces. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static class WellKnownInterfaceIIDs { <# diff --git a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs index 0308eacd46..7f8f448bd6 100644 --- a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs +++ b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -20,10 +19,7 @@ namespace WindowsRuntime.InteropServices; /// the code will throw . It is the caller's responsibility /// to validate inputs before calling any method in this class. /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public static unsafe class WindowsRuntimeComWrappersMarshal { /// @@ -249,4 +245,4 @@ public static WindowsRuntimeObjectReference UnwrapObjectReferenceUnsafe(WindowsR { return value.NativeObjectReference; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncAction.cs b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncAction.cs index b6720c55fb..2390c3a901 100644 --- a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncAction.cs +++ b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncAction.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using Windows.Foundation; @@ -53,10 +52,7 @@ WindowsRuntimeObjectReference InitializeIAsyncInfoObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; public AsyncActionCompletedHandler? Completed @@ -105,12 +101,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInter } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncActionWithProgress{TProgress}.cs b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncActionWithProgress{TProgress}.cs index 7f192a9749..8e3a2946e9 100644 --- a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncActionWithProgress{TProgress}.cs +++ b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncActionWithProgress{TProgress}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using ABI.Windows.Foundation; @@ -18,10 +17,7 @@ namespace WindowsRuntime; /// The implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeAsyncActionWithProgress : WindowsRuntimeObject, IAsyncActionWithProgress, IWindowsRuntimeInterface>, @@ -59,10 +55,7 @@ WindowsRuntimeObjectReference InitializeIAsyncInfoObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -119,12 +112,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInter } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperationWithProgress{TResult, TProgress}.cs b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperationWithProgress{TResult, TProgress}.cs index a248639770..9165191dff 100644 --- a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperationWithProgress{TResult, TProgress}.cs +++ b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperationWithProgress{TResult, TProgress}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using ABI.Windows.Foundation; @@ -19,10 +18,7 @@ namespace WindowsRuntime; /// The implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeAsyncOperationWithProgress : WindowsRuntimeObject, IAsyncOperationWithProgress, IWindowsRuntimeInterface>, @@ -60,10 +56,7 @@ WindowsRuntimeObjectReference InitializeIAsyncInfoObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -120,12 +113,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInter } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperation{TResult}.cs b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperation{TResult}.cs index 86bdd28dc4..398841bb70 100644 --- a/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperation{TResult}.cs +++ b/src/WinRT.Runtime2/NativeObjects/AsyncInfo/WindowsRuntimeAsyncOperation{TResult}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using ABI.Windows.Foundation; @@ -18,10 +17,7 @@ namespace WindowsRuntime; /// The implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeAsyncOperation : WindowsRuntimeObject, IAsyncOperation, IWindowsRuntimeInterface>, @@ -59,10 +55,7 @@ WindowsRuntimeObjectReference InitializeIAsyncInfoObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -112,12 +105,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInter } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerable.cs b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerable.cs index 487915e3d2..f525dd873d 100644 --- a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerable.cs +++ b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerable.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; using WindowsRuntime.InteropServices; namespace WindowsRuntime; @@ -26,10 +25,7 @@ public WindowsRuntimeEnumerable(WindowsRuntimeObjectReference nativeObjectRefere } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -45,12 +41,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerator.cs b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerator.cs index dff273efc5..7ef06855c0 100644 --- a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerator.cs +++ b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeEnumerator.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using WindowsRuntime.InteropServices; @@ -39,10 +38,7 @@ public WindowsRuntimeEnumerator(WindowsRuntimeObjectReference nativeObjectRefere } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -113,12 +109,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeList.cs b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeList.cs index 66a402a897..3b06177474 100644 --- a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeList.cs +++ b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeList.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using WindowsRuntime.InteropServices; @@ -53,10 +52,7 @@ WindowsRuntimeObjectReference InitializeIIterableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -148,12 +144,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeReadOnlyList.cs b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeReadOnlyList.cs index b8278220c0..5034c07809 100644 --- a/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeReadOnlyList.cs +++ b/src/WinRT.Runtime2/NativeObjects/Bindables/WindowsRuntimeReadOnlyList.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using WindowsRuntime.InteropServices; @@ -57,10 +56,7 @@ WindowsRuntimeObjectReference InitializeIIterableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -76,12 +72,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryKeyCollection{TKey, TValue}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryKeyCollection{TKey, TValue}.cs index 41e3c32a57..d1d18a8de6 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryKeyCollection{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryKeyCollection{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; namespace WindowsRuntime; @@ -13,10 +12,7 @@ namespace WindowsRuntime; /// /// The type of keys in the dictionary. /// The type of values in the dictionary. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class DictionaryKeyCollection : ICollection { /// @@ -108,10 +104,7 @@ IEnumerator IEnumerable.GetEnumerator() /// /// The implementation for . /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public sealed class Enumerator : IEnumerator { /// @@ -158,4 +151,4 @@ public void Dispose() _enumerator.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryValueCollection{TKey, TValue}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryValueCollection{TKey, TValue}.cs index b382430ed2..ca42a4fc6a 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryValueCollection{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/DictionaryValueCollection{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; namespace WindowsRuntime; @@ -13,10 +12,7 @@ namespace WindowsRuntime; /// /// The type of keys in the dictionary. /// The type of values in the dictionary. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class DictionaryValueCollection : ICollection { /// @@ -117,10 +113,7 @@ IEnumerator IEnumerable.GetEnumerator() /// /// The implementation for . /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public sealed class Enumerator : IEnumerator { /// @@ -167,4 +160,4 @@ public void Dispose() _enumerator.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryKeyCollection{TKey, TValue}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryKeyCollection{TKey, TValue}.cs index 7b9ef3047a..b3a2c08ff6 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryKeyCollection{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryKeyCollection{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; namespace WindowsRuntime; @@ -13,10 +12,7 @@ namespace WindowsRuntime; /// /// The type of keys in the read-only dictionary. /// The type of values in the read-only dictionary. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class ReadOnlyDictionaryKeyCollection : IEnumerable { /// @@ -51,10 +47,7 @@ IEnumerator IEnumerable.GetEnumerator() /// /// The implementation for . /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public sealed class Enumerator : IEnumerator { /// @@ -101,4 +94,4 @@ public void Dispose() _enumerator.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryValueCollection{TKey, TValue}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryValueCollection{TKey, TValue}.cs index 00ed96700f..adc6b5fae9 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryValueCollection{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/ReadOnlyDictionaryValueCollection{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; namespace WindowsRuntime; @@ -13,10 +12,7 @@ namespace WindowsRuntime; /// /// The type of keys in the read-only dictionary. /// The type of values in the read-only dictionary. -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public sealed class ReadOnlyDictionaryValueCollection : IEnumerable { /// @@ -51,10 +47,7 @@ IEnumerator IEnumerable.GetEnumerator() /// /// The implementation for . /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public sealed class Enumerator : IEnumerator { /// @@ -101,4 +94,4 @@ public void Dispose() _enumerator.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeDictionary{TKey, TValue}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeDictionary{TKey, TValue}.cs index ebe4b6f5d6..6e3b584176 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeDictionary{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeDictionary{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading; @@ -22,10 +21,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IMap<K, V> implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeDictionary< TKey, TValue, @@ -83,10 +79,7 @@ WindowsRuntimeObjectReference InitializeIIterableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -205,12 +198,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerable{T}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerable{T}.cs index bc7d477c2f..a2c08d899e 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerable{T}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerable{T}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using WindowsRuntime.InteropServices; #pragma warning disable CA1816 @@ -18,10 +17,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IIterable<T> implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeEnumerable : WindowsRuntimeObject, IEnumerable, IWindowsRuntimeInterface> where TIIterableMethods : IIterableMethodsImpl { @@ -36,10 +32,7 @@ protected WindowsRuntimeEnumerable(WindowsRuntimeObjectReference nativeObjectRef } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -61,12 +54,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface>.GetI } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerator{T}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerator{T}.cs index dca11f3180..52da2cb0f8 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerator{T}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeEnumerator{T}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using WindowsRuntime.InteropServices; @@ -19,10 +18,7 @@ namespace WindowsRuntime; /// The implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeEnumerator : WindowsRuntimeObject, IEnumerator, IWindowsRuntimeInterface> where TIIteratorMethods : IIteratorMethodsImpl { @@ -47,10 +43,7 @@ protected WindowsRuntimeEnumerator(WindowsRuntimeObjectReference nativeObjectRef } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -142,12 +135,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface>.GetI } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeList{T}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeList{T}.cs index e77e03308a..fa7982393c 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeList{T}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeList{T}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using WindowsRuntime.InteropServices; @@ -22,10 +21,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IVector<T> implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeList< T, TIIterable, @@ -70,10 +66,7 @@ WindowsRuntimeObjectReference InitializeIIterableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -162,12 +155,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface>.GetI } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeMapChangedEventArgs{TKey}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeMapChangedEventArgs{TKey}.cs index fa97363bdb..f7a5e4c87b 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeMapChangedEventArgs{TKey}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeMapChangedEventArgs{TKey}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using Windows.Foundation.Collections; using WindowsRuntime.InteropServices; @@ -15,10 +14,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IMapChangedEventArgs<K> implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeMapChangedEventArgs : WindowsRuntimeObject, IMapChangedEventArgs, IWindowsRuntimeInterface> @@ -35,10 +31,7 @@ protected WindowsRuntimeMapChangedEventArgs(WindowsRuntimeObjectReference native } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -54,12 +47,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableMap{TKey, TValue}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableMap{TKey, TValue}.cs index a2b13bd635..710dad9b0e 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableMap{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableMap{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading; @@ -27,10 +26,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IObservableMap<K, V> factory type for event source objects. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeObservableMap< TKey, TValue, @@ -139,10 +135,7 @@ public event MapChangedEventHandler? MapChanged } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -267,12 +260,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableVector{T}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableVector{T}.cs index 40f4f76aad..05f9c31d7c 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableVector{T}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeObservableVector{T}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using Windows.Foundation.Collections; @@ -25,10 +24,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IObservableVector<T> factory type for event source objects. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeObservableVector< T, TIIterable, @@ -130,10 +126,7 @@ public event VectorChangedEventHandler? VectorChanged } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -228,12 +221,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface>.GetI } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyDictionary{TKey, TValue}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyDictionary{TKey, TValue}.cs index 6785c57edd..8ab484e01e 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyDictionary{TKey, TValue}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyDictionary{TKey, TValue}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading; @@ -22,10 +21,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IMapView<K, V> implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeReadOnlyDictionary< TKey, TValue, @@ -82,10 +78,7 @@ WindowsRuntimeObjectReference InitializeIIterableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -143,12 +136,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyList{T}.cs b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyList{T}.cs index 65abb113df..c9313be2ad 100644 --- a/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyList{T}.cs +++ b/src/WinRT.Runtime2/NativeObjects/Collections/WindowsRuntimeReadOnlyList{T}.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using WindowsRuntime.InteropServices; @@ -20,10 +19,7 @@ namespace WindowsRuntime; /// The Windows.Foundation.Collections.IVectorView<T> implementation type. /// [WindowsRuntimeManagedOnlyType] -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public abstract class WindowsRuntimeReadOnlyList< T, TIIterable, @@ -69,10 +65,7 @@ WindowsRuntimeObjectReference InitializeIIterableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal sealed override bool HasUnwrappableNativeObjectReference => true; /// @@ -106,12 +99,9 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface>.GetI } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected sealed override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/NativeObjects/Foundation/WindowsRuntimeMemoryBufferReference.cs b/src/WinRT.Runtime2/NativeObjects/Foundation/WindowsRuntimeMemoryBufferReference.cs index 62a2ecb4dd..417aaae08b 100644 --- a/src/WinRT.Runtime2/NativeObjects/Foundation/WindowsRuntimeMemoryBufferReference.cs +++ b/src/WinRT.Runtime2/NativeObjects/Foundation/WindowsRuntimeMemoryBufferReference.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using Windows.Foundation; @@ -60,10 +59,7 @@ WindowsRuntimeObjectReference InitializeIClosableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -88,10 +84,7 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; diff --git a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeBuffer.cs b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeBuffer.cs index 2f94efde9f..2b959ace6a 100644 --- a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeBuffer.cs +++ b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeBuffer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using Windows.Storage.Streams; using WindowsRuntime.InteropServices; @@ -26,10 +25,7 @@ public WindowsRuntimeBuffer(WindowsRuntimeObjectReference nativeObjectReference) } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -49,10 +45,7 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInterfac } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; diff --git a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeInputStream.cs b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeInputStream.cs index c3de4a7ae7..1c76cd2225 100644 --- a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeInputStream.cs +++ b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeInputStream.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using Windows.Foundation; @@ -54,10 +53,7 @@ WindowsRuntimeObjectReference InitializeIClosableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -85,10 +81,7 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; diff --git a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeOutputStream.cs b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeOutputStream.cs index 26d28c990a..ce5eb4dcb0 100644 --- a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeOutputStream.cs +++ b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeOutputStream.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using Windows.Foundation; @@ -52,10 +51,7 @@ WindowsRuntimeObjectReference InitializeIClosableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -89,10 +85,7 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; diff --git a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeRandomAccessStream.cs b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeRandomAccessStream.cs index fe50449890..a71efb0052 100644 --- a/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeRandomAccessStream.cs +++ b/src/WinRT.Runtime2/NativeObjects/Streams/WindowsRuntimeRandomAccessStream.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; using Windows.Foundation; @@ -98,10 +97,7 @@ WindowsRuntimeObjectReference InitializeIClosableObjectReference() } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// @@ -193,10 +189,7 @@ WindowsRuntimeObjectReferenceValue IWindowsRuntimeInterface.GetInte } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; diff --git a/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs b/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs deleted file mode 100644 index e871e10332..0000000000 --- a/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -namespace WindowsRuntime; - -/// -/// A type containing constants for various scenarios related to Windows Runtime functionality and projections. -/// -internal static class WindowsRuntimeConstants -{ - /// - /// A message for private implementation detail types. - /// - public const string PrivateImplementationDetailObsoleteMessage = - "This type or method is a private implementation detail, and it's only meant to be consumed by generated projections (produced by 'cswinrt.exe') " + - "and by generated interop code (produced by 'cswinrtinteropgen.exe'). Private implementation detail types are not considered part of the versioned " + - "API surface, and they are ignored when determining the assembly version following semantic versioning. Types might be modified or removed " + - "across any version change for 'WinRT.Runtime.dll', and using them in user code is undefined behavior and not supported."; - - /// - /// The diagnostic id for private implementation detail types. - /// - public const string PrivateImplementationDetailObsoleteDiagnosticId = "CSWINRT3001"; - - /// - /// The URL format for all custom diagnostics for CsWinRT. - /// - /// - /// This URL format assumes it will receive the diagnostic id as a parameter. - /// - public const string CsWinRTDiagnosticsUrlFormat = "https://aka.ms/cswinrt/errors/{0}"; -} \ No newline at end of file diff --git a/src/WinRT.Runtime2/WinRT.Runtime.csproj b/src/WinRT.Runtime2/WinRT.Runtime.csproj index 2b734d5c1d..110687d446 100644 --- a/src/WinRT.Runtime2/WinRT.Runtime.csproj +++ b/src/WinRT.Runtime2/WinRT.Runtime.csproj @@ -81,9 +81,6 @@ --> $(NoWarn);AD0001 - - $(NoWarn);CSWINRT3001 - true key.snk diff --git a/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs b/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs index 68a91a6597..97e5356d8f 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; -using System.ComponentModel; using WindowsRuntime; namespace Windows.Foundation; @@ -14,10 +12,7 @@ namespace Windows.Foundation; /// This type is required for ABI projection of Windows Runtime types, but marshalling it is not supported. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public enum TrustLevel { /// @@ -34,4 +29,4 @@ public enum TrustLevel /// The component requires the full privileges of the user. /// FullTrust = PartialTrust + 1 -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs b/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs index 963f9a2e00..f97858b6ce 100644 --- a/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs +++ b/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using WindowsRuntime; namespace Windows.UI.Xaml.Interop; @@ -14,10 +13,7 @@ namespace Windows.UI.Xaml.Interop; /// This type is required for ABI projection of the class, but marshalling it is not supported. /// /// -[Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] -[EditorBrowsable(EditorBrowsableState.Never)] +[WindowsRuntimeImplementationOnlyMember] public enum TypeKind { /// @@ -34,4 +30,4 @@ public enum TypeKind /// The type is a custom type declared by means other than WinMD. /// Custom -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/WindowsRuntimeInspectable.cs b/src/WinRT.Runtime2/WindowsRuntimeInspectable.cs index 862b2b3c95..e45420c30e 100644 --- a/src/WinRT.Runtime2/WindowsRuntimeInspectable.cs +++ b/src/WinRT.Runtime2/WindowsRuntimeInspectable.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ComponentModel; using WindowsRuntime.InteropServices; namespace WindowsRuntime; @@ -29,19 +28,13 @@ public WindowsRuntimeInspectable(WindowsRuntimeObjectReference nativeObjectRefer } /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal override bool HasUnwrappableNativeObjectReference => true; /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected override bool IsOverridableInterface(in Guid iid) { return false; } -} \ No newline at end of file +} diff --git a/src/WinRT.Runtime2/WindowsRuntimeObject.cs b/src/WinRT.Runtime2/WindowsRuntimeObject.cs index 0f634f2acb..ce1cf45e72 100644 --- a/src/WinRT.Runtime2/WindowsRuntimeObject.cs +++ b/src/WinRT.Runtime2/WindowsRuntimeObject.cs @@ -5,7 +5,6 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; @@ -50,10 +49,7 @@ public abstract unsafe class WindowsRuntimeObject : /// /// The inner Windows Runtime object reference to wrap in the current instance. /// Thrown if is . - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected WindowsRuntimeObject(WindowsRuntimeObjectReference nativeObjectReference) { ArgumentNullException.ThrowIfNull(nativeObjectReference); @@ -74,10 +70,7 @@ protected WindowsRuntimeObject(WindowsRuntimeObjectReference nativeObjectReferen /// /// This constructor should only be used when activating sealed types (both projected and user-defined types). /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected WindowsRuntimeObject( WindowsRuntimeActivationTypes.DerivedSealed _, WindowsRuntimeObjectReference activationFactoryObjectReference, @@ -120,10 +113,7 @@ protected WindowsRuntimeObject( /// /// This constructor should only be used when activating composable types (both projected and user-defined types). /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected WindowsRuntimeObject( WindowsRuntimeActivationTypes.DerivedComposed _, WindowsRuntimeObjectReference activationFactoryObjectReference, @@ -203,10 +193,7 @@ protected WindowsRuntimeObject( /// overload should be used instead, as that is more efficient in case the default signature is sufficient. /// /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected WindowsRuntimeObject( WindowsRuntimeActivationFactoryCallback.DerivedSealed activationFactoryCallback, in Guid iid, @@ -252,10 +239,7 @@ protected WindowsRuntimeObject( /// overload should be used instead, as that is more efficient in case the default signature is sufficient. /// /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected WindowsRuntimeObject( WindowsRuntimeActivationFactoryCallback.DerivedComposed activationFactoryCallback, in Guid iid, @@ -295,10 +279,7 @@ protected WindowsRuntimeObject( /// /// This object reference should point to an IInspectable native object. /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal WindowsRuntimeObjectReference NativeObjectReference { get; } /// @@ -308,10 +289,7 @@ protected WindowsRuntimeObject( /// This value is in aggregation scenarios, as the instance that should be marshalled /// to native is the derived managed type for the projected class, and not the inner object for the base type. /// - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected internal virtual bool HasUnwrappableNativeObjectReference => UnreachableException.Throw(); /// @@ -364,10 +342,7 @@ ConcurrentDictionary InitializeTypeHandleCache() /// /// The interface to check. /// Whether the interface represented by is an overridable interface for the current type. - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] protected virtual bool IsOverridableInterface(in Guid iid) { return UnreachableException.Throw(); @@ -379,10 +354,7 @@ protected virtual bool IsOverridableInterface(in Guid iid) /// The type handle for the interface to retrieve the object reference for. /// The resulting object. /// Thrown if the interface specified by is not implemented. - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public WindowsRuntimeObjectReference GetObjectReferenceForInterface(RuntimeTypeHandle interfaceType) { // Throw an exception if we couldn't resolve the interface reference @@ -411,10 +383,7 @@ static void ThrowArgumentException(RuntimeTypeHandle interfaceType) /// The type handle for the interface to retrieve the object reference for. /// The resulting object, if the interface could be retrieved. /// Whether could be retrieved successfully. - [Obsolete(WindowsRuntimeConstants.PrivateImplementationDetailObsoleteMessage, - DiagnosticId = WindowsRuntimeConstants.PrivateImplementationDetailObsoleteDiagnosticId, - UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] - [EditorBrowsable(EditorBrowsableState.Never)] + [WindowsRuntimeImplementationOnlyMember] public bool TryGetObjectReferenceForInterface(RuntimeTypeHandle interfaceType, [NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference) { return TryGetCastResult( @@ -958,4 +927,4 @@ public static NotSupportedException GetNotSupportedException() $"Support for 'IDynamicInterfaceCastable' is disabled (make sure that the 'CsWinRTEnableIDynamicInterfaceCastableSupport' property is not set to 'false'). " + $"In this configuration, runtime casts on Windows Runtime objects will only work if the managed object implements the target interface in metadata."); } -} \ No newline at end of file +} diff --git a/src/cswinrt/code_writers.h b/src/cswinrt/code_writers.h index a780db203e..d088af24d6 100644 --- a/src/cswinrt/code_writers.h +++ b/src/cswinrt/code_writers.h @@ -5212,8 +5212,6 @@ R"( w.write(R"(using System; using WindowsRuntime; -#pragma warning disable CSWINRT3001 - namespace ABI { %internal static class WindowsRuntimeDefaultInterfaces; @@ -5269,8 +5267,6 @@ namespace ABI w.write(R"(using System; using WindowsRuntime; -#pragma warning disable CSWINRT3001 - namespace ABI { %internal static class WindowsRuntimeExclusiveToInterfaces; diff --git a/src/cswinrt/strings/ComInteropExtensions.cs b/src/cswinrt/strings/ComInteropExtensions.cs index 644b8c94c1..36c6c27c90 100644 --- a/src/cswinrt/strings/ComInteropExtensions.cs +++ b/src/cswinrt/strings/ComInteropExtensions.cs @@ -25,8 +25,6 @@ // minimum Windows SDK that is currently supported. See this mapping // in the Windows SDK projection project. The two should be kept in sync. -#pragma warning disable CSWINRT3001 - using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/cswinrt/strings/InspectableVftbl.cs b/src/cswinrt/strings/InspectableVftbl.cs index 8a8f2053ba..d11da42786 100644 --- a/src/cswinrt/strings/InspectableVftbl.cs +++ b/src/cswinrt/strings/InspectableVftbl.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#pragma warning disable CSWINRT3001 // "Type or member '...' is a private implementation detail" - #if CSWINRT_REFERENCE_PROJECTION [assembly: WindowsRuntime.InteropServices.WindowsRuntimeReferenceAssembly] #else diff --git a/src/cswinrt/type_writers.h b/src/cswinrt/type_writers.h index fd02a17bc5..43715c4ff2 100644 --- a/src/cswinrt/type_writers.h +++ b/src/cswinrt/type_writers.h @@ -58,7 +58,6 @@ using static System.Runtime.InteropServices.ComWrappers; #pragma warning disable CS0169 // "The field '...' is never used" #pragma warning disable CS0649 // "Field '...' is never assigned to" #pragma warning disable CA2207, CA1063, CA1033, CA1001, CA2213 -#pragma warning disable CSWINRT3001 // "Type or member '...' is a private implementation detail" #pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type )", VERSION_STRING); From 85ce9972f15cf8a4616c3df667bb692ff10909f6 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 17 Jun 2026 08:53:39 -0700 Subject: [PATCH 2/8] Move WindowsRuntimeObject implementation to partial file (#2446) Extract the bulk of WindowsRuntimeObject's implementation into a new partial file (WindowsRuntimeObject.Impl.cs) and update WindowsRuntimeObject.cs to be a partial declaration. The change relocates constructors, caching fields, dynamic cast/QueryInterface logic, virtual method table helpers, and exception stubs into the new file while removing now-unneeded usings from the original file. This refactor preserves existing behavior but improves code organization and maintainability by separating surface declaration from detailed implementation. --- .../WindowsRuntimeObject.Impl.cs | 922 ++++++++++++++++++ src/WinRT.Runtime2/WindowsRuntimeObject.cs | 896 +---------------- 2 files changed, 927 insertions(+), 891 deletions(-) create mode 100644 src/WinRT.Runtime2/WindowsRuntimeObject.Impl.cs diff --git a/src/WinRT.Runtime2/WindowsRuntimeObject.Impl.cs b/src/WinRT.Runtime2/WindowsRuntimeObject.Impl.cs new file mode 100644 index 0000000000..a27bf2368d --- /dev/null +++ b/src/WinRT.Runtime2/WindowsRuntimeObject.Impl.cs @@ -0,0 +1,922 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using System.Threading; +using WindowsRuntime.InteropServices; + +#pragma warning disable IDE0046 + +namespace WindowsRuntime; + +/// +public unsafe partial class WindowsRuntimeObject +{ + /// + /// The lazy-loaded, cached object reference for IInspectable for the current object. + /// + /// + /// This is used when marshalling projected types as 'object'. Having a dedicated field to be able + /// to do this efficiently is worth it, as in some important scenarios (eg. XAML) it is extremely + /// common to have Windows Runtime APIs just taking 'object' as a parameter. We would not want + /// to constantly have to do 'QueryInterface' calls in those cases in each marshalling stub. + /// + private volatile WindowsRuntimeObjectReference? _inspectableObjectReference; + + /// + /// The lazy-loaded cache of additional data associated to type handles. + /// + private volatile ConcurrentDictionary? _typeHandleCache; + + /// + /// Creates a instance with the specified parameters. + /// + /// The inner Windows Runtime object reference to wrap in the current instance. + /// Thrown if is . + [WindowsRuntimeImplementationOnlyMember] + protected WindowsRuntimeObject(WindowsRuntimeObjectReference nativeObjectReference) + { + ArgumentNullException.ThrowIfNull(nativeObjectReference); + + NativeObjectReference = nativeObjectReference; + } + + /// + /// Creates a instance with the specified parameters for sealed scenarios. + /// + /// Marker parameter used to select this constructor for sealed types (unused). + /// The for the IActivationFactory instance. + /// The IID of the default interface for the Windows Runtime class being constructed. + /// The value available in metadata for the type being marshalled. + /// Thrown if is . + /// Thrown if has been disposed. + /// Thrown if there's any errors when activating the underlying native object. + /// + /// This constructor should only be used when activating sealed types (both projected and user-defined types). + /// + [WindowsRuntimeImplementationOnlyMember] + protected WindowsRuntimeObject( + WindowsRuntimeActivationTypes.DerivedSealed _, + WindowsRuntimeObjectReference activationFactoryObjectReference, + in Guid iid, + CreateObjectReferenceMarshalingType marshalingType) + { + ArgumentNullException.ThrowIfNull(activationFactoryObjectReference); + + // This constructor is only meant to be used for sealed types, so there's never a non-delegating (inner) return value. + // See additional notes in the overload below for more details about how and when that parameter is necessary. + WindowsRuntimeActivationHelper.ActivateInstanceUnsafe( + activationFactoryObjectReference: activationFactoryObjectReference, + defaultInterface: out void* defaultInterface); + + // The inner interface pointer isn't used for non-composable types, so we just pass 'null' + void* innerInterface = null; + + // Initialize a 'WindowsRuntimeObjectReference' for the current native objects and the managed instance we're + // constructing. This will also take care of registering things with 'ComWrappers', and setting up all the + // reference tracker infrastructure, in case the native object implements the 'IReferenceTracker' interface. + NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( + isAggregation: false, + thisInstance: this, + newInstanceUnknown: ref defaultInterface, + innerInstanceUnknown: ref innerInterface, + newInstanceIid: in iid, + marshalingType: marshalingType); + } + + /// + /// Creates a instance with the specified parameters for composed scenarios. + /// + /// Marker parameter used to select this constructor for composed types (unused). + /// The for the IActivationFactory instance. + /// The IID of the default interface for the Windows Runtime class being constructed. + /// The value available in metadata for the type being marshalled. + /// Thrown if is . + /// Thrown if has been disposed. + /// Thrown if there's any errors when activating the underlying native object. + /// + /// This constructor should only be used when activating composable types (both projected and user-defined types). + /// + [WindowsRuntimeImplementationOnlyMember] + protected WindowsRuntimeObject( + WindowsRuntimeActivationTypes.DerivedComposed _, + WindowsRuntimeObjectReference activationFactoryObjectReference, + in Guid iid, + CreateObjectReferenceMarshalingType marshalingType) + { + ArgumentNullException.ThrowIfNull(activationFactoryObjectReference); + + bool hasUnwrappableNativeObjectReference = HasUnwrappableNativeObjectReference; + + // Activate the instance for the composition scenario. This constructor is only used when instantiating + // Windows Runtime composable types (either projected types, or user-defined types deriving from one). + // However, depending on which case it is, the activation is executed slightly differently: + // + // 1) Activation for composition: this happens when activating a user-defined type that derives from a + // projected composable Windows Runtime type. In this case, the managed object being constructed will + // be the controlling 'IInspectable' instance, which is passed as the 'baseInterface' parameter. + // The returned 'innerInterface' will be used to invoke methods on the base interfaces. + // 2) Standalone activation: this happens when activating a composable type directly (eg. 'Button'). In + // this case, 'baseInterface' will be 'null', as there is no explicit controlling 'IInspectable' object + // that needs to be passed (the controlling instance is the same one as the object being constructed). + // Callers will ignore the returned 'innerInterface' as well in this example. + // + // For additional info, see: https://learn.microsoft.com/uwp/winrt-cref/winrt-type-system#composable-activation. + WindowsRuntimeActivationHelper.ActivateInstanceUnsafe( + activationFactoryObjectReference: activationFactoryObjectReference, + baseInterface: hasUnwrappableNativeObjectReference ? null : this, + innerInterface: out void* innerInterface, + defaultInterface: out void* defaultInterface); + + // Initialize a 'WindowsRuntimeObjectReference' for the current native objects and the managed instance we're + // constructing. This will also take care of registering things with 'ComWrappers', and setting up all the + // reference tracker infrastructure, in case the native object implements the 'IReferenceTracker' interface. + NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( + isAggregation: !hasUnwrappableNativeObjectReference, + thisInstance: this, + newInstanceUnknown: ref defaultInterface, + innerInstanceUnknown: ref innerInterface, + newInstanceIid: in iid, + marshalingType: marshalingType); + + // Optimization: if we are activating the current type for composition, then the returned object reference + // will wrap the 'IInspectable' pointer for the controlling instance (ie. 'innerInterface'). In this case, + // we can assign it to the cached 'IInspectable' object reference as well, since that would represent the + // exact same interface pointer. This entirley skips allocating that object reference in the future, if + // the instance being constructed were to be marshalled as 'IInspectable' (ie. as 'object') to native. We + // can assign the field directly rather than the property, to avoid doing a 'cmpxchg' operation here. That + // is not needed at this point anyway, as we're constructing the object, so no other thread can access it. + // + // We can also perform a similar optimization when activating types in standalone mode. If we are activating + // not for composition, then 'NativeObjectReference' would be wrapping the default interface pointer for the + // current type, meaning that it can be copied to the field caching that interface as well. We just can't do + // that in this base constructor though, as all the default interface fields are generated in each derived + // projected types. That optimization can be done right after the call to the base constructor, in each type. + if (!hasUnwrappableNativeObjectReference) + { + _inspectableObjectReference = NativeObjectReference; + } + } + + /// + /// Creates a instance with the specified parameters for sealed scenarios. + /// + /// The instance to delegate activation to. + /// The IID of the default interface for the Windows Runtime class being constructed. + /// The value available in metadata for the type being marshalled. + /// The additional parameters to provide to . + /// Thrown if is . + /// Thrown if there's any errors when activating the underlying native object. + /// + /// + /// This constructor should only be used when activating sealed types (both projected and user-defined types). + /// + /// + /// Additionally, this constructor is only meant to be used when additional custom parameters are required to invoke the target factory method. If no additional + /// parameters are needed, the + /// overload should be used instead, as that is more efficient in case the default signature is sufficient. + /// + /// + [WindowsRuntimeImplementationOnlyMember] + protected WindowsRuntimeObject( + WindowsRuntimeActivationFactoryCallback.DerivedSealed activationFactoryCallback, + in Guid iid, + CreateObjectReferenceMarshalingType marshalingType, + WindowsRuntimeActivationArgsReference additionalParameters) + { + ArgumentNullException.ThrowIfNull(activationFactoryCallback); + + // Delegate to the activation factory callback (see detailed explanation above) + activationFactoryCallback.Invoke( + additionalParameters: additionalParameters, + defaultInterface: out void* defaultInterface); + + // The inner interface pointer isn't used for non-composable types, so we just pass 'null' + void* innerInterface = null; + + // Initialize the 'WindowsRuntimeObjectReference' for the default interface (same as above) + NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( + isAggregation: false, + thisInstance: this, + newInstanceUnknown: ref defaultInterface, + innerInstanceUnknown: ref innerInterface, + newInstanceIid: in iid, + marshalingType: marshalingType); + } + + /// + /// Creates a instance with the specified parameters for composed scenarios. + /// + /// The instance to delegate activation to. + /// The IID of the default interface for the Windows Runtime class being constructed. + /// The value available in metadata for the type being marshalled. + /// The additional parameters to provide to . + /// Thrown if is . + /// Thrown if there's any errors when activating the underlying native object. + /// + /// + /// This constructor should only be used when activating composable types (both projected and user-defined types). + /// + /// + /// Additionally, this constructor is only meant to be used when additional custom parameters are required to invoke the target factory method. If no additional + /// parameters are needed, the + /// overload should be used instead, as that is more efficient in case the default signature is sufficient. + /// + /// + [WindowsRuntimeImplementationOnlyMember] + protected WindowsRuntimeObject( + WindowsRuntimeActivationFactoryCallback.DerivedComposed activationFactoryCallback, + in Guid iid, + CreateObjectReferenceMarshalingType marshalingType, + WindowsRuntimeActivationArgsReference additionalParameters) + { + ArgumentNullException.ThrowIfNull(activationFactoryCallback); + + bool hasUnwrappableNativeObjectReference = HasUnwrappableNativeObjectReference; + + // Delegate to the activation factory callback (see detailed explanation above) + activationFactoryCallback.Invoke( + additionalParameters: additionalParameters, + baseInterface: hasUnwrappableNativeObjectReference ? null : this, + innerInterface: out void* innerInterface, + defaultInterface: out void* defaultInterface); + + // Initialize a 'WindowsRuntimeObjectReference' object (see detailed explanation above) + NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( + isAggregation: !hasUnwrappableNativeObjectReference, + thisInstance: this, + newInstanceUnknown: ref defaultInterface, + innerInstanceUnknown: ref innerInterface, + newInstanceIid: in iid, + marshalingType: marshalingType); + + // Optimization: pre-cache the inspectable object reference if possible (see detailed explanation above) + if (!hasUnwrappableNativeObjectReference) + { + _inspectableObjectReference = NativeObjectReference; + } + } + + /// + /// Gets the inner Windows Runtime object reference for the current instance. + /// + /// + /// This object reference should point to an IInspectable native object. + /// + [WindowsRuntimeImplementationOnlyMember] + protected internal WindowsRuntimeObjectReference NativeObjectReference { get; } + + /// + /// Gets a value indicating whether the current instance has an unwrappable native object reference. + /// + /// + /// This value is in aggregation scenarios, as the instance that should be marshalled + /// to native is the derived managed type for the projected class, and not the inner object for the base type. + /// + [WindowsRuntimeImplementationOnlyMember] + protected internal virtual bool HasUnwrappableNativeObjectReference => UnreachableException.Throw(); + + /// + /// Gets the lazy-loaded, cached object reference for IInspectable for the current object. + /// + internal WindowsRuntimeObjectReference InspectableObjectReference + { + get + { + [MethodImpl(MethodImplOptions.NoInlining)] + WindowsRuntimeObjectReference InitializeInspectableObjectReference() + { + _ = Interlocked.CompareExchange( + location1: ref _inspectableObjectReference, + value: NativeObjectReference.As(in WellKnownWindowsInterfaceIIDs.IID_IInspectable), + comparand: null); + + return _inspectableObjectReference; + } + + return _inspectableObjectReference ?? InitializeInspectableObjectReference(); + } + init => _inspectableObjectReference = value; + } + + /// + /// Gets the lazy-loaded cache of additional data associated to type handles. + /// + private ConcurrentDictionary TypeHandleCache + { + get + { + [MethodImpl(MethodImplOptions.NoInlining)] + ConcurrentDictionary InitializeTypeHandleCache() + { + _ = Interlocked.CompareExchange( + location1: ref _typeHandleCache, + value: new ConcurrentDictionary(concurrencyLevel: 1, capacity: 16), + comparand: null); + + return _typeHandleCache; + } + + return _typeHandleCache ?? InitializeTypeHandleCache(); + } + } + + /// + /// Determines whether a given interface is an overridable interface for the current type. + /// + /// The interface to check. + /// Whether the interface represented by is an overridable interface for the current type. + [WindowsRuntimeImplementationOnlyMember] + protected virtual bool IsOverridableInterface(in Guid iid) + { + return UnreachableException.Throw(); + } + + /// + /// Retrieves a object for the specified interface. + /// + /// The type handle for the interface to retrieve the object reference for. + /// The resulting object. + /// Thrown if the interface specified by is not implemented. + [WindowsRuntimeImplementationOnlyMember] + public WindowsRuntimeObjectReference GetObjectReferenceForInterface(RuntimeTypeHandle interfaceType) + { + // Throw an exception if we couldn't resolve the interface reference + if (!TryGetCastResult( + interfaceType: interfaceType, + implementationType: out _, + interfaceReference: out WindowsRuntimeObjectReference? interfaceReference)) + { + [DoesNotReturn] + [StackTraceHidden] + static void ThrowArgumentException(RuntimeTypeHandle interfaceType) + { + throw new ArgumentException( + $"The type '{Type.GetTypeFromHandle(interfaceType)}' cannot be used to retrieve an object reference for the current object."); + } + + ThrowArgumentException(interfaceType); + } + + return interfaceReference; + } + + /// + /// Tries to retrieve a object for the specified interface. + /// + /// The type handle for the interface to retrieve the object reference for. + /// The resulting object, if the interface could be retrieved. + /// Whether could be retrieved successfully. + [WindowsRuntimeImplementationOnlyMember] + public bool TryGetObjectReferenceForInterface(RuntimeTypeHandle interfaceType, [NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference) + { + return TryGetCastResult( + interfaceType: interfaceType, + implementationType: out _, + interfaceReference: out interfaceReference); + } + + /// + /// Retrieves a object for the interface. + /// + /// The resulting object. + /// Thrown if the interface is not implemented. + internal WindowsRuntimeObjectReference GetObjectReferenceForIEnumerableInterfaceInstance() + { + // Throw an exception if we couldn't resolve the 'IEnumerable' interface reference + if (!TryGetObjectReferenceForIEnumerableInterfaceInstance(out WindowsRuntimeObjectReference? interfaceReference)) + { + [DoesNotReturn] + [StackTraceHidden] + static void ThrowArgumentException() + { + throw new ArgumentException( + $"The type '{typeof(IEnumerable)}' cannot be used to retrieve an object reference for the current object."); + } + + ThrowArgumentException(); + } + + return interfaceReference; + } + + /// + /// Tries to retrieve a object for the interface. + /// + /// The resulting object, if the interface could be retrieved. + /// Whether could be retrieved successfully. + internal bool TryGetObjectReferenceForIEnumerableInterfaceInstance([NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference) + { + ConcurrentDictionary typeHandleCache = TypeHandleCache; + + // If we have a cached value, return it immediately to skip further lookups. We use + // the 'IEnumerableInstance' type to cache the specialized object reference in this + // scenario. The only thing that matters is no other code will try this same lookup. + if (typeHandleCache.TryGetValue(typeof(IEnumerableInstance).TypeHandle, out object? value)) + { + switch (value) + { + case DynamicInterfaceCastableResult castResult: + interfaceReference = castResult.InterfaceObjectReference; + return true; + default: + interfaceReference = null; + return false; + } + } + + // Go through the cached object references for dynamic casts to try to find a compatible one + foreach (KeyValuePair typeHandleEntry in TypeHandleCache) + { + // Resolve the interface type (this can never be 'null', as we're the only ones adding elements) + Type interfaceType = Type.GetTypeFromHandle(typeHandleEntry.Key)!; + + // Scan the cached entries, and skip all the ones that are not some 'IEnumerable' instantiation + if (!(interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))) + { + continue; + } + + // Also skip all 'IEnumerable' instantiations that are not actually implemented by the native object + if (typeHandleEntry.Value is not DynamicInterfaceCastableResult result) + { + continue; + } + + // Try to cache the cast result that we retrieved, but we can't assume we'll win the race here. + // If we lost and the result is different, that's fine, we'll just use that one instead. This + // also guarantees that even if we have race conditions, the same implementation is always used. + object cachedResult = typeHandleCache.GetOrAdd(typeof(IEnumerableInstance).TypeHandle, result); + + // Return the resulting object reference from the cached result. Note that in the event of a lost + // race, this might possibly result in us reporting a failure even though this thread had actually + // found an object reference. This is intentional, as we want to make sure that we don't return + // different implementations at different callsites, as that could lead to hard to debug problems. + // In practice, this doesn't matter, as we always expect 'IEnumerable' casts to be done after some + // other cast to 'IEnumerable'. The main scenario where this happens is within LINQ operations. + switch (cachedResult) + { + case DynamicInterfaceCastableResult castResult: + interfaceReference = castResult.InterfaceObjectReference; + return true; + default: + interfaceReference = null; + return false; + } + } + + // Cache the failed cast, but still validate the return in case of an unlikely race against an 'IEnumerable' cast + object cachedFailure = typeHandleCache.GetOrAdd(typeof(IEnumerableInstance).TypeHandle, DynamicInterfaceCastFailure.Instance); + + // Switch on the cached failure as above, just in case we somehow still got a valid result on another thread first + switch (cachedFailure) + { + case DynamicInterfaceCastableResult castResult: + interfaceReference = castResult.InterfaceObjectReference; + return true; + default: + interfaceReference = null; + return false; + } + } + + /// + private static RuntimeTypeHandle GetInterfaceImplementation(RuntimeTypeHandle interfaceType) + { + // Fail immediately if the feature switch is disabled, to ensure all related code can be trimmed + if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) + { + throw WindowsRuntimeObjectExceptions.GetNotSupportedException(); + } + + Type type = Type.GetTypeFromHandle(interfaceType)!; + + // If we can resolve the implementation type through the Windows Runtime infrastructure, return it + if (DynamicInterfaceCastableImplementationInfo.TryGetInfo( + interfaceType: type, + info: out DynamicInterfaceCastableImplementationInfo? implementationInfo)) + { + return implementationInfo.ImplementationType.TypeHandle; + } + + // If the interface is a generated COM interface, return the implementation type from there + if (StrategyBasedComWrappers.DefaultIUnknownInterfaceDetailsStrategy.GetIUnknownDerivedDetails(interfaceType) is IIUnknownDerivedDetails details) + { + return details.Implementation.TypeHandle; + } + + // Otherwise we don't have an implementation type, so this cast can't possibly succeed + return default; + } + + /// + private bool IsInterfaceImplemented(RuntimeTypeHandle interfaceType, bool throwIfNotImplemented) + { + // Early feature switch check to improve trimming (same as above) + if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) + { + // If we should throw, explicitly throw the same exception as from 'GetInterfaceImplementation', rather than + // just returning 'false' and letting the runtime throw an 'InvalidCastException'. This allows developers to + // more easily understand why a given runtime cast might be failing under different configurations. + if (throwIfNotImplemented) + { + throw WindowsRuntimeObjectExceptions.GetNotSupportedException(); + } + + return false; + } + + return TryGetCastResult( + interfaceType: interfaceType, + implementationType: out _, + interfaceReference: out _); + } + + /// + private VirtualMethodTableInfo GetVirtualMethodTableInfoForKey(Type type) + { + if (LookupGeneratedVTableInfo( + interfaceType: type.TypeHandle, + performTypeHandleCacheLookup: true, + throwOnQueryInterfaceFailure: true, + castResult: out GeneratedComInterfaceCastResult? castResult) is not CustomQueryInterfaceResult.Handled) + { + [DoesNotReturn] + [StackTraceHidden] + static void ThrowArgumentException(Type type) + { + throw new ArgumentException( + $"The type '{type}' cannot be used to resolve a virtual method table for the current object."); + } + + ThrowArgumentException(type); + } + + return new(castResult!.TableInfo.ThisPtr, castResult.TableInfo.Table); + } + + /// + private CustomQueryInterfaceResult GetInterface(ref Guid iid, out nint ppv) + { + // We explicitly don't handle overridable interfaces, as well as 'IInspectable' and 'IWeakReferenceSource'. + // This last one in particular must be ignored to avoid issues when an RCW object is used as a target + // for a 'WeakReference' object. Lastly, we also need to not handle this 'QueryInterface' request when + // 'NativeObjectReference' is 'null', which will be the case during initialization (because objects are + // constructed entirely from this base 'WindowsRuntimeObject' type). In that case, 'QueryInterface' calls + // will be coming for the outer instance from the inner one, where the outer calls 'GetInterface' first, + // and they wouldn't need to be handled anyway. + if (IsOverridableInterface(in iid) || + WellKnownWindowsInterfaceIIDs.IID_IInspectable == iid || + WellKnownWindowsInterfaceIIDs.IID_IWeakReferenceSource == iid || + NativeObjectReference is null) + { + ppv = default; + + return CustomQueryInterfaceResult.NotHandled; + } + + // Delegate the 'QueryInterface' call to the inner object reference + return NativeObjectReference.TryAsUnsafe(in iid, out ppv) + ? CustomQueryInterfaceResult.Handled + : CustomQueryInterfaceResult.NotHandled; + } + + /// + /// Tries to get an object reference without additional lookups. + /// + /// The input interface type. + /// The implementation type. + /// The for the interface. + /// Whether the cast was successfully retrieved. + /// + /// This method mirrors above, just with minor + /// differences to further optimize it for + /// and calls, where we + /// need the cast results. Any changes to either of these methods should be kept in sync. + /// + private bool TryGetCastResult( + RuntimeTypeHandle interfaceType, + [NotNullWhen(true)] out RuntimeTypeHandle implementationType, + [NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference) + { + ConcurrentDictionary typeHandleCache = TypeHandleCache; + + // If we have a cached value, return it immediately to skip further lookups + if (typeHandleCache.TryGetValue(interfaceType, out object? value)) + { + switch (value) + { + case DynamicInterfaceCastableResult castResult: + implementationType = castResult.ImplementationType.TypeHandle; + interfaceReference = castResult.InterfaceObjectReference; + return true; + case GeneratedComInterfaceCastResult castResult: + implementationType = castResult.TableInfo.ManagedType; + interfaceReference = castResult.InterfaceObjectReference; + return true; + default: + implementationType = default; + interfaceReference = null; + return false; + } + } + + // First, check for 'IDynamicInterfaceCastable' casts through the Windows Runtime infrastructure + CustomQueryInterfaceResult dynamicQueryInterfaceResult = LookupDynamicInterfaceCastableImplementationInfo( + interfaceType: interfaceType, + castResult: out DynamicInterfaceCastableResult? dynamicInterfaceCastableResult); + + // Return the appropriate result based on the 'QueryInterface' result, if handled + switch (dynamicQueryInterfaceResult) + { + case CustomQueryInterfaceResult.Handled: + implementationType = dynamicInterfaceCastableResult!.ImplementationType.TypeHandle; + interfaceReference = dynamicInterfaceCastableResult.InterfaceObjectReference; + return true; + case CustomQueryInterfaceResult.Failed: + goto Failure; + case CustomQueryInterfaceResult.NotHandled: + default: break; + } + + // Next, check to see if the target interface is a generated COM interface + CustomQueryInterfaceResult generatedQueryInterfaceResult = LookupGeneratedVTableInfo( + interfaceType: interfaceType, + performTypeHandleCacheLookup: false, + throwOnQueryInterfaceFailure: false, + castResult: out GeneratedComInterfaceCastResult? generatedComInterfaceCastResult); + + // Return the appropriate result for 'QueryInterface' (same as above) + switch (generatedQueryInterfaceResult) + { + case CustomQueryInterfaceResult.Handled: + implementationType = generatedComInterfaceCastResult!.TableInfo.ManagedType; + interfaceReference = generatedComInterfaceCastResult.InterfaceObjectReference; + return true; + case CustomQueryInterfaceResult.Failed: + case CustomQueryInterfaceResult.NotHandled: + default: break; + } + + Failure: + implementationType = default; + interfaceReference = null; + + // Before returning, cache the fact the cast failed, so future calls will be faster + _ = typeHandleCache.TryAdd(interfaceType, DynamicInterfaceCastFailure.Instance); + + return false; + } + + /// + /// Looks up whether the input interface type is implemented for an cast. + /// + /// The input interface type. + /// The resulting value, if the cast is successful. + /// A value representing the result of this dynamic cast lookup operation. + /// + /// When successful, this method will cache a value into . + /// + private CustomQueryInterfaceResult LookupDynamicInterfaceCastableImplementationInfo(RuntimeTypeHandle interfaceType, out DynamicInterfaceCastableResult? castResult) + { + castResult = null; + + // Also fail from here if the feature switch is disabled, to ensure that 'DynamicInterfaceCastableImplementationInfo' + // can fully be trimmed. In theory this path shouldn't be reachable if the feature is disabled, but this can help. + if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) + { + return CustomQueryInterfaceResult.Failed; + } + + Type type = Type.GetTypeFromHandle(interfaceType)!; + + // If we can't resolve the implementation info at all, the cast can't possibly succeed + if (!DynamicInterfaceCastableImplementationInfo.TryGetInfo( + interfaceType: type, + info: out DynamicInterfaceCastableImplementationInfo? implementationInfo)) + { + return CustomQueryInterfaceResult.NotHandled; + } + + WindowsRuntimeObjectReference? interfaceReference; + + // Special case generic interface types that can be implemented via multiple types. For instance, a cast to + // 'ICollection>' should succeed if the native objects implement 'IList>', + // but also if the native object implements 'IDictionary'. In these cases, we won't know which IID to use + // nor what actual implementation type to use (as it depends on what the native object implements), so we defer + // to the generated forwarder attribute to check that. + if (type.IsGenericType && ( + type.GetGenericTypeDefinition() == typeof(ICollection<>) || + type.GetGenericTypeDefinition() == typeof(IReadOnlyCollection<>)) && + type.GenericTypeArguments[0].IsGenericType && + type.GenericTypeArguments[0].GetGenericTypeDefinition() == typeof(KeyValuePair<,>)) + { + // Invoke 'IsInterfaceImplemented' on the implementation type, which will perform a series of calls + // to 'TryGetObjectReferenceForInterface' for all the compatible Windows Runtime interfaces. The + // resulting object references will be for the interface that actually exists on the native object. + // This interface shouldn't really be needed from this key for the lookup, but we still store it. + if (!implementationInfo.GetDynamicInterfaceCastableForwarder().IsInterfaceImplemented(this, out interfaceReference)) + { + return CustomQueryInterfaceResult.Failed; + } + } + else + { + // Try to cast to the IID specified by the interface, and stop if that failed. + // In this case we can just get the IID directly from the implementation type. + if (!NativeObjectReference.TryAs( + iid: implementationInfo.ImplementationType.GUID, + objectReference: out interfaceReference)) + { + return CustomQueryInterfaceResult.Failed; + } + } + + // Initialize the cache result to return to callers + castResult = new DynamicInterfaceCastableResult() + { + ImplementationType = implementationInfo.ImplementationType, + InterfaceObjectReference = interfaceReference + }; + + // Add the cast result to the cache, or get the updated value if we raced against another thread + object effectiveCastResult = TypeHandleCache.GetOrAdd(interfaceType, castResult); + + // If the result is different than the one we tried to add, it means we lost a race against another + // thread. In this case we just discard our object reference. The updated result is perfectly valid. + if (effectiveCastResult != castResult) + { + interfaceReference.Dispose(); + + castResult = (DynamicInterfaceCastableResult)effectiveCastResult; + } + + return CustomQueryInterfaceResult.Handled; + } + + /// + /// Looks up whether the input interface type is implemented for a generated COM interface cast. + /// + /// The input interface type. + /// Whether to lookup into first. + /// Whether to throw an exception of QueryInterface fails. + /// The resulting value, if the cast is successful. + /// A value representing the result of this dynamic cast lookup operation. + /// + /// When successful, this method will cache a value into . + /// + private CustomQueryInterfaceResult LookupGeneratedVTableInfo( + RuntimeTypeHandle interfaceType, + bool performTypeHandleCacheLookup, + bool throwOnQueryInterfaceFailure, + out GeneratedComInterfaceCastResult? castResult) + { + castResult = null; + + // Same trim-friendly check as above (see notes there) + if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) + { + return CustomQueryInterfaceResult.Failed; + } + + // We only do the lookup if the caller hasn't already done so + if (performTypeHandleCacheLookup && TypeHandleCache.TryGetValue(interfaceType, out object? typeHandleCacheValue)) + { + // Try to see if we have a cached table info, and if we do, we can stop here + if (typeHandleCacheValue is GeneratedComInterfaceCastResult cachedCastResult) + { + castResult = cachedCastResult; + + return CustomQueryInterfaceResult.Handled; + } + } + + // This method is specifically only for checking generated COM interfaces. If we can't + // resolve the 'IIUnknownDerivedDetails' value for the interface, we have nothing to do. + if (StrategyBasedComWrappers.DefaultIUnknownInterfaceDetailsStrategy.GetIUnknownDerivedDetails(interfaceType) is IIUnknownDerivedDetails details) + { + HRESULT hresult = NativeObjectReference.DerivedTryAsNative(details.Iid, out WindowsRuntimeObjectReference? interfaceReference); + + // If the 'QueryInterface' call failed, we know the interface can't possibly be implemented. + // Because the actual 'QueryInterface' failed, we also know there would be no point for the + // rest of the 'IDynamicInterfaceCastable' logic to run, as the cast can never succeed. + if (hresult.Failed) + { + // Throw only if requested by callers + if (throwOnQueryInterfaceFailure) + { + Marshal.ThrowExceptionForHR(hresult); + } + + return CustomQueryInterfaceResult.Failed; + } + + // Here we are intentionally getting the pointer without incrementing its reference count. + // The target native object will be kept alive by the cached 'WindowsRuntimeObjectReference'. + void* interfacePtr = interfaceReference!.GetThisPtrUnsafe(); + + // Initialize the cache result to return to callers + castResult = new GeneratedComInterfaceCastResult + { + TableInfo = new IIUnknownCacheStrategy.TableInfo() + { + ThisPtr = interfacePtr, + Table = *(void***)interfacePtr, + ManagedType = details.Implementation.TypeHandle + }, + InterfaceObjectReference = interfaceReference + }; + + // Try to add the cast result to the cache + object effectiveCastResult = TypeHandleCache.GetOrAdd(interfaceType, castResult); + + // If we lost a thread, dispose the reference and return the updated result we + // just retrieved from the cache. This is the same logic as for other casts. + if (effectiveCastResult != castResult) + { + interfaceReference.Dispose(); + + castResult = (GeneratedComInterfaceCastResult)effectiveCastResult; + } + + return CustomQueryInterfaceResult.Handled; + } + + return CustomQueryInterfaceResult.NotHandled; + } + + /// + /// A placeholder type for failed casts. + /// + private sealed class DynamicInterfaceCastFailure + { + /// + /// The singleton instance. + /// + public static readonly DynamicInterfaceCastFailure Instance = new(); + } + + /// + /// A type for successful generated COM interface casts. + /// + private sealed class GeneratedComInterfaceCastResult + { + /// + /// Gets the vaulue for the interface. + /// + public required IIUnknownCacheStrategy.TableInfo TableInfo { get; init; } + + /// + /// Gets the instance for the interface pointer. + /// + public required WindowsRuntimeObjectReference InterfaceObjectReference { get; init; } + } + + /// + /// A type for successful cast. + /// + private sealed class DynamicInterfaceCastableResult + { + /// + /// Gets the implementation type for the interface. + /// + public required Type ImplementationType { get; init; } + + /// + /// Gets the instance for the interface pointer. + /// + public required WindowsRuntimeObjectReference InterfaceObjectReference { get; init; } + } + + /// + /// A dummy type to use for caching adaptive object references in . + /// + private static class IEnumerableInstance; +} + +/// +/// Exception stubs for . +/// +file static class WindowsRuntimeObjectExceptions +{ + /// + /// Gets a if support for is disabled. + /// + [MethodImpl(MethodImplOptions.NoInlining)] + public static NotSupportedException GetNotSupportedException() + { + // We can't throw the exception from here like the other method above, because it causes + // a linker crash when publishing with Native AOT. We can update this once it's fixed. + throw new( + $"Support for 'IDynamicInterfaceCastable' is disabled (make sure that the 'CsWinRTEnableIDynamicInterfaceCastableSupport' property is not set to 'false'). " + + $"In this configuration, runtime casts on Windows Runtime objects will only work if the managed object implements the target interface in metadata."); + } +} diff --git a/src/WinRT.Runtime2/WindowsRuntimeObject.cs b/src/WinRT.Runtime2/WindowsRuntimeObject.cs index ce1cf45e72..8a3789452b 100644 --- a/src/WinRT.Runtime2/WindowsRuntimeObject.cs +++ b/src/WinRT.Runtime2/WindowsRuntimeObject.cs @@ -2,18 +2,8 @@ // Licensed under the MIT License. using System; -using System.Collections; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; -using System.Threading; -using WindowsRuntime.InteropServices; - -#pragma warning disable IDE0046 namespace WindowsRuntime; @@ -23,908 +13,32 @@ namespace WindowsRuntime; /// /// This type should only be used as a base type by generated projected types. /// -public abstract unsafe class WindowsRuntimeObject : +public abstract partial class WindowsRuntimeObject : IDynamicInterfaceCastable, IUnmanagedVirtualMethodTableProvider, ICustomQueryInterface { - /// - /// The lazy-loaded, cached object reference for IInspectable for the current object. - /// - /// - /// This is used when marshalling projected types as 'object'. Having a dedicated field to be able - /// to do this efficiently is worth it, as in some important scenarios (eg. XAML) it is extremely - /// common to have Windows Runtime APIs just taking 'object' as a parameter. We would not want - /// to constantly have to do 'QueryInterface' calls in those cases in each marshalling stub. - /// - private volatile WindowsRuntimeObjectReference? _inspectableObjectReference; - - /// - /// The lazy-loaded cache of additional data associated to type handles. - /// - private volatile ConcurrentDictionary? _typeHandleCache; - - /// - /// Creates a instance with the specified parameters. - /// - /// The inner Windows Runtime object reference to wrap in the current instance. - /// Thrown if is . - [WindowsRuntimeImplementationOnlyMember] - protected WindowsRuntimeObject(WindowsRuntimeObjectReference nativeObjectReference) - { - ArgumentNullException.ThrowIfNull(nativeObjectReference); - - NativeObjectReference = nativeObjectReference; - } - - /// - /// Creates a instance with the specified parameters for sealed scenarios. - /// - /// Marker parameter used to select this constructor for sealed types (unused). - /// The for the IActivationFactory instance. - /// The IID of the default interface for the Windows Runtime class being constructed. - /// The value available in metadata for the type being marshalled. - /// Thrown if is . - /// Thrown if has been disposed. - /// Thrown if there's any errors when activating the underlying native object. - /// - /// This constructor should only be used when activating sealed types (both projected and user-defined types). - /// - [WindowsRuntimeImplementationOnlyMember] - protected WindowsRuntimeObject( - WindowsRuntimeActivationTypes.DerivedSealed _, - WindowsRuntimeObjectReference activationFactoryObjectReference, - in Guid iid, - CreateObjectReferenceMarshalingType marshalingType) - { - ArgumentNullException.ThrowIfNull(activationFactoryObjectReference); - - // This constructor is only meant to be used for sealed types, so there's never a non-delegating (inner) return value. - // See additional notes in the overload below for more details about how and when that parameter is necessary. - WindowsRuntimeActivationHelper.ActivateInstanceUnsafe( - activationFactoryObjectReference: activationFactoryObjectReference, - defaultInterface: out void* defaultInterface); - - // The inner interface pointer isn't used for non-composable types, so we just pass 'null' - void* innerInterface = null; - - // Initialize a 'WindowsRuntimeObjectReference' for the current native objects and the managed instance we're - // constructing. This will also take care of registering things with 'ComWrappers', and setting up all the - // reference tracker infrastructure, in case the native object implements the 'IReferenceTracker' interface. - NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( - isAggregation: false, - thisInstance: this, - newInstanceUnknown: ref defaultInterface, - innerInstanceUnknown: ref innerInterface, - newInstanceIid: in iid, - marshalingType: marshalingType); - } - - /// - /// Creates a instance with the specified parameters for composed scenarios. - /// - /// Marker parameter used to select this constructor for composed types (unused). - /// The for the IActivationFactory instance. - /// The IID of the default interface for the Windows Runtime class being constructed. - /// The value available in metadata for the type being marshalled. - /// Thrown if is . - /// Thrown if has been disposed. - /// Thrown if there's any errors when activating the underlying native object. - /// - /// This constructor should only be used when activating composable types (both projected and user-defined types). - /// - [WindowsRuntimeImplementationOnlyMember] - protected WindowsRuntimeObject( - WindowsRuntimeActivationTypes.DerivedComposed _, - WindowsRuntimeObjectReference activationFactoryObjectReference, - in Guid iid, - CreateObjectReferenceMarshalingType marshalingType) - { - ArgumentNullException.ThrowIfNull(activationFactoryObjectReference); - - bool hasUnwrappableNativeObjectReference = HasUnwrappableNativeObjectReference; - - // Activate the instance for the composition scenario. This constructor is only used when instantiating - // Windows Runtime composable types (either projected types, or user-defined types deriving from one). - // However, depending on which case it is, the activation is executed slightly differently: - // - // 1) Activation for composition: this happens when activating a user-defined type that derives from a - // projected composable Windows Runtime type. In this case, the managed object being constructed will - // be the controlling 'IInspectable' instance, which is passed as the 'baseInterface' parameter. - // The returned 'innerInterface' will be used to invoke methods on the base interfaces. - // 2) Standalone activation: this happens when activating a composable type directly (eg. 'Button'). In - // this case, 'baseInterface' will be 'null', as there is no explicit controlling 'IInspectable' object - // that needs to be passed (the controlling instance is the same one as the object being constructed). - // Callers will ignore the returned 'innerInterface' as well in this example. - // - // For additional info, see: https://learn.microsoft.com/uwp/winrt-cref/winrt-type-system#composable-activation. - WindowsRuntimeActivationHelper.ActivateInstanceUnsafe( - activationFactoryObjectReference: activationFactoryObjectReference, - baseInterface: hasUnwrappableNativeObjectReference ? null : this, - innerInterface: out void* innerInterface, - defaultInterface: out void* defaultInterface); - - // Initialize a 'WindowsRuntimeObjectReference' for the current native objects and the managed instance we're - // constructing. This will also take care of registering things with 'ComWrappers', and setting up all the - // reference tracker infrastructure, in case the native object implements the 'IReferenceTracker' interface. - NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( - isAggregation: !hasUnwrappableNativeObjectReference, - thisInstance: this, - newInstanceUnknown: ref defaultInterface, - innerInstanceUnknown: ref innerInterface, - newInstanceIid: in iid, - marshalingType: marshalingType); - - // Optimization: if we are activating the current type for composition, then the returned object reference - // will wrap the 'IInspectable' pointer for the controlling instance (ie. 'innerInterface'). In this case, - // we can assign it to the cached 'IInspectable' object reference as well, since that would represent the - // exact same interface pointer. This entirley skips allocating that object reference in the future, if - // the instance being constructed were to be marshalled as 'IInspectable' (ie. as 'object') to native. We - // can assign the field directly rather than the property, to avoid doing a 'cmpxchg' operation here. That - // is not needed at this point anyway, as we're constructing the object, so no other thread can access it. - // - // We can also perform a similar optimization when activating types in standalone mode. If we are activating - // not for composition, then 'NativeObjectReference' would be wrapping the default interface pointer for the - // current type, meaning that it can be copied to the field caching that interface as well. We just can't do - // that in this base constructor though, as all the default interface fields are generated in each derived - // projected types. That optimization can be done right after the call to the base constructor, in each type. - if (!hasUnwrappableNativeObjectReference) - { - _inspectableObjectReference = NativeObjectReference; - } - } - - /// - /// Creates a instance with the specified parameters for sealed scenarios. - /// - /// The instance to delegate activation to. - /// The IID of the default interface for the Windows Runtime class being constructed. - /// The value available in metadata for the type being marshalled. - /// The additional parameters to provide to . - /// Thrown if is . - /// Thrown if there's any errors when activating the underlying native object. - /// - /// - /// This constructor should only be used when activating sealed types (both projected and user-defined types). - /// - /// - /// Additionally, this constructor is only meant to be used when additional custom parameters are required to invoke the target factory method. If no additional - /// parameters are needed, the - /// overload should be used instead, as that is more efficient in case the default signature is sufficient. - /// - /// - [WindowsRuntimeImplementationOnlyMember] - protected WindowsRuntimeObject( - WindowsRuntimeActivationFactoryCallback.DerivedSealed activationFactoryCallback, - in Guid iid, - CreateObjectReferenceMarshalingType marshalingType, - WindowsRuntimeActivationArgsReference additionalParameters) - { - ArgumentNullException.ThrowIfNull(activationFactoryCallback); - - // Delegate to the activation factory callback (see detailed explanation above) - activationFactoryCallback.Invoke( - additionalParameters: additionalParameters, - defaultInterface: out void* defaultInterface); - - // The inner interface pointer isn't used for non-composable types, so we just pass 'null' - void* innerInterface = null; - - // Initialize the 'WindowsRuntimeObjectReference' for the default interface (same as above) - NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( - isAggregation: false, - thisInstance: this, - newInstanceUnknown: ref defaultInterface, - innerInstanceUnknown: ref innerInterface, - newInstanceIid: in iid, - marshalingType: marshalingType); - } - - /// - /// Creates a instance with the specified parameters for composed scenarios. - /// - /// The instance to delegate activation to. - /// The IID of the default interface for the Windows Runtime class being constructed. - /// The value available in metadata for the type being marshalled. - /// The additional parameters to provide to . - /// Thrown if is . - /// Thrown if there's any errors when activating the underlying native object. - /// - /// - /// This constructor should only be used when activating composable types (both projected and user-defined types). - /// - /// - /// Additionally, this constructor is only meant to be used when additional custom parameters are required to invoke the target factory method. If no additional - /// parameters are needed, the - /// overload should be used instead, as that is more efficient in case the default signature is sufficient. - /// - /// - [WindowsRuntimeImplementationOnlyMember] - protected WindowsRuntimeObject( - WindowsRuntimeActivationFactoryCallback.DerivedComposed activationFactoryCallback, - in Guid iid, - CreateObjectReferenceMarshalingType marshalingType, - WindowsRuntimeActivationArgsReference additionalParameters) - { - ArgumentNullException.ThrowIfNull(activationFactoryCallback); - - bool hasUnwrappableNativeObjectReference = HasUnwrappableNativeObjectReference; - - // Delegate to the activation factory callback (see detailed explanation above) - activationFactoryCallback.Invoke( - additionalParameters: additionalParameters, - baseInterface: hasUnwrappableNativeObjectReference ? null : this, - innerInterface: out void* innerInterface, - defaultInterface: out void* defaultInterface); - - // Initialize a 'WindowsRuntimeObjectReference' object (see detailed explanation above) - NativeObjectReference = WindowsRuntimeObjectReference.InitializeFromManagedTypeUnsafe( - isAggregation: !hasUnwrappableNativeObjectReference, - thisInstance: this, - newInstanceUnknown: ref defaultInterface, - innerInstanceUnknown: ref innerInterface, - newInstanceIid: in iid, - marshalingType: marshalingType); - - // Optimization: pre-cache the inspectable object reference if possible (see detailed explanation above) - if (!hasUnwrappableNativeObjectReference) - { - _inspectableObjectReference = NativeObjectReference; - } - } - - /// - /// Gets the inner Windows Runtime object reference for the current instance. - /// - /// - /// This object reference should point to an IInspectable native object. - /// - [WindowsRuntimeImplementationOnlyMember] - protected internal WindowsRuntimeObjectReference NativeObjectReference { get; } - - /// - /// Gets a value indicating whether the current instance has an unwrappable native object reference. - /// - /// - /// This value is in aggregation scenarios, as the instance that should be marshalled - /// to native is the derived managed type for the projected class, and not the inner object for the base type. - /// - [WindowsRuntimeImplementationOnlyMember] - protected internal virtual bool HasUnwrappableNativeObjectReference => UnreachableException.Throw(); - - /// - /// Gets the lazy-loaded, cached object reference for IInspectable for the current object. - /// - internal WindowsRuntimeObjectReference InspectableObjectReference - { - get - { - [MethodImpl(MethodImplOptions.NoInlining)] - WindowsRuntimeObjectReference InitializeInspectableObjectReference() - { - _ = Interlocked.CompareExchange( - location1: ref _inspectableObjectReference, - value: NativeObjectReference.As(in WellKnownWindowsInterfaceIIDs.IID_IInspectable), - comparand: null); - - return _inspectableObjectReference; - } - - return _inspectableObjectReference ?? InitializeInspectableObjectReference(); - } - init => _inspectableObjectReference = value; - } - - /// - /// Gets the lazy-loaded cache of additional data associated to type handles. - /// - private ConcurrentDictionary TypeHandleCache - { - get - { - [MethodImpl(MethodImplOptions.NoInlining)] - ConcurrentDictionary InitializeTypeHandleCache() - { - _ = Interlocked.CompareExchange( - location1: ref _typeHandleCache, - value: new ConcurrentDictionary(concurrencyLevel: 1, capacity: 16), - comparand: null); - - return _typeHandleCache; - } - - return _typeHandleCache ?? InitializeTypeHandleCache(); - } - } - - /// - /// Determines whether a given interface is an overridable interface for the current type. - /// - /// The interface to check. - /// Whether the interface represented by is an overridable interface for the current type. - [WindowsRuntimeImplementationOnlyMember] - protected virtual bool IsOverridableInterface(in Guid iid) - { - return UnreachableException.Throw(); - } - - /// - /// Retrieves a object for the specified interface. - /// - /// The type handle for the interface to retrieve the object reference for. - /// The resulting object. - /// Thrown if the interface specified by is not implemented. - [WindowsRuntimeImplementationOnlyMember] - public WindowsRuntimeObjectReference GetObjectReferenceForInterface(RuntimeTypeHandle interfaceType) - { - // Throw an exception if we couldn't resolve the interface reference - if (!TryGetCastResult( - interfaceType: interfaceType, - implementationType: out _, - interfaceReference: out WindowsRuntimeObjectReference? interfaceReference)) - { - [DoesNotReturn] - [StackTraceHidden] - static void ThrowArgumentException(RuntimeTypeHandle interfaceType) - { - throw new ArgumentException( - $"The type '{Type.GetTypeFromHandle(interfaceType)}' cannot be used to retrieve an object reference for the current object."); - } - - ThrowArgumentException(interfaceType); - } - - return interfaceReference; - } - - /// - /// Tries to retrieve a object for the specified interface. - /// - /// The type handle for the interface to retrieve the object reference for. - /// The resulting object, if the interface could be retrieved. - /// Whether could be retrieved successfully. - [WindowsRuntimeImplementationOnlyMember] - public bool TryGetObjectReferenceForInterface(RuntimeTypeHandle interfaceType, [NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference) - { - return TryGetCastResult( - interfaceType: interfaceType, - implementationType: out _, - interfaceReference: out interfaceReference); - } - - /// - /// Retrieves a object for the interface. - /// - /// The resulting object. - /// Thrown if the interface is not implemented. - internal WindowsRuntimeObjectReference GetObjectReferenceForIEnumerableInterfaceInstance() - { - // Throw an exception if we couldn't resolve the 'IEnumerable' interface reference - if (!TryGetObjectReferenceForIEnumerableInterfaceInstance(out WindowsRuntimeObjectReference? interfaceReference)) - { - [DoesNotReturn] - [StackTraceHidden] - static void ThrowArgumentException() - { - throw new ArgumentException( - $"The type '{typeof(IEnumerable)}' cannot be used to retrieve an object reference for the current object."); - } - - ThrowArgumentException(); - } - - return interfaceReference; - } - - /// - /// Tries to retrieve a object for the interface. - /// - /// The resulting object, if the interface could be retrieved. - /// Whether could be retrieved successfully. - internal bool TryGetObjectReferenceForIEnumerableInterfaceInstance([NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference) - { - ConcurrentDictionary typeHandleCache = TypeHandleCache; - - // If we have a cached value, return it immediately to skip further lookups. We use - // the 'IEnumerableInstance' type to cache the specialized object reference in this - // scenario. The only thing that matters is no other code will try this same lookup. - if (typeHandleCache.TryGetValue(typeof(IEnumerableInstance).TypeHandle, out object? value)) - { - switch (value) - { - case DynamicInterfaceCastableResult castResult: - interfaceReference = castResult.InterfaceObjectReference; - return true; - default: - interfaceReference = null; - return false; - } - } - - // Go through the cached object references for dynamic casts to try to find a compatible one - foreach (KeyValuePair typeHandleEntry in TypeHandleCache) - { - // Resolve the interface type (this can never be 'null', as we're the only ones adding elements) - Type interfaceType = Type.GetTypeFromHandle(typeHandleEntry.Key)!; - - // Scan the cached entries, and skip all the ones that are not some 'IEnumerable' instantiation - if (!(interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))) - { - continue; - } - - // Also skip all 'IEnumerable' instantiations that are not actually implemented by the native object - if (typeHandleEntry.Value is not DynamicInterfaceCastableResult result) - { - continue; - } - - // Try to cache the cast result that we retrieved, but we can't assume we'll win the race here. - // If we lost and the result is different, that's fine, we'll just use that one instead. This - // also guarantees that even if we have race conditions, the same implementation is always used. - object cachedResult = typeHandleCache.GetOrAdd(typeof(IEnumerableInstance).TypeHandle, result); - - // Return the resulting object reference from the cached result. Note that in the event of a lost - // race, this might possibly result in us reporting a failure even though this thread had actually - // found an object reference. This is intentional, as we want to make sure that we don't return - // different implementations at different callsites, as that could lead to hard to debug problems. - // In practice, this doesn't matter, as we always expect 'IEnumerable' casts to be done after some - // other cast to 'IEnumerable'. The main scenario where this happens is within LINQ operations. - switch (cachedResult) - { - case DynamicInterfaceCastableResult castResult: - interfaceReference = castResult.InterfaceObjectReference; - return true; - default: - interfaceReference = null; - return false; - } - } - - // Cache the failed cast, but still validate the return in case of an unlikely race against an 'IEnumerable' cast - object cachedFailure = typeHandleCache.GetOrAdd(typeof(IEnumerableInstance).TypeHandle, DynamicInterfaceCastFailure.Instance); - - // Switch on the cached failure as above, just in case we somehow still got a valid result on another thread first - switch (cachedFailure) - { - case DynamicInterfaceCastableResult castResult: - interfaceReference = castResult.InterfaceObjectReference; - return true; - default: - interfaceReference = null; - return false; - } - } - /// RuntimeTypeHandle IDynamicInterfaceCastable.GetInterfaceImplementation(RuntimeTypeHandle interfaceType) { - // Fail immediately if the feature switch is disabled, to ensure all related code can be trimmed - if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) - { - throw WindowsRuntimeObjectExceptions.GetNotSupportedException(); - } - - Type type = Type.GetTypeFromHandle(interfaceType)!; - - // If we can resolve the implementation type through the Windows Runtime infrastructure, return it - if (DynamicInterfaceCastableImplementationInfo.TryGetInfo( - interfaceType: type, - info: out DynamicInterfaceCastableImplementationInfo? implementationInfo)) - { - return implementationInfo.ImplementationType.TypeHandle; - } - - // If the interface is a generated COM interface, return the implementation type from there - if (StrategyBasedComWrappers.DefaultIUnknownInterfaceDetailsStrategy.GetIUnknownDerivedDetails(interfaceType) is IIUnknownDerivedDetails details) - { - return details.Implementation.TypeHandle; - } - - // Otherwise we don't have an implementation type, so this cast can't possibly succeed - return default; + return GetInterfaceImplementation(interfaceType); } /// bool IDynamicInterfaceCastable.IsInterfaceImplemented(RuntimeTypeHandle interfaceType, bool throwIfNotImplemented) { - // Early feature switch check to improve trimming (same as above) - if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) - { - // If we should throw, explicitly throw the same exception as from 'GetInterfaceImplementation', rather than - // just returning 'false' and letting the runtime throw an 'InvalidCastException'. This allows developers to - // more easily understand why a given runtime cast might be failing under different configurations. - if (throwIfNotImplemented) - { - throw WindowsRuntimeObjectExceptions.GetNotSupportedException(); - } - - return false; - } - - return TryGetCastResult( - interfaceType: interfaceType, - implementationType: out _, - interfaceReference: out _); + return IsInterfaceImplemented(interfaceType, throwIfNotImplemented); } /// VirtualMethodTableInfo IUnmanagedVirtualMethodTableProvider.GetVirtualMethodTableInfoForKey(Type type) { - if (LookupGeneratedVTableInfo( - interfaceType: type.TypeHandle, - performTypeHandleCacheLookup: true, - throwOnQueryInterfaceFailure: true, - castResult: out GeneratedComInterfaceCastResult? castResult) is not CustomQueryInterfaceResult.Handled) - { - [DoesNotReturn] - [StackTraceHidden] - static void ThrowArgumentException(Type type) - { - throw new ArgumentException( - $"The type '{type}' cannot be used to resolve a virtual method table for the current object."); - } - - ThrowArgumentException(type); - } - - return new(castResult!.TableInfo.ThisPtr, castResult.TableInfo.Table); + return GetVirtualMethodTableInfoForKey(type); } /// CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, out nint ppv) { - // We explicitly don't handle overridable interfaces, as well as 'IInspectable' and 'IWeakReferenceSource'. - // This last one in particular must be ignored to avoid issues when an RCW object is used as a target - // for a 'WeakReference' object. Lastly, we also need to not handle this 'QueryInterface' request when - // 'NativeObjectReference' is 'null', which will be the case during initialization (because objects are - // constructed entirely from this base 'WindowsRuntimeObject' type). In that case, 'QueryInterface' calls - // will be coming for the outer instance from the inner one, where the outer calls 'GetInterface' first, - // and they wouldn't need to be handled anyway. - if (IsOverridableInterface(in iid) || - WellKnownWindowsInterfaceIIDs.IID_IInspectable == iid || - WellKnownWindowsInterfaceIIDs.IID_IWeakReferenceSource == iid || - NativeObjectReference is null) - { - ppv = default; - - return CustomQueryInterfaceResult.NotHandled; - } - - // Delegate the 'QueryInterface' call to the inner object reference - return NativeObjectReference.TryAsUnsafe(in iid, out ppv) - ? CustomQueryInterfaceResult.Handled - : CustomQueryInterfaceResult.NotHandled; - } - - /// - /// Tries to get an object reference without additional lookups. - /// - /// The input interface type. - /// The implementation type. - /// The for the interface. - /// Whether the cast was successfully retrieved. - /// - /// This method mirrors above, just with minor - /// differences to further optimize it for - /// and calls, where we - /// need the cast results. Any changes to either of these methods should be kept in sync. - /// - private bool TryGetCastResult( - RuntimeTypeHandle interfaceType, - [NotNullWhen(true)] out RuntimeTypeHandle implementationType, - [NotNullWhen(true)] out WindowsRuntimeObjectReference? interfaceReference) - { - ConcurrentDictionary typeHandleCache = TypeHandleCache; - - // If we have a cached value, return it immediately to skip further lookups - if (typeHandleCache.TryGetValue(interfaceType, out object? value)) - { - switch (value) - { - case DynamicInterfaceCastableResult castResult: - implementationType = castResult.ImplementationType.TypeHandle; - interfaceReference = castResult.InterfaceObjectReference; - return true; - case GeneratedComInterfaceCastResult castResult: - implementationType = castResult.TableInfo.ManagedType; - interfaceReference = castResult.InterfaceObjectReference; - return true; - default: - implementationType = default; - interfaceReference = null; - return false; - } - } - - // First, check for 'IDynamicInterfaceCastable' casts through the Windows Runtime infrastructure - CustomQueryInterfaceResult dynamicQueryInterfaceResult = LookupDynamicInterfaceCastableImplementationInfo( - interfaceType: interfaceType, - castResult: out DynamicInterfaceCastableResult? dynamicInterfaceCastableResult); - - // Return the appropriate result based on the 'QueryInterface' result, if handled - switch (dynamicQueryInterfaceResult) - { - case CustomQueryInterfaceResult.Handled: - implementationType = dynamicInterfaceCastableResult!.ImplementationType.TypeHandle; - interfaceReference = dynamicInterfaceCastableResult.InterfaceObjectReference; - return true; - case CustomQueryInterfaceResult.Failed: - goto Failure; - case CustomQueryInterfaceResult.NotHandled: - default: break; - } - - // Next, check to see if the target interface is a generated COM interface - CustomQueryInterfaceResult generatedQueryInterfaceResult = LookupGeneratedVTableInfo( - interfaceType: interfaceType, - performTypeHandleCacheLookup: false, - throwOnQueryInterfaceFailure: false, - castResult: out GeneratedComInterfaceCastResult? generatedComInterfaceCastResult); - - // Return the appropriate result for 'QueryInterface' (same as above) - switch (generatedQueryInterfaceResult) - { - case CustomQueryInterfaceResult.Handled: - implementationType = generatedComInterfaceCastResult!.TableInfo.ManagedType; - interfaceReference = generatedComInterfaceCastResult.InterfaceObjectReference; - return true; - case CustomQueryInterfaceResult.Failed: - case CustomQueryInterfaceResult.NotHandled: - default: break; - } - - Failure: - implementationType = default; - interfaceReference = null; - - // Before returning, cache the fact the cast failed, so future calls will be faster - _ = typeHandleCache.TryAdd(interfaceType, DynamicInterfaceCastFailure.Instance); - - return false; - } - - /// - /// Looks up whether the input interface type is implemented for an cast. - /// - /// The input interface type. - /// The resulting value, if the cast is successful. - /// A value representing the result of this dynamic cast lookup operation. - /// - /// When successful, this method will cache a value into . - /// - private CustomQueryInterfaceResult LookupDynamicInterfaceCastableImplementationInfo(RuntimeTypeHandle interfaceType, out DynamicInterfaceCastableResult? castResult) - { - castResult = null; - - // Also fail from here if the feature switch is disabled, to ensure that 'DynamicInterfaceCastableImplementationInfo' - // can fully be trimmed. In theory this path shouldn't be reachable if the feature is disabled, but this can help. - if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) - { - return CustomQueryInterfaceResult.Failed; - } - - Type type = Type.GetTypeFromHandle(interfaceType)!; - - // If we can't resolve the implementation info at all, the cast can't possibly succeed - if (!DynamicInterfaceCastableImplementationInfo.TryGetInfo( - interfaceType: type, - info: out DynamicInterfaceCastableImplementationInfo? implementationInfo)) - { - return CustomQueryInterfaceResult.NotHandled; - } - - WindowsRuntimeObjectReference? interfaceReference; - - // Special case generic interface types that can be implemented via multiple types. For instance, a cast to - // 'ICollection>' should succeed if the native objects implement 'IList>', - // but also if the native object implements 'IDictionary'. In these cases, we won't know which IID to use - // nor what actual implementation type to use (as it depends on what the native object implements), so we defer - // to the generated forwarder attribute to check that. - if (type.IsGenericType && ( - type.GetGenericTypeDefinition() == typeof(ICollection<>) || - type.GetGenericTypeDefinition() == typeof(IReadOnlyCollection<>)) && - type.GenericTypeArguments[0].IsGenericType && - type.GenericTypeArguments[0].GetGenericTypeDefinition() == typeof(KeyValuePair<,>)) - { - // Invoke 'IsInterfaceImplemented' on the implementation type, which will perform a series of calls - // to 'TryGetObjectReferenceForInterface' for all the compatible Windows Runtime interfaces. The - // resulting object references will be for the interface that actually exists on the native object. - // This interface shouldn't really be needed from this key for the lookup, but we still store it. - if (!implementationInfo.GetDynamicInterfaceCastableForwarder().IsInterfaceImplemented(this, out interfaceReference)) - { - return CustomQueryInterfaceResult.Failed; - } - } - else - { - // Try to cast to the IID specified by the interface, and stop if that failed. - // In this case we can just get the IID directly from the implementation type. - if (!NativeObjectReference.TryAs( - iid: implementationInfo.ImplementationType.GUID, - objectReference: out interfaceReference)) - { - return CustomQueryInterfaceResult.Failed; - } - } - - // Initialize the cache result to return to callers - castResult = new DynamicInterfaceCastableResult() - { - ImplementationType = implementationInfo.ImplementationType, - InterfaceObjectReference = interfaceReference - }; - - // Add the cast result to the cache, or get the updated value if we raced against another thread - object effectiveCastResult = TypeHandleCache.GetOrAdd(interfaceType, castResult); - - // If the result is different than the one we tried to add, it means we lost a race against another - // thread. In this case we just discard our object reference. The updated result is perfectly valid. - if (effectiveCastResult != castResult) - { - interfaceReference.Dispose(); - - castResult = (DynamicInterfaceCastableResult)effectiveCastResult; - } - - return CustomQueryInterfaceResult.Handled; - } - - /// - /// Looks up whether the input interface type is implemented for a generated COM interface cast. - /// - /// The input interface type. - /// Whether to lookup into first. - /// Whether to throw an exception of QueryInterface fails. - /// The resulting value, if the cast is successful. - /// A value representing the result of this dynamic cast lookup operation. - /// - /// When successful, this method will cache a value into . - /// - private CustomQueryInterfaceResult LookupGeneratedVTableInfo( - RuntimeTypeHandle interfaceType, - bool performTypeHandleCacheLookup, - bool throwOnQueryInterfaceFailure, - out GeneratedComInterfaceCastResult? castResult) - { - castResult = null; - - // Same trim-friendly check as above (see notes there) - if (!WindowsRuntimeFeatureSwitches.EnableIDynamicInterfaceCastableSupport) - { - return CustomQueryInterfaceResult.Failed; - } - - // We only do the lookup if the caller hasn't already done so - if (performTypeHandleCacheLookup && TypeHandleCache.TryGetValue(interfaceType, out object? typeHandleCacheValue)) - { - // Try to see if we have a cached table info, and if we do, we can stop here - if (typeHandleCacheValue is GeneratedComInterfaceCastResult cachedCastResult) - { - castResult = cachedCastResult; - - return CustomQueryInterfaceResult.Handled; - } - } - - // This method is specifically only for checking generated COM interfaces. If we can't - // resolve the 'IIUnknownDerivedDetails' value for the interface, we have nothing to do. - if (StrategyBasedComWrappers.DefaultIUnknownInterfaceDetailsStrategy.GetIUnknownDerivedDetails(interfaceType) is IIUnknownDerivedDetails details) - { - HRESULT hresult = NativeObjectReference.DerivedTryAsNative(details.Iid, out WindowsRuntimeObjectReference? interfaceReference); - - // If the 'QueryInterface' call failed, we know the interface can't possibly be implemented. - // Because the actual 'QueryInterface' failed, we also know there would be no point for the - // rest of the 'IDynamicInterfaceCastable' logic to run, as the cast can never succeed. - if (hresult.Failed) - { - // Throw only if requested by callers - if (throwOnQueryInterfaceFailure) - { - Marshal.ThrowExceptionForHR(hresult); - } - - return CustomQueryInterfaceResult.Failed; - } - - // Here we are intentionally getting the pointer without incrementing its reference count. - // The target native object will be kept alive by the cached 'WindowsRuntimeObjectReference'. - void* interfacePtr = interfaceReference!.GetThisPtrUnsafe(); - - // Initialize the cache result to return to callers - castResult = new GeneratedComInterfaceCastResult - { - TableInfo = new IIUnknownCacheStrategy.TableInfo() - { - ThisPtr = interfacePtr, - Table = *(void***)interfacePtr, - ManagedType = details.Implementation.TypeHandle - }, - InterfaceObjectReference = interfaceReference - }; - - // Try to add the cast result to the cache - object effectiveCastResult = TypeHandleCache.GetOrAdd(interfaceType, castResult); - - // If we lost a thread, dispose the reference and return the updated result we - // just retrieved from the cache. This is the same logic as for other casts. - if (effectiveCastResult != castResult) - { - interfaceReference.Dispose(); - - castResult = (GeneratedComInterfaceCastResult)effectiveCastResult; - } - - return CustomQueryInterfaceResult.Handled; - } - - return CustomQueryInterfaceResult.NotHandled; - } - - /// - /// A placeholder type for failed casts. - /// - private sealed class DynamicInterfaceCastFailure - { - /// - /// The singleton instance. - /// - public static readonly DynamicInterfaceCastFailure Instance = new(); - } - - /// - /// A type for successful generated COM interface casts. - /// - private sealed class GeneratedComInterfaceCastResult - { - /// - /// Gets the vaulue for the interface. - /// - public required IIUnknownCacheStrategy.TableInfo TableInfo { get; init; } - - /// - /// Gets the instance for the interface pointer. - /// - public required WindowsRuntimeObjectReference InterfaceObjectReference { get; init; } - } - - /// - /// A type for successful cast. - /// - private sealed class DynamicInterfaceCastableResult - { - /// - /// Gets the implementation type for the interface. - /// - public required Type ImplementationType { get; init; } - - /// - /// Gets the instance for the interface pointer. - /// - public required WindowsRuntimeObjectReference InterfaceObjectReference { get; init; } - } - - /// - /// A dummy type to use for caching adaptive object references in . - /// - private static class IEnumerableInstance; -} - -/// -/// Exception stubs for . -/// -file static class WindowsRuntimeObjectExceptions -{ - /// - /// Gets a if support for is disabled. - /// - [MethodImpl(MethodImplOptions.NoInlining)] - public static NotSupportedException GetNotSupportedException() - { - // We can't throw the exception from here like the other method above, because it causes - // a linker crash when publishing with Native AOT. We can update this once it's fixed. - throw new( - $"Support for 'IDynamicInterfaceCastable' is disabled (make sure that the 'CsWinRTEnableIDynamicInterfaceCastableSupport' property is not set to 'false'). " + - $"In this configuration, runtime casts on Windows Runtime objects will only work if the managed object implements the target interface in metadata."); + return GetInterface(ref iid, out ppv); } } From 2394cbf68efff1549cec919b6879972fa3eb9e07 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 17 Jun 2026 11:58:07 -0700 Subject: [PATCH 3/8] Set up dual reference assembly build for WinRT.Runtime (#2444) * Adjust reference assembly build for WinRT.Runtime Prevent the SDK-produced reference assembly from leaking implementation-only types by customizing the ref-assembly build. When not building the explicit CsWinRT reference assembly, ProduceReferenceAssembly is disabled and WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY is defined to simplify #if usage. When CsWinRTBuildReferenceAssembly is true, WINDOWS_RUNTIME_REFERENCE_ASSEMBLY is defined and expected warnings (CS8597, IDE0005, IDE0380) are suppressed. A BeforeTargets CoreCompile target removes files that opt out of reference assemblies (via WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE), ABI sources, and several implementation-only folders so the packaged reference assembly omits private implementation details. * Guard Windows metadata by assembly type Wrap Windows runtime metadata and platform/contract attributes with build-time symbols to differentiate reference vs implementation assemblies. Many files now conditionally include Windows.Foundation.Metadata usings and apply [ContractVersion]/[SupportedOSPlatform] for WINDOWS_RUNTIME_REFERENCE_ASSEMBLY and [WindowsRuntimeMetadata]/[WindowsRuntimeClassName]/marshalling attributes for WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY. Removed unconditional SupportedOSPlatform/usings where appropriate and added #if guards across foundation, collections, streams, async adapters and task/asyncinfo helpers to allow building both reference and implementation variants. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Disable CS1574 in WindowsRuntimeFeatureSwitches Suppress CS1574 (XML doc 'cref' not found) warnings in WindowsRuntimeFeatureSwitches.cs by adding `#pragma warning disable CS1574` before the namespace declaration. This prevents spurious documentation warnings during the build, likely caused by cref references to internal or conditional types. * Move WindowsRuntimeInspectable to NativeObjects Rename/move WindowsRuntimeInspectable.cs from src/WinRT.Runtime2/ to src/WinRT.Runtime2/NativeObjects/ to reorganize project structure. File content unchanged (100% similarity). * Split WindowsRuntimeObject into partial file Move the core implementation into a new partial file (src/WinRT.Runtime2/WindowsRuntimeObject.Impl.cs) and make WindowsRuntimeObject partial. The impl file contains caching, dynamic cast lookup, generated COM vtable handling, QueryInterface logic, activation constructors and an exceptions helper; redundant usings/implementation were removed from WindowsRuntimeObject.cs to keep the public surface unchanged. * Add build guards for reference vs implementation Introduce compile-time guards to separate reference and implementation builds. Many files were marked as implementation-only by adding a WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE define; APIs and method bodies were wrapped with WINDOWS_RUNTIME_REFERENCE_ASSEMBLY / WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY conditionals (throw null in reference builds, real code in implementation builds). Adjustments touch attributes, interop/activation, marshalling, async helpers, buffer/stream utilities, and WindowsRuntimeMarshal/RestrictedErrorInfo/RestrictedErrorInfoExceptionMarshaller. Also updated the project file to exclude the Marshalling folder from the reference build. This enables producing lightweight reference assemblies while keeping full implementations in the implementation assembly. * Use explicit #elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY in WinRT.Runtime Replace the plain #else branch following #if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY with an explicit #elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY for clarity. The two constants are mutually exclusive and exhaustive, so the behavior is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...WindowsRuntimeDefaultInterfaceAttribute.cs | 2 + ...owsRuntimeExclusiveToInterfaceAttribute.cs | 2 + .../WindowsRuntimeMappedMetadataAttribute.cs | 2 + .../WindowsRuntimeMetadataAttribute.cs | 2 + ...WindowsRuntimeMetadataTypeNameAttribute.cs | 2 + .../WindowsRuntimeReferenceTypeAttribute.cs | 2 + .../Activation/IActivationFactory.cs | 4 +- .../WindowsRuntimeActivationFactory.cs | 12 +++ .../WindowsRuntimeActivationHelper.cs | 2 + .../Activation/WindowsRuntimeDllModule.cs | 2 + .../WindowsRuntimePlatformModule.cs | 2 + .../AsyncInfo/Adapters/TaskAdapter.cs | 2 - .../Adapters/TaskAdapter{TResult}.cs | 2 - .../TaskWithProgressAdapter{TProgress}.cs | 2 - ...WithProgressAdapter{TResult, TProgress}.cs | 2 - ...niversalTaskAdapter{TResult, TProgress}.cs | 2 - ...syncInfoTaskCompletionSource{TProgress}.cs | 2 - ...askCompletionSource{TResult, TProgress}.cs | 2 - ...amicInterfaceCastableForwarderAttribute.cs | 2 + ...indowsRuntimeActivationFactoryAttribute.cs | 2 + ...wsRuntimeComWrappersMarshallerAttribute.cs | 2 + ...indowsRuntimeComponentAssemblyAttribute.cs | 2 + ...meComponentAssemblyExportsTypeAttribute.cs | 2 + .../WindowsRuntimeMappedTypeAttribute.cs | 2 + ...indowsRuntimeReferenceAssemblyAttribute.cs | 2 + .../Events/EventRegistrationToken.cs | 2 + .../Exceptions/RestrictedErrorInfo.cs | 20 +++++ .../IWindowsRuntimeInterface.cs | 2 + .../IWindowsRuntimeInterface{T}.cs | 2 + .../RestrictedErrorInfoExceptionMarshaller.cs | 13 ++- .../AsyncInfo.cs | 68 +++++++++++++++ .../WindowsRuntimeBuffer.cs | 16 ++++ .../WellKnownInterfaceIIDs.g.cs | 2 + .../InteropServices/WellKnownInterfaceIIDs.tt | 2 + .../WindowsRuntimeBufferMarshal.cs | 12 +++ .../WindowsRuntimeComWrappers.cs | 2 + .../WindowsRuntimeComWrappersMarshal.cs | 2 + .../InteropServices/WindowsRuntimeMarshal.cs | 30 +++++++ .../WindowsRuntimeInspectable.cs | 0 .../WindowsRuntimeFeatureSwitches.cs | 2 + src/WinRT.Runtime2/WinRT.Runtime.csproj | 83 +++++++++++++++++++ .../AsyncActionCompletedHandler.cs | 7 +- .../AsyncActionProgressHandler{TProgress}.cs | 7 +- ...WithProgressCompletedHandler{TProgress}.cs | 7 +- ...AsyncOperationCompletedHandler{TResult}.cs | 7 +- ...tionProgressHandler{TResult, TProgress}.cs | 7 +- ...essCompletedHandler{TResult, TProgress}.cs | 7 +- .../Windows.Foundation/AsyncStatus.cs | 9 +- .../Collections/CollectionChange.cs | 9 +- .../Collections/IMapChangedEventArgs{K}.cs | 7 +- .../Collections/IObservableMap{K, V}.cs | 7 +- .../Collections/IObservableVector{T}.cs | 7 +- .../Collections/IVectorChangedEventArgs.cs | 7 +- .../MapChangedEventHandler{K, V}.cs | 7 +- .../VectorChangedEventHandler{T}.cs | 7 +- .../Extensions/VectorExtensions.cs | 4 + .../WindowsRuntimeTaskExtensions.cs | 36 ++++++++ .../Windows.Foundation/FoundationContract.cs | 7 +- .../Windows.Foundation/IAsyncAction.cs | 7 +- .../IAsyncActionWithProgress{TProgress}.cs | 7 +- .../Windows.Foundation/IAsyncInfo.cs | 7 +- ...erationWithProgress{TResult, TProgress}.cs | 7 +- .../IAsyncOperation{TResult}.cs | 7 +- .../IMemoryBufferReference.cs | 7 +- .../Windows.Foundation/IStringable.cs | 7 +- .../Metadata/ApiContractAttribute.cs | 7 +- .../Metadata/ContractVersionAttribute.cs | 9 +- .../Windows.Foundation/Point.cs | 17 +++- .../Windows.Foundation/PropertyType.cs | 9 +- src/WinRT.Runtime2/Windows.Foundation/Rect.cs | 17 +++- src/WinRT.Runtime2/Windows.Foundation/Size.cs | 9 +- .../UniversalApiContract.cs | 7 +- .../WindowsRuntimeBufferExtensions.cs | 36 ++++++++ .../WindowsRuntimeStreamExtensions.cs | 36 ++++++++ .../Windows.Storage.Streams/IBuffer.cs | 7 +- .../Windows.Storage.Streams/IInputStream.cs | 7 +- .../Windows.Storage.Streams/IOutputStream.cs | 7 +- .../IRandomAccessStream.cs | 7 +- .../InputStreamOptions.cs | 9 +- .../WindowsRuntimeObject.Impl.cs | 2 + src/WinRT.Runtime2/WindowsRuntimeObject.cs | 16 ++++ 81 files changed, 657 insertions(+), 63 deletions(-) rename src/WinRT.Runtime2/{ => NativeObjects}/WindowsRuntimeInspectable.cs (100%) diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs index e280fa0702..b0b2593fe2 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeDefaultInterfaceAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime; diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs index b21c5264f7..c0dc1fd708 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeExclusiveToInterfaceAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime; diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs index db7d06d96b..c6a4bb7912 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMappedMetadataAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime; diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs index aff608ee3d..4a672e15e5 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime; diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs index 3e6bceb204..e67276a5b7 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeMetadataTypeNameAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime; diff --git a/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs b/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs index e5351a0c4f..b7670fd04f 100644 --- a/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs +++ b/src/WinRT.Runtime2/Attributes/WindowsRuntimeReferenceTypeAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime; diff --git a/src/WinRT.Runtime2/InteropServices/Activation/IActivationFactory.cs b/src/WinRT.Runtime2/InteropServices/Activation/IActivationFactory.cs index f571959beb..171dbdc5d3 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/IActivationFactory.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/IActivationFactory.cs @@ -11,8 +11,10 @@ namespace WindowsRuntime.InteropServices; /// Enables a class to be activated by the Windows Runtime. /// /// -[WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] [Guid("00000035-0000-0000-C000-000000000046")] +#if WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY +[WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] +#endif [EditorBrowsable(EditorBrowsableState.Never)] public interface IActivationFactory { diff --git a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactory.cs b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactory.cs index 847890afdb..22e14f383f 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactory.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationFactory.cs @@ -114,6 +114,9 @@ public static bool TryGetActivationFactoryUnsafe(string runtimeClassName, in Gui /// private static HRESULT GetActivationFactoryFromAnySourceUnsafe(string runtimeClassName, in Guid iid, out void* activationFactory) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY // If we have no input IID, it means that callers just expect whatever the default interface pointer // returned by each attempted API is. For the activation handler and 'RoGetActivationFactory', we // still need to pass an IID in all cases. Unless specified, this should be 'IID_IActivationFactory'. @@ -148,6 +151,7 @@ private static HRESULT GetActivationFactoryFromAnySourceUnsafe(string runtimeCla return Unsafe.IsNullRef(in iid) ? GetActivationFactoryFromDllUnsafe(runtimeClassName, hresult, out activationFactory) : GetActivationFactoryFromDllUnsafe(runtimeClassName, in iid, hresult, out activationFactory); +#endif } /// Tries to get the activation factory for a Windows Runtime type with the specified runtime class name, using only the registered activation handler, if present. @@ -175,6 +179,9 @@ private static HRESULT GetActivationFactoryFromDllUnsafe( HRESULT hresult, out void* activationFactory) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY activationFactory = null; ReadOnlySpan moduleName = runtimeClassName; @@ -223,6 +230,7 @@ private static HRESULT GetActivationFactoryFromDllUnsafe( } return hresult; +#endif } /// Tries to get the activation factory for a Windows Runtime type with the specified runtime class name, using only manifest-free activation. @@ -235,6 +243,9 @@ private static HRESULT GetActivationFactoryFromDllUnsafe( HRESULT hresult, out void* activationFactory) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY activationFactory = null; // First, try to get the activation factory with the same logic for when we don't have an IID @@ -253,6 +264,7 @@ private static HRESULT GetActivationFactoryFromDllUnsafe( _ = IUnknownVftbl.ReleaseUnsafe(activationFactoryUnknown); return hresult; +#endif } /// diff --git a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationHelper.cs b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationHelper.cs index c16f258c0a..31b71efed9 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationHelper.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeActivationHelper.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.Collections; using System.Collections.Specialized; diff --git a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeDllModule.cs b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeDllModule.cs index 1903eb1684..eccc4a170a 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeDllModule.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimeDllModule.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimePlatformModule.cs b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimePlatformModule.cs index 67d56ea4bb..f5f5b4c99a 100644 --- a/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimePlatformModule.cs +++ b/src/WinRT.Runtime2/InteropServices/Activation/WindowsRuntimePlatformModule.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter.cs index 8a774cbaef..6bdc88f71d 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -12,7 +11,6 @@ namespace WindowsRuntime.InteropServices; /// /// Implements the Windows Runtime interface by wrapping a instance. /// -[SupportedOSPlatform("windows10.0.10240.0")] internal sealed class TaskAdapter : UniversalTaskAdapter< ValueTypePlaceholder, ValueTypePlaceholder, diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter{TResult}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter{TResult}.cs index 3cc8cd1627..5e64234ce1 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter{TResult}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskAdapter{TResult}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -13,7 +12,6 @@ namespace WindowsRuntime.InteropServices; /// Implements the Windows Runtime interface by wrapping a instance. /// /// The result type. -[SupportedOSPlatform("windows10.0.10240.0")] internal sealed class TaskAdapter : UniversalTaskAdapter< TResult, ValueTypePlaceholder, diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TProgress}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TProgress}.cs index 0e81028fef..19b82b24cf 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TProgress}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TProgress}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -13,7 +12,6 @@ namespace WindowsRuntime.InteropServices; /// Implements the Windows Runtime interface by wrapping a instance. /// /// The type of progress information. -[SupportedOSPlatform("windows10.0.10240.0")] internal sealed class TaskWithProgressAdapter : UniversalTaskAdapter< ValueTypePlaceholder, TProgress, diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TResult, TProgress}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TResult, TProgress}.cs index 0d8acff608..dd49a5ce14 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TResult, TProgress}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/TaskWithProgressAdapter{TResult, TProgress}.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -14,7 +13,6 @@ namespace WindowsRuntime.InteropServices; /// /// The result type. /// The type of progress information. -[SupportedOSPlatform("windows10.0.10240.0")] internal sealed class TaskWithProgressAdapter : UniversalTaskAdapter< TResult, TProgress, diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/UniversalTaskAdapter{TResult, TProgress}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/UniversalTaskAdapter{TResult, TProgress}.cs index 0f71ad6045..68e6db7d67 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/UniversalTaskAdapter{TResult, TProgress}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/Adapters/UniversalTaskAdapter{TResult, TProgress}.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -21,7 +20,6 @@ namespace WindowsRuntime.InteropServices; /// The type of progress information. /// The type of completed handler (e.g. for ). /// The type of progress handler (e.g. for ). -[SupportedOSPlatform("windows10.0.10240.0")] internal abstract partial class UniversalTaskAdapter< TResult, TProgress, diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TProgress}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TProgress}.cs index 933aa7d908..efbaeef888 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TProgress}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TProgress}.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -18,7 +17,6 @@ namespace WindowsRuntime.InteropServices; /// A implementation backed by an object. /// /// The type of progress information. -[SupportedOSPlatform("windows10.0.10240.0")] internal sealed class AsyncInfoTaskCompletionSource : TaskCompletionSource { /// diff --git a/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TResult, TProgress}.cs b/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TResult, TProgress}.cs index e7bbc6c180..a00ea4716c 100644 --- a/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TResult, TProgress}.cs +++ b/src/WinRT.Runtime2/InteropServices/AsyncInfo/TaskCompletionSources/AsyncInfoTaskCompletionSource{TResult, TProgress}.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -19,7 +18,6 @@ namespace WindowsRuntime.InteropServices; /// /// The result type. /// The type of progress information. -[SupportedOSPlatform("windows10.0.10240.0")] internal sealed class AsyncInfoTaskCompletionSource : TaskCompletionSource { /// diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs index 1749195175..7bb18ea8cb 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/DynamicInterfaceCastableForwarderAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs index c641ebeb60..89dfb57166 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeActivationFactoryAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs index 0802e82b94..b3d0b5d8e9 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComWrappersMarshallerAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs index 7a52538f9c..bc1c1b1492 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs index 6b1ef71188..484d3322d3 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs index 72916e1bcd..c6badd7638 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeMappedTypeAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs index ed4b612b7d..a7d2d0a06c 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationToken.cs b/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationToken.cs index 8b590c358c..c31ba3e0e7 100644 --- a/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationToken.cs +++ b/src/WinRT.Runtime2/InteropServices/Events/EventRegistrationToken.cs @@ -11,10 +11,12 @@ namespace WindowsRuntime.InteropServices; /// Represents a reference to a delegate that receives change notifications. /// /// +#if WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY [WindowsRuntimeMetadata("Windows.Foundation.FoundationContract")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [WindowsRuntimeReferenceType(typeof(EventRegistrationToken?))] [ABI.WindowsRuntime.InteropServices.EventRegistrationTokenComWrappersMarshaller] +#endif public struct EventRegistrationToken : IEquatable { /// diff --git a/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs b/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs index b228f3776c..f771feeab9 100644 --- a/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs +++ b/src/WinRT.Runtime2/InteropServices/Exceptions/RestrictedErrorInfo.cs @@ -38,6 +38,9 @@ public static unsafe class RestrictedErrorInfo /// restoredExceptionFromGlobalState Out param. private static Exception? GetExceptionForHR(HRESULT errorCode, out bool restoredExceptionFromGlobalState) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY // If the 'HRESULT' indicates success, there is no exception to return if (errorCode.Succeeded) { @@ -176,6 +179,7 @@ public static unsafe class RestrictedErrorInfo restoredExceptionFromGlobalState = false; return exception; +#endif } /// @@ -226,6 +230,9 @@ static void Throw(HRESULT errorCode) /// public static HRESULT GetHRForException(Exception? exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY // If the input exception is 'null', we always just map to 'S_OK' if (exception is null) { @@ -250,6 +257,7 @@ public static HRESULT GetHRForException(Exception? exception) } return WellKnownExceptionMappings.GetHRForNativeOrManagedErrorCode(hresult); +#endif } /// @@ -259,6 +267,9 @@ public static HRESULT GetHRForException(Exception? exception) /// Thrown if is . internal static void SetErrorInfo(Exception exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(exception); try @@ -335,6 +346,7 @@ internal static void SetErrorInfo(Exception exception) // If we fail to set the error info, we continue on reporting the original exception Debug.Assert(false, e.Message, e.StackTrace); } +#endif } /// @@ -343,6 +355,9 @@ internal static void SetErrorInfo(Exception exception) /// The input instance to attach the error info to. internal static void AttachErrorInfo(Exception exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(exception); void* restrictedErrorInfoPtr = null; @@ -413,6 +428,7 @@ internal static void AttachErrorInfo(Exception exception) { WindowsRuntimeUnknownMarshaller.Free(restrictedErrorInfoPtr); } +#endif } /// @@ -429,6 +445,9 @@ internal static void AttachErrorInfo(Exception exception) /// internal static void ReportUnhandledError(Exception exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY SetErrorInfo(exception); using WindowsRuntimeObjectReferenceValue restrictedErrorInfoValue = RestrictedErrorInfoHelpers.BorrowErrorInfo(); @@ -439,5 +458,6 @@ internal static void ReportUnhandledError(Exception exception) { _ = WindowsRuntimeImports.RoReportUnhandledError(restrictedErrorInfoValuePtr); } +#endif } } \ No newline at end of file diff --git a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs index 082c65de26..6c27ef1112 100644 --- a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs +++ b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; namespace WindowsRuntime.InteropServices; diff --git a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs index b306b78023..d5cec7946f 100644 --- a/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs +++ b/src/WinRT.Runtime2/InteropServices/IWindowsRuntimeInterface{T}.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + namespace WindowsRuntime.InteropServices; /// diff --git a/src/WinRT.Runtime2/InteropServices/Marshalling/RestrictedErrorInfoExceptionMarshaller.cs b/src/WinRT.Runtime2/InteropServices/Marshalling/RestrictedErrorInfoExceptionMarshaller.cs index 4c5cb3050e..8c68ae2054 100644 --- a/src/WinRT.Runtime2/InteropServices/Marshalling/RestrictedErrorInfoExceptionMarshaller.cs +++ b/src/WinRT.Runtime2/InteropServices/Marshalling/RestrictedErrorInfoExceptionMarshaller.cs @@ -7,15 +7,16 @@ namespace WindowsRuntime.InteropServices.Marshalling; /// -/// A marshaller using to marshal exceptions to and from the native side. +/// A marshaller using the IRestrictedErrorInfo infrastructure to marshal exceptions to and from the native side. /// /// /// This type is only meant to be used in two scenarios: /// -/// With , when used on interfaces implemented by WinRT objects. +/// With , when used on interfaces implemented by Windows Runtime objects. /// In blocks within generated or handwritten marshalling stubs. /// /// +/// . [CustomMarshaller(typeof(Exception), MarshalMode.ManagedToUnmanagedOut, typeof(RestrictedErrorInfoExceptionMarshaller))] public static class RestrictedErrorInfoExceptionMarshaller { @@ -36,9 +37,13 @@ public static class RestrictedErrorInfoExceptionMarshaller /// public static HRESULT ConvertToUnmanaged(Exception value) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY RestrictedErrorInfo.SetErrorInfo(value); return RestrictedErrorInfo.GetHRForException(value); +#endif } /// @@ -48,6 +53,10 @@ public static HRESULT ConvertToUnmanaged(Exception value) /// A managed exception. public static Exception? ConvertToManaged(HRESULT value) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return RestrictedErrorInfo.GetExceptionForHR(value); +#endif } } \ No newline at end of file diff --git a/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/AsyncInfo.cs b/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/AsyncInfo.cs index d7ca2ace12..3dee37992b 100644 --- a/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/AsyncInfo.cs +++ b/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/AsyncInfo.cs @@ -2,7 +2,9 @@ // Licensed under the MIT License. using System; +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY using System.Runtime.Versioning; +#endif using System.Threading; using System.Threading.Tasks; using Windows.Foundation; @@ -20,7 +22,9 @@ namespace WindowsRuntime.InteropServices; /// that will be wrapped by the returned Windows Runtime adapter. /// /// +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY [SupportedOSPlatform("windows10.0.10240.0")] +#endif public static class AsyncInfo { /// @@ -41,9 +45,13 @@ public static class AsyncInfo /// public static IAsyncAction Run(Func factory) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(factory); return new TaskAdapter(factory); +#endif } /// @@ -75,9 +83,13 @@ public static IAsyncAction Run(Func factory) /// public static IAsyncActionWithProgress Run(Func, Task> factory) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(factory); return new TaskWithProgressAdapter(factory); +#endif } /// @@ -99,9 +111,13 @@ public static IAsyncActionWithProgress Run(Func public static IAsyncOperation Run(Func> factory) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(factory); return new TaskAdapter(factory); +#endif } /// @@ -139,9 +155,13 @@ public static IAsyncOperation Run(Func Run( Func, Task> factory) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(factory); return new TaskWithProgressAdapter(factory); +#endif } /// @@ -150,7 +170,11 @@ public static IAsyncOperationWithProgress RunThe resulting instance. public static IAsyncAction CompletedAction() { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskAdapter(default(CompletedTaskPlaceholder)); +#endif } /// @@ -160,7 +184,11 @@ public static IAsyncAction CompletedAction() /// The resulting instance. public static IAsyncActionWithProgress CompletedActionWithProgress() { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskWithProgressAdapter(default(CompletedTaskPlaceholder)); +#endif } /// @@ -171,7 +199,11 @@ public static IAsyncActionWithProgress CompletedActionWithProgressThe resulting instance. public static IAsyncOperation FromResult(TResult result) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskAdapter(result); +#endif } /// @@ -183,7 +215,11 @@ public static IAsyncOperation FromResult(TResult result) /// The resulting instance. public static IAsyncOperationWithProgress FromResultWithProgress(TResult result) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskWithProgressAdapter(result); +#endif } /// @@ -193,9 +229,13 @@ public static IAsyncOperationWithProgress FromResultWithProg /// The resulting instance. public static IAsyncAction FromException(Exception exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(exception); return new TaskAdapter(exception); +#endif } /// @@ -206,9 +246,13 @@ public static IAsyncAction FromException(Exception exception) /// The resulting instance. public static IAsyncActionWithProgress FromExceptionWithProgress(Exception exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(exception); return new TaskWithProgressAdapter(exception); +#endif } /// @@ -219,9 +263,13 @@ public static IAsyncActionWithProgress FromExceptionWithProgressThe resulting instance. public static IAsyncOperation FromException(Exception exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(exception); return new TaskAdapter(exception); +#endif } /// @@ -233,9 +281,13 @@ public static IAsyncOperation FromException(Exception exceptio /// The resulting instance. public static IAsyncOperationWithProgress FromExceptionWithProgress(Exception exception) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(exception); return new TaskWithProgressAdapter(exception); +#endif } /// @@ -244,7 +296,11 @@ public static IAsyncOperationWithProgress FromExceptionWithP /// The resulting instance. public static IAsyncAction CanceledAction() { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskAdapter(default(CanceledTaskPlaceholder)); +#endif } /// @@ -254,7 +310,11 @@ public static IAsyncAction CanceledAction() /// The resulting instance. public static IAsyncActionWithProgress CanceledActionWithProgress() { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskWithProgressAdapter(default(CanceledTaskPlaceholder)); +#endif } /// @@ -264,7 +324,11 @@ public static IAsyncActionWithProgress CanceledActionWithProgressThe resulting instance. public static IAsyncOperation CanceledOperation() { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskAdapter(default(CanceledTaskPlaceholder)); +#endif } /// @@ -275,6 +339,10 @@ public static IAsyncOperation CanceledOperation() /// The resulting instance. public static IAsyncOperationWithProgress CanceledOperationWithProgress() { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return new TaskWithProgressAdapter(default(CanceledTaskPlaceholder)); +#endif } } \ No newline at end of file diff --git a/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/WindowsRuntimeBuffer.cs b/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/WindowsRuntimeBuffer.cs index 73194ebb12..61fcd17294 100644 --- a/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/WindowsRuntimeBuffer.cs +++ b/src/WinRT.Runtime2/InteropServices/System.Runtime.InteropServices/WindowsRuntimeBuffer.cs @@ -19,9 +19,13 @@ public static class WindowsRuntimeBuffer /// Thrown if is less than 0. public static IBuffer Create(int capacity) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentOutOfRangeException.ThrowIfNegative(capacity); return new WindowsRuntimePinnedArrayBuffer(capacity); +#endif } /// @@ -31,11 +35,15 @@ public static IBuffer Create(int capacity) /// The resulting instance (with and equal to the length of ). public static IBuffer Create(ReadOnlySpan data) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY byte[] pinnedData = GC.AllocateArray(data.Length, pinned: true); data.CopyTo(pinnedData); return new WindowsRuntimePinnedArrayBuffer(pinnedData, offset: 0, data.Length, data.Length); +#endif } /// @@ -49,6 +57,9 @@ public static IBuffer Create(ReadOnlySpan data) /// Thrown if is less than the length of . public static IBuffer Create(ReadOnlySpan data, int capacity) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentOutOfRangeException.ThrowIfNegative(capacity); //if (capacity < length) throw new ArgumentException(global::Windows.Foundation.SR.Argument_InsufficientBufferCapacity); @@ -57,6 +68,7 @@ public static IBuffer Create(ReadOnlySpan data, int capacity) data.CopyTo(pinnedData); return new WindowsRuntimePinnedArrayBuffer(pinnedData, offset: 0, data.Length, capacity); +#endif } /// @@ -73,6 +85,9 @@ public static IBuffer Create(ReadOnlySpan data, int capacity) /// Thrown if the specified range is not valid, or if is less than the specified range. public static IBuffer Create(byte[] data, int offset, int length, int capacity) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(data); ArgumentOutOfRangeException.ThrowIfNegative(offset); ArgumentOutOfRangeException.ThrowIfNegative(length); @@ -91,5 +106,6 @@ public static IBuffer Create(byte[] data, int offset, int length, int capacity) length: length); return new WindowsRuntimePinnedArrayBuffer(pinnedData, offset: 0, length, capacity); +#endif } } diff --git a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs index ca36198485..801f4ff154 100644 --- a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs +++ b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.g.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.ComponentModel; using System.Runtime.CompilerServices; diff --git a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt index b730a857d1..9cde0ffb9c 100644 --- a/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt +++ b/src/WinRT.Runtime2/InteropServices/WellKnownInterfaceIIDs.tt @@ -5,6 +5,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.ComponentModel; using System.Runtime.CompilerServices; diff --git a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeBufferMarshal.cs b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeBufferMarshal.cs index ff0756aa54..fa12a96d36 100644 --- a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeBufferMarshal.cs +++ b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeBufferMarshal.cs @@ -27,6 +27,9 @@ public static partial class WindowsRuntimeBufferMarshal /// public static unsafe bool TryGetDataUnsafe([NotNullWhen(true)] IBuffer? buffer, out byte* data) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY if (buffer is null) { goto Failure; @@ -49,6 +52,7 @@ public static unsafe bool TryGetDataUnsafe([NotNullWhen(true)] IBuffer? buffer, data = null; return false; +#endif } /// @@ -66,6 +70,9 @@ public static unsafe bool TryGetDataUnsafe([NotNullWhen(true)] IBuffer? buffer, /// public static unsafe bool TryGetDataUnsafe([NotNullWhen(true)] IMemoryBufferReference? buffer, out byte* data, out uint capacity) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY if (buffer is null) { goto Failure; @@ -92,6 +99,7 @@ public static unsafe bool TryGetDataUnsafe([NotNullWhen(true)] IMemoryBufferRefe capacity = 0; return false; +#endif } /// @@ -102,6 +110,9 @@ public static unsafe bool TryGetDataUnsafe([NotNullWhen(true)] IMemoryBufferRefe /// Whether was successfully retrieved. public static bool TryGetArray([NotNullWhen(true)] IBuffer? buffer, out ArraySegment array) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY if (buffer is null) { goto Failure; @@ -127,5 +138,6 @@ public static bool TryGetArray([NotNullWhen(true)] IBuffer? buffer, out ArraySeg array = default; return false; +#endif } } diff --git a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappers.cs b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappers.cs index 087229d386..ea0cfbdba9 100644 --- a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappers.cs +++ b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappers.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.Collections; using System.Diagnostics; diff --git a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs index 7f8f448bd6..34f2d36bf4 100644 --- a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs +++ b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeComWrappersMarshal.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; diff --git a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeMarshal.cs b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeMarshal.cs index 192490fb4f..e8fe2074ba 100644 --- a/src/WinRT.Runtime2/InteropServices/WindowsRuntimeMarshal.cs +++ b/src/WinRT.Runtime2/InteropServices/WindowsRuntimeMarshal.cs @@ -5,7 +5,9 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +#if WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY using WindowsRuntime.InteropServices.Marshalling; +#endif namespace WindowsRuntime.InteropServices; @@ -22,6 +24,9 @@ public static unsafe class WindowsRuntimeMarshal /// Whether and are the same object or wrap the same underlying native object. public static bool NativeReferenceEquals(object? left, object? right) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY if (ReferenceEquals(left, right)) { return true; @@ -44,6 +49,7 @@ public static bool NativeReferenceEquals(object? left, object? right) } return false; +#endif } /// @@ -55,9 +61,13 @@ public static bool NativeReferenceEquals(object? left, object? right) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsReferenceToManagedObject(void* externalComObject) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY ArgumentNullException.ThrowIfNull(externalComObject); return WindowsRuntimeComWrappersMarshal.IsReferenceToManagedObjectUnsafe(externalComObject); +#endif } /// @@ -68,6 +78,9 @@ public static bool IsReferenceToManagedObject(void* externalComObject) /// Whether was a reference to a managed object, and could be retrieved. public static bool TryGetManagedObject(void* externalComObject, [NotNullWhen(true)] out object? result) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY // If the input pointer is a reference to a managed object, we can resolve the original managed object if (externalComObject is not null && WindowsRuntimeComWrappersMarshal.IsReferenceToManagedObjectUnsafe(externalComObject)) { @@ -79,6 +92,7 @@ public static bool TryGetManagedObject(void* externalComObject, [NotNullWhen(tru result = null; return false; +#endif } /// @@ -89,6 +103,9 @@ public static bool TryGetManagedObject(void* externalComObject, [NotNullWhen(tru /// Whether was a reference to a native object, and could be retrieved. public static bool TryGetNativeObject([NotNullWhen(true)] object? managedObject, out void* result) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY // If the input object is wrapping a native object, we can unwrap it and return it after incrementing its reference count if (WindowsRuntimeComWrappersMarshal.TryUnwrapObjectReference(managedObject, out WindowsRuntimeObjectReference? objectReference)) { @@ -100,6 +117,7 @@ public static bool TryGetNativeObject([NotNullWhen(true)] object? managedObject, result = null; return false; +#endif } /// @@ -120,7 +138,11 @@ public static bool TryGetNativeObject([NotNullWhen(true)] object? managedObject, /// public static void* ConvertToUnmanaged(object? managedObject) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return WindowsRuntimeUnknownMarshaller.ConvertToUnmanaged(managedObject).DetachThisPtrUnsafe(); +#endif } /// @@ -132,7 +154,11 @@ public static bool TryGetNativeObject([NotNullWhen(true)] object? managedObject, /// public static object? ConvertToManaged(void* value) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY return WindowsRuntimeObjectMarshaller.ConvertToManaged(value); +#endif } /// @@ -146,6 +172,10 @@ public static bool TryGetNativeObject([NotNullWhen(true)] object? managedObject, /// public static void Free(void* value) { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + throw null; +#elif WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY WindowsRuntimeUnknownMarshaller.Free(value); +#endif } } \ No newline at end of file diff --git a/src/WinRT.Runtime2/WindowsRuntimeInspectable.cs b/src/WinRT.Runtime2/NativeObjects/WindowsRuntimeInspectable.cs similarity index 100% rename from src/WinRT.Runtime2/WindowsRuntimeInspectable.cs rename to src/WinRT.Runtime2/NativeObjects/WindowsRuntimeInspectable.cs diff --git a/src/WinRT.Runtime2/Properties/WindowsRuntimeFeatureSwitches.cs b/src/WinRT.Runtime2/Properties/WindowsRuntimeFeatureSwitches.cs index 99d5d20c94..7d9d247c6e 100644 --- a/src/WinRT.Runtime2/Properties/WindowsRuntimeFeatureSwitches.cs +++ b/src/WinRT.Runtime2/Properties/WindowsRuntimeFeatureSwitches.cs @@ -4,6 +4,8 @@ using System; using System.Diagnostics.CodeAnalysis; +#pragma warning disable CS1574 + namespace WindowsRuntime; /// diff --git a/src/WinRT.Runtime2/WinRT.Runtime.csproj b/src/WinRT.Runtime2/WinRT.Runtime.csproj index 01ac0e7767..452f24bd9e 100644 --- a/src/WinRT.Runtime2/WinRT.Runtime.csproj +++ b/src/WinRT.Runtime2/WinRT.Runtime.csproj @@ -78,6 +78,89 @@ true key.snk + + + + false + + + $(DefineConstants);WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY + + + + + $(DefineConstants);WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + + + $(NoWarn);CS8597;IDE0005;IDE0380 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false $(DefineConstants);WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY - + + + $(DefineConstants);WINDOWS_RUNTIME_REFERENCE_ASSEMBLY $(NoWarn);CS8597;IDE0005;IDE0380 + + + $(WarningsAsErrors);RS0030 + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs b/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs index 97e5356d8f..727f34a9f0 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE + using WindowsRuntime; namespace Windows.Foundation; From a1a04c4f1d4d8b796ebd04960dc3980ebdf37129 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 17 Jun 2026 15:29:04 -0700 Subject: [PATCH 5/8] Add a reference-assembly-only constructor for WindowsRuntimeObject (#2448) * Bring back WindowsRuntimeConstants for the WindowsRuntimeObject constructor Re-add the type removed in #2434, now holding the dedicated obsolete message, diagnostic id (CSWINRT3001) and URL format used to flag the reference-assembly-only WindowsRuntimeObject constructor. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Add a reference-assembly-only constructor for WindowsRuntimeObject After #2446 all WindowsRuntimeObject constructors live in the implementation-only WindowsRuntimeObject.Impl.cs and are stripped from the reference assembly, so the compiler would synthesize a protected parameterless constructor. That constructor is absent from the implementation assembly and would throw MissingMethodException at runtime if a user type derived from WindowsRuntimeObject. Explicitly define it for the reference assembly only, marked obsolete (CSWINRT3001) and hidden, so deriving from WindowsRuntimeObject produces a build diagnostic instead. Only generated projections may derive from it. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Add back the CSWINRT3001 diagnostics doc Re-add the diagnostics doc removed in #2434, updated for the new scenario (deriving from WindowsRuntimeObject is not supported), and rename it to match the diagnostic id (updating the solution reference, which was previously dangling). Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/diagnostics/cswinrt3001.md | 28 ++++++++++++++++ .../Properties/WindowsRuntimeConstants.cs | 32 +++++++++++++++++++ src/WinRT.Runtime2/WindowsRuntimeObject.cs | 21 ++++++++++++ src/cswinrt.slnx | 2 +- 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 docs/diagnostics/cswinrt3001.md create mode 100644 src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs diff --git a/docs/diagnostics/cswinrt3001.md b/docs/diagnostics/cswinrt3001.md new file mode 100644 index 0000000000..3c5c34a265 --- /dev/null +++ b/docs/diagnostics/cswinrt3001.md @@ -0,0 +1,28 @@ +# CsWinRT warning CSWINRT3001 + +Deriving from `WindowsRuntimeObject` is only supported for projected types generated by CsWinRT. The parameterless `WindowsRuntimeObject` constructor is a private implementation detail: it is only defined in the reference assembly for `WinRT.Runtime.dll`, and it is not present in the actual implementation assembly that is used when the application runs. Deriving from `WindowsRuntimeObject` in user code will result in a `MissingMethodException` being thrown at runtime. + +For instance, the following sample generates CSWINRT3001: + +```csharp +using WindowsRuntime; + +namespace MyProgram; + +// CSWINRT3001: deriving from 'WindowsRuntimeObject' is not supported +public sealed class MyObject : WindowsRuntimeObject +{ +} +``` + +## Additional resources + +`CSWINRT3001` is emitted when user code derives from `WindowsRuntimeObject`, the base type for all projected Windows Runtime classes in `WinRT.Runtime.dll`. Only projections generated by CsWinRT are allowed to derive from this type: the generated projections (produced by `cswinrtprojectiongen.exe` and `cswinrtprojectionrefgen.exe`) chain to dedicated, private implementation detail constructors that are only present in the implementation `WinRT.Runtime.dll`. When building a reference assembly for `WinRT.Runtime.dll`, those implementation constructors are stripped. + +## Recommended action + +- Do not derive from `WindowsRuntimeObject` in user code. +- If you are authoring a Windows Runtime component, define your types normally and let CsWinRT generate the projection that derives from `WindowsRuntimeObject` for you. +- If you need to wrap a native Windows Runtime object, consider just storing the projected object in your class, or using the supported marshalling APIs in `WinRT.Runtime.dll` instead of deriving from `WindowsRuntimeObject` directly. + +Keeping `WindowsRuntimeObject` derivation exclusive to generated projections is what allows CsWinRT to deliver fast, safe interop while evolving rapidly. Respecting the diagnostic ensures your applications remain stable across updates (and also avoids `MissingMethodException` failures at runtime when updating the CsWinRT version). diff --git a/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs b/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs new file mode 100644 index 0000000000..befb33eb05 --- /dev/null +++ b/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace WindowsRuntime; + +/// +/// A type containing constants for various scenarios related to Windows Runtime functionality and projections. +/// +internal static class WindowsRuntimeConstants +{ + /// + /// A message for the parameterless constructor. + /// + public const string WindowsRuntimeObjectConstructorObsoleteMessage = + "This constructor is a private implementation detail, and it must never be used. Deriving from 'WindowsRuntimeObject' is only " + + "supported for projected types generated by CsWinRT (produced by 'cswinrtprojectiongen.exe' and 'cswinrtprojectionrefgen.exe'), " + + "and it is not supported for user-defined types. This constructor is not present in the actual implementation assembly. " + + "Deriving from 'WindowsRuntimeObject' in user code will result in a 'MissingMethodException' being thrown at runtime."; + + /// + /// The diagnostic id for the parameterless constructor. + /// + public const string WindowsRuntimeObjectConstructorObsoleteDiagnosticId = "CSWINRT3001"; + + /// + /// The URL format for all custom diagnostics for CsWinRT. + /// + /// + /// This URL format assumes it will receive the diagnostic id as a parameter. + /// + public const string CsWinRTDiagnosticsUrlFormat = "https://aka.ms/cswinrt/errors/{0}"; +} diff --git a/src/WinRT.Runtime2/WindowsRuntimeObject.cs b/src/WinRT.Runtime2/WindowsRuntimeObject.cs index 59df07ca40..06ed3d9891 100644 --- a/src/WinRT.Runtime2/WindowsRuntimeObject.cs +++ b/src/WinRT.Runtime2/WindowsRuntimeObject.cs @@ -2,6 +2,9 @@ // Licensed under the MIT License. using System; +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +using System.ComponentModel; +#endif using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; @@ -18,6 +21,24 @@ public abstract partial class WindowsRuntimeObject : IUnmanagedVirtualMethodTableProvider, ICustomQueryInterface { +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY + /// + /// Creates a instance. + /// + /// + /// Deriving from is only supported for projected types generated by CsWinRT, + /// and invoking this from a user-defined type will result in a at runtime. + /// + [Obsolete(WindowsRuntimeConstants.WindowsRuntimeObjectConstructorObsoleteMessage, + DiagnosticId = WindowsRuntimeConstants.WindowsRuntimeObjectConstructorObsoleteDiagnosticId, + UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + protected WindowsRuntimeObject() + { + throw null; + } +#endif + /// RuntimeTypeHandle IDynamicInterfaceCastable.GetInterfaceImplementation(RuntimeTypeHandle interfaceType) { diff --git a/src/cswinrt.slnx b/src/cswinrt.slnx index 08bde562fe..4312c4f3b9 100644 --- a/src/cswinrt.slnx +++ b/src/cswinrt.slnx @@ -38,7 +38,7 @@ - + From b9f064dead821dcf069e0e58f25f575836b1763b Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 18 Jun 2026 08:55:58 -0700 Subject: [PATCH 6/8] Package the WinRT.Runtime reference assembly (#2451) Make the dual reference-assembly build for WinRT.Runtime (set up via the 'CsWinRTBuildReferenceAssembly' switch) functional end to end, so the NuGet package ships a proper reference assembly under 'ref\net10.0'. The reference build recompiles WinRT.Runtime with all implementation-only types stripped out, producing a lightweight metadata-only assembly along with an XML doc that is likewise stripped to the public reference surface. NuGet binds the compiler to the 'ref' assembly (and the runtime to the 'lib' assembly), and the compiler resolves XML docs next to the compile-time assembly, so the stripped XML is shipped next to the reference assembly in 'ref\net10.0' (IntelliSense then shows only the public surface). The 'lib' folder ships only the implementation assembly; its XML doc is not packaged, since it would never be surfaced and only documents implementation details. The reference build is run as AnyCPU, matching how the solution builds the implementation assembly, so its outputs land in the platform-less 'bin\\net10.0' and 'obj\\net10.0\ref' folders. Because the reference build overwrites the 'bin' outputs, the implementation assembly is staged out before it runs, and both are packaged from the staging folder. - nuget: ship 'ref\net10.0\WinRT.Runtime.dll' and its XML (lib has dll only) - build.cmd: stage the impl dll, build the reference assembly, stage ref dll + xml - CsWinRT-Build-Steps.yml: build and stage the reference assembly and its XML - CsWinRT-PublishToNuGet-Steps.yml: add the 'net10_runtime_ref(_xml)' props Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CsWinRT-Build-Steps.yml | 31 ++++++++++++++++- .../CsWinRT-PublishToNuGet-Steps.yml | 3 +- nuget/Microsoft.Windows.CsWinRT.nuspec | 3 +- src/build.cmd | 33 +++++++++++++++++-- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/build/AzurePipelineTemplates/CsWinRT-Build-Steps.yml b/build/AzurePipelineTemplates/CsWinRT-Build-Steps.yml index 64b692a3bb..55fe6b5ec6 100644 --- a/build/AzurePipelineTemplates/CsWinRT-Build-Steps.yml +++ b/build/AzurePipelineTemplates/CsWinRT-Build-Steps.yml @@ -237,9 +237,38 @@ steps: Contents: | WinRT.Runtime.dll WinRT.Runtime.pdb - WinRT.Runtime.xml TargetFolder: $(StagingFolder)\net10.0 + # Build the WinRT.Runtime reference assembly, with implementation-only types stripped out. Like the + # implementation assembly, it is built as AnyCPU (no platform), so its outputs land in the platform-less + # 'bin\\net10.0' and 'obj\\net10.0\ref' folders. It is staged after the implementation + # assembly (above), since the reference build overwrites the 'bin' outputs. + - task: VSBuild@1 + displayName: Build WinRT.Runtime reference assembly + condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) + inputs: + solution: $(Build.SourcesDirectory)\src\WinRT.Runtime2\WinRT.Runtime.csproj + msbuildArgs: /restore /p:VersionNumber=$(VersionNumber),VersionString=$(Build.BuildNumber),AssemblyVersionNumber=$(WinRT.Runtime.AssemblyVersion),CsWinRTBuildReferenceAssembly=true,ContinuousIntegrationBuild=true + configuration: $(BuildConfiguration) + + # Stage WinRT.Runtime reference assembly (metadata-only assembly produced under 'obj\...\ref') + - task: CopyFiles@2 + displayName: Stage WinRT.Runtime reference assembly + condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) + inputs: + SourceFolder: $(Build.SourcesDirectory)\src\WinRT.Runtime2\obj\$(BuildConfiguration)\net10.0\ref + Contents: WinRT.Runtime.dll + TargetFolder: $(StagingFolder)\net10.0\ref + + # Stage WinRT.Runtime reference assembly XML documentation (stripped to the reference surface) + - task: CopyFiles@2 + displayName: Stage WinRT.Runtime reference assembly XML + condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) + inputs: + SourceFolder: $(Build.SourcesDirectory)\src\WinRT.Runtime2\bin\$(BuildConfiguration)\net10.0 + Contents: WinRT.Runtime.xml + TargetFolder: $(StagingFolder)\net10.0\ref + # Stage WinRT.Host.Shim - task: CopyFiles@2 displayName: Stage WinRT.Host.Shim diff --git a/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml b/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml index 6c09c44fc8..4fb62c6480 100644 --- a/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml +++ b/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml @@ -99,7 +99,8 @@ steps: cswinrt_nuget_version=$(NugetVersion);\ interop_winmd=$(Build.SourcesDirectory)\\release_x86\\native\\WindowsRuntime.Internal.winmd;\ net10_runtime=$(Build.SourcesDirectory)\\release_x86\\net10.0\\WinRT.Runtime.dll;\ - net10_runtime_xml=$(Build.SourcesDirectory)\\release_x86\\net10.0\\WinRT.Runtime.xml;\ + net10_runtime_ref=$(Build.SourcesDirectory)\\release_x86\\net10.0\\ref\\WinRT.Runtime.dll;\ + net10_runtime_ref_xml=$(Build.SourcesDirectory)\\release_x86\\net10.0\\ref\\WinRT.Runtime.xml;\ source_generator=$(Build.SourcesDirectory)\\release_x86\\net10.0\\WinRT.SourceGenerator.dll;\ winrt_shim=$(Build.SourcesDirectory)\\release_x86\\net10.0\\WinRT.Host.Shim.dll;\ winrt_host_x86=$(Build.SourcesDirectory)\\release_x86\\native\\WinRT.Host.dll;\ diff --git a/nuget/Microsoft.Windows.CsWinRT.nuspec b/nuget/Microsoft.Windows.CsWinRT.nuspec index 28a6113f82..20f6970078 100644 --- a/nuget/Microsoft.Windows.CsWinRT.nuspec +++ b/nuget/Microsoft.Windows.CsWinRT.nuspec @@ -34,7 +34,8 @@ - + + diff --git a/src/build.cmd b/src/build.cmd index 51f471e172..ab4c18a5eb 100644 --- a/src/build.cmd +++ b/src/build.cmd @@ -118,6 +118,32 @@ if ErrorLevel 1 ( exit /b !ErrorLevel! ) +rem Build the WinRT.Runtime reference assembly. This recompiles WinRT.Runtime with all implementation-only +rem types stripped out (via 'CsWinRTBuildReferenceAssembly=true'), producing a lightweight reference assembly +rem (and its matching, stripped XML documentation) for packaging under 'ref\net10.0'. Like the implementation +rem assembly, it is built as AnyCPU (no platform), so its outputs land in the platform-less 'bin\\net10.0' +rem and 'obj\\net10.0\ref' folders. The reference build overwrites the implementation assembly in 'bin', +rem so the implementation outputs are staged out first, and both are then packaged from the staging folder. +set winrt_runtime_bin=%this_dir%WinRT.Runtime2\bin\%cswinrt_configuration%\net10.0\ +set winrt_runtime_staging=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\WinRT.Runtime\ + +echo Staging WinRT.Runtime implementation assembly for %cswinrt_platform% %cswinrt_configuration% +if not exist "%winrt_runtime_staging%lib\" mkdir "%winrt_runtime_staging%lib\" +copy /y "%winrt_runtime_bin%WinRT.Runtime.dll" "%winrt_runtime_staging%lib\WinRT.Runtime.dll" + +echo Building WinRT.Runtime reference assembly for %cswinrt_platform% %cswinrt_configuration% +call :exec %msbuild_path%msbuild.exe %cswinrt_build_params% /restore /p:configuration=%cswinrt_configuration%;VersionNumber=%cswinrt_version_number%;VersionString=%cswinrt_version_string%;AssemblyVersionNumber=%cswinrt_assembly_version%;CsWinRTBuildReferenceAssembly=true %this_dir%WinRT.Runtime2\WinRT.Runtime.csproj +if ErrorLevel 1 ( + echo. + echo ERROR: Reference assembly build failed + exit /b !ErrorLevel! +) + +echo Staging WinRT.Runtime reference assembly for %cswinrt_platform% %cswinrt_configuration% +if not exist "%winrt_runtime_staging%ref\" mkdir "%winrt_runtime_staging%ref\" +copy /y "%this_dir%WinRT.Runtime2\obj\%cswinrt_configuration%\net10.0\ref\WinRT.Runtime.dll" "%winrt_runtime_staging%ref\WinRT.Runtime.dll" +copy /y "%winrt_runtime_bin%WinRT.Runtime.xml" "%winrt_runtime_staging%ref\WinRT.Runtime.xml" + rem skip tests for now goto :package @@ -270,8 +296,9 @@ if "%cswinrt_label%"=="functionaltest" exit /b 0 rem We set the properties of the CsWinRT.nuspec here, and pass them as the -Properties option when we call `nuget pack` set cswinrt_bin_dir=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\cswinrt\bin\ set interop_winmd=%this_dir%WinRT.Internal\bin\%cswinrt_configuration%\net10.0-windows10.0.26100.1\WindowsRuntime.Internal.winmd -set net10_runtime=%this_dir%WinRT.Runtime2\bin\%cswinrt_configuration%\net10.0\WinRT.Runtime.dll -set net10_runtime_xml=%this_dir%WinRT.Runtime2\bin\%cswinrt_configuration%\net10.0\WinRT.Runtime.xml +set net10_runtime=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\WinRT.Runtime\lib\WinRT.Runtime.dll +set net10_runtime_ref=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\WinRT.Runtime\ref\WinRT.Runtime.dll +set net10_runtime_ref_xml=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\WinRT.Runtime\ref\WinRT.Runtime.xml set source_generator_roslyn4120=%this_dir%Authoring\WinRT.SourceGenerator.Roslyn4120\bin\%cswinrt_configuration%\netstandard2.0\WinRT.SourceGenerator.dll set source_generator=%this_dir%Authoring\WinRT.SourceGenerator2\bin\%cswinrt_configuration%\net10.0\WinRT.SourceGenerator.dll set winrt_host_%cswinrt_platform%=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\WinRT.Host\bin\WinRT.Host.dll @@ -286,7 +313,7 @@ set run_cswinrt_generator_task=%this_dir%WinRT.Generator.Tasks\bin\%cswinrt_conf rem Now call pack echo Creating nuget package -call :exec %nuget_dir%\nuget pack %this_dir%..\nuget\Microsoft.Windows.CsWinRT.nuspec -Properties interop_winmd=%interop_winmd%;net10_runtime=%net10_runtime%;net10_runtime_xml=%net10_runtime_xml%;source_generator=%source_generator%;cswinrt_nuget_version=%cswinrt_version_string%;winrt_host_x86=%winrt_host_x86%;winrt_host_x64=%winrt_host_x64%;winrt_host_arm=%winrt_host_arm%;winrt_host_arm64=%winrt_host_arm64%;winrt_host_resource_x86=%winrt_host_resource_x86%;winrt_host_resource_x64=%winrt_host_resource_x64%;winrt_host_resource_arm=%winrt_host_resource_arm%;winrt_host_resource_arm64=%winrt_host_resource_arm64%;winrt_shim=%winrt_shim%;cswinrtinteropgen_x64=%cswinrtinteropgen_x64%;cswinrtinteropgen_arm64=%cswinrtinteropgen_arm64%;cswinrtimplgen_x64=%cswinrtimplgen_x64%;cswinrtimplgen_arm64=%cswinrtimplgen_arm64%;cswinrtprojectiongen_x64=%cswinrtprojectiongen_x64%;cswinrtprojectiongen_arm64=%cswinrtprojectiongen_arm64%;cswinrtprojectionrefgen_x64=%cswinrtprojectionrefgen_x64%;cswinrtprojectionrefgen_arm64=%cswinrtprojectionrefgen_arm64%;cswinrtwinmdgen_x64=%cswinrtwinmdgen_x64%;cswinrtwinmdgen_arm64=%cswinrtwinmdgen_arm64%;run_cswinrt_generator_task=%run_cswinrt_generator_task%; -OutputDirectory %cswinrt_bin_dir% -NonInteractive -Verbosity Detailed -NoPackageAnalysis +call :exec %nuget_dir%\nuget pack %this_dir%..\nuget\Microsoft.Windows.CsWinRT.nuspec -Properties interop_winmd=%interop_winmd%;net10_runtime=%net10_runtime%;net10_runtime_ref=%net10_runtime_ref%;net10_runtime_ref_xml=%net10_runtime_ref_xml%;source_generator=%source_generator%;cswinrt_nuget_version=%cswinrt_version_string%;winrt_host_x86=%winrt_host_x86%;winrt_host_x64=%winrt_host_x64%;winrt_host_arm=%winrt_host_arm%;winrt_host_arm64=%winrt_host_arm64%;winrt_host_resource_x86=%winrt_host_resource_x86%;winrt_host_resource_x64=%winrt_host_resource_x64%;winrt_host_resource_arm=%winrt_host_resource_arm%;winrt_host_resource_arm64=%winrt_host_resource_arm64%;winrt_shim=%winrt_shim%;cswinrtinteropgen_x64=%cswinrtinteropgen_x64%;cswinrtinteropgen_arm64=%cswinrtinteropgen_arm64%;cswinrtimplgen_x64=%cswinrtimplgen_x64%;cswinrtimplgen_arm64=%cswinrtimplgen_arm64%;cswinrtprojectiongen_x64=%cswinrtprojectiongen_x64%;cswinrtprojectiongen_arm64=%cswinrtprojectiongen_arm64%;cswinrtprojectionrefgen_x64=%cswinrtprojectionrefgen_x64%;cswinrtprojectionrefgen_arm64=%cswinrtprojectionrefgen_arm64%;cswinrtwinmdgen_x64=%cswinrtwinmdgen_x64%;cswinrtwinmdgen_arm64=%cswinrtwinmdgen_arm64%;run_cswinrt_generator_task=%run_cswinrt_generator_task%; -OutputDirectory %cswinrt_bin_dir% -NonInteractive -Verbosity Detailed -NoPackageAnalysis goto :eof :exec From a10559abbcb856a52fbd856c4270fb04a37a4a45 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 18 Jun 2026 09:46:52 -0700 Subject: [PATCH 7/8] Document the WinRT.Runtime reference assembly and impl-only APIs (#2452) * Add docs for reference assembly and impl-only API Document the WinRT.Runtime dual-build (implementation + stripped reference assembly) and the implementation-only API workflow. Updates include: explaining CsWinRTBuildReferenceAssembly and compilation symbols (WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY / WINDOWS_RUNTIME_REFERENCE_ASSEMBLY / WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE), ProduceReferenceAssembly=false behavior, the WindowsRuntimeImplementationOnlyMember attribute, BannedSymbols.txt + Microsoft.CodeAnalysis.BannedApiAnalyzers guard, reference-only WindowsRuntimeObject() constructor and CSWINRT3001 diagnostic, and packaging into ref\net10.0 alongside lib\net10.0. Also update interop-generator SKILL and reference docs to note that generator-consumed runtime APIs are marked as implementation-only and stripped from the reference assembly to ensure version compatibility. * Add docs for implementation-only WinRT.Runtime types Add a new "Implementation-only types consumed from WinRT.Runtime" section to .github/skills/interop-generator/SKILL.md describing the categories of implementation-only APIs the generator calls (ABI marshallers, scalar/object/delegate marshallers, array marshallers, native object wrappers, interface method implementations, collection adapters, ComWrappers/object-reference types, event sources, type-map groups/attributes, IID table/error helpers). Explain that these APIs live only in the WinRT.Runtime implementation assembly, that generated code emits [IgnoresAccessChecksTo] to reach them, and note the need to version-match cswinrtinteropgen to the targeted WinRT.Runtime. Also update .github/skills/update-interop-generator-instructions/SKILL.md to add a verification step to ensure the implementation-only types inventory is current and reconciled with References/InteropReferences.cs and the WinRT.Runtime implementation. --- .github/copilot-instructions.md | 17 ++++++++++++++++- .github/skills/interop-generator/SKILL.md | 19 ++++++++++++++++++- .../references/marshalling-arrays.md | 2 +- .../marshalling-generic-interfaces.md | 2 +- .../update-copilot-instructions/SKILL.md | 1 + .../SKILL.md | 2 ++ 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 278620869f..57575b09e5 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -173,13 +173,16 @@ The runtime library (`WinRT.Runtime.dll`) provides all common infrastructure for - **Warnings as errors**: release only. `EnforceCodeStyleInBuild` enabled, `AnalysisLevelStyle` = `latest-all`. - **Strong-name signed** with `key.snk` - **AOT compatible**: `IsAotCompatible = true` +- **Dual-built**: produces both the implementation assembly and a stripped **reference assembly** (see "Reference assembly" below); the reference build adds a `Microsoft.CodeAnalysis.BannedApiAnalyzers` reference **Directory structure:** ``` WinRT.Runtime2/ -├── WindowsRuntimeObject.cs # Base class for ALL projected runtime classes +├── WindowsRuntimeObject.cs # Base class for ALL projected runtime classes (partial; reference + shared surface) +├── WindowsRuntimeObject.Impl.cs # Implementation-only half of WindowsRuntimeObject (excluded from the reference assembly) ├── WindowsRuntimeInspectable.cs # Fallback type for unknown native objects +├── BannedSymbols.txt # Banned API list for the reference assembly build (blocks implementation-only types from leaking) ├── ABI/ # ABI type mappings (managed ↔ native) │ ├── System/ # Primitives, String, Uri, DateTimeOffset, collections, etc. │ ├── Windows.Foundation/ # Foundation types (Point, Rect, Size, etc.) @@ -242,6 +245,17 @@ WinRT.Runtime2/ - **T4 templates**: 6 `.tt` files generate constants (`HRESULT` codes, interface IIDs, XAML class names) and specialized marshallers (blittable array types). - **Feature switches**: opt-in/opt-out runtime features are controlled via `[FeatureSwitchDefinition]`-annotated properties in `WindowsRuntimeFeatureSwitches` (`Properties/WindowsRuntimeFeatureSwitches.cs`). Each switch is backed by an `AppContext` configuration property (e.g. `CSWINRT_ENABLE_MANIFEST_FREE_ACTIVATION`) and wired to an MSBuild property (e.g. `CsWinRTEnableManifestFreeActivation`) in `nuget/Microsoft.Windows.CsWinRT.targets`, which emits `RuntimeHostConfigurationOption` items with `Trim="true"`. This lets ILLink (trimming) and ILC (Native AOT) treat the switch values as constants and dead-code-eliminate all code behind disabled switches, making opt-in features fully pay-for-play. +**Reference assembly:** + +`WinRT.Runtime` is built **twice**: once as the implementation assembly (the actual `WinRT.Runtime.dll` that runs) and once as a lightweight **reference assembly** that downstream tooling and `ProjectReference` consumers compile against. The reference build is selected via the `CsWinRTBuildReferenceAssembly` MSBuild property and strips out every implementation-only type and member, so none of them are exposed on the public API surface. + +- **Compilation symbols**: the implementation build defines `WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY`; the reference build defines `WINDOWS_RUNTIME_REFERENCE_ASSEMBLY`. Members that differ between the two (e.g. the explicit interface implementations on `WindowsRuntimeObject`, which become `throw null` stubs) are guarded with `#if`/`#elif` on these symbols. An entire source file can opt out of the reference assembly by placing `#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE` at the top: the `RemoveWindowsRuntimeImplementationOnlyFiles` target removes those files (plus the whole `ABI/`, `NativeObjects/`, `Exceptions/`, `Windows.UI.Xaml.Interop/`, and most `InteropServices/` subfolders) before `CoreCompile`. +- **`ProduceReferenceAssembly = false`**: the implementation build disables the SDK's automatic reference assembly, because `WinRT.Runtime` ships its own (the SDK-generated one would leak the implementation-only types to consumers and break reference projections). +- **`[WindowsRuntimeImplementationOnlyMember]`** (`Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs`): an `internal sealed`, `[Conditional("WINDOWS_RUNTIME_REFERENCE_ASSEMBLY")]` marker placed on implementation-only types/members (including most of the marker attributes under `Attributes/`). It replaces the older `[Obsolete] + [EditorBrowsable(Never)]` combination, makes the intent explicit, and is only ever emitted into the reference assembly (where it is stripped along with the members it marks). +- **Banned API analyzer**: the reference build references `Microsoft.CodeAnalysis.BannedApiAnalyzers` and lists `WindowsRuntimeImplementationOnlyMemberAttribute` in `BannedSymbols.txt`, with `RS0030` promoted to an error, so the build fails if any implementation-only type ever leaks into the reference surface. It also suppresses warnings that only appear in the stripped build (`CS8597`, `IDE0005`, `IDE0380`). +- **Reference-assembly-only `WindowsRuntimeObject()` constructor**: a parameterless `protected` constructor exists only in the reference assembly (`#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY`). It is marked `[Obsolete(..., DiagnosticId = "CSWINRT3001")]`, so user code that derives from `WindowsRuntimeObject` gets the `CSWINRT3001` warning; because the constructor is absent from the implementation assembly, doing so throws `MissingMethodException` at runtime. Only CsWinRT-generated projections may derive from `WindowsRuntimeObject`. The related messages live in `Properties/WindowsRuntimeConstants.cs`. +- **Packaging**: the implementation assembly ships in `lib\net10.0\` of the `Microsoft.Windows.CsWinRT` NuGet package, and the reference assembly (with its XML documentation, trimmed to the reference surface) ships in `ref\net10.0\`. The dual build and staging are driven by `src/build.cmd` and the Azure Pipelines build steps. + **Types projected in WinRT.Runtime:** Not all WinRT types are generated automatically by the projection writer into SDK projection assemblies. `WinRT.Runtime` contains two categories of types that require special handling: @@ -713,6 +727,7 @@ All five .NET build tools (`cswinrtprojectionrefgen`, `cswinrtprojectiongen`, `c | Impl Generator | `CSWINRTIMPLGENxxxx` | `0001`–`0014`, `9999` | | Interop Generator | `CSWINRTINTEROPGENxxxx` | `0001`–`0097`, `9999` | | WinMD Generator | `CSWINRTWINMDGENxxxx` | `0001`–`0010`, `9999` | +| Runtime (obsolete markers) | `CSWINRT3xxx` | `CSWINRT3001` (deriving from `WindowsRuntimeObject`) | --- diff --git a/.github/skills/interop-generator/SKILL.md b/.github/skills/interop-generator/SKILL.md index 96e5d16114..a85c8beaa9 100644 --- a/.github/skills/interop-generator/SKILL.md +++ b/.github/skills/interop-generator/SKILL.md @@ -32,7 +32,7 @@ The `WinRT.Interop.dll` assembly is produced by `cswinrtinteropgen`, which is a - If a project **does not** reference CsWinRT, then `cswinrtinteropgen` is loaded from the Windows SDK projections targeting pack. - If CsWinRT **is** referenced (directly or transitively), then `cswinrtinteropgen` is loaded from that package, but only if the `WinRT.Runtime.dll` binary from that package has a higher version than the one in the Windows SDK projections package being referenced. This correctly handles cases where a dependent project might have a reference to an outdated CsWinRT package. -This version matching is critical because `cswinrtinteropgen` relies on "implementation details only" APIs in `WinRT.Runtime.dll` — APIs which are public, hidden, and marked as `[Obsolete]`, and which are exclusively meant to be consumed by generated code produced by `cswinrtinteropgen`. These APIs might change at any time without following semantic versioning for CsWinRT. For instance, they are crucial to support marshalling generic Windows Runtime collection interfaces, and the code in `WinRT.Interop.dll` makes heavy use of them in this scenario. +This version matching is critical because `cswinrtinteropgen` relies on "implementation details only" APIs in `WinRT.Runtime.dll` — APIs which are public in the implementation assembly but marked with `[WindowsRuntimeImplementationOnlyMember]` and stripped from the `WinRT.Runtime.dll` reference assembly (so they never surface to consumers), and which are exclusively meant to be consumed by generated code produced by `cswinrtinteropgen`. These APIs might change at any time without following semantic versioning for CsWinRT. For instance, they are crucial to support marshalling generic Windows Runtime collection interfaces, and the code in `WinRT.Interop.dll` makes heavy use of them in this scenario. ## Project settings @@ -720,6 +720,23 @@ The generated `WinRT.Interop.dll` does not operate in isolation — it works in For detailed control flow of generic interface marshalling, see `references/marshalling-generic-interfaces.md`. For array marshalling, see `references/marshalling-arrays.md`. For the generated type name mangling scheme, see `references/name-mangling-scheme.md`. +### Implementation-only types consumed from WinRT.Runtime + +Almost everything the generated code calls into lives in `WinRT.Runtime.dll` as **implementation-only** APIs: public in the implementation assembly, marked `[WindowsRuntimeImplementationOnlyMember]` (or living in folders excluded from the reference build, such as `ABI/`, `NativeObjects/`, and most of `InteropServices/`), and stripped from the reference assembly. They are resolved through `References/InteropReferences.cs`. The main categories consumed are: + +- **ABI marshallers for custom-mapped types** (`ABI.System.*`, `ABI.Windows.Foundation.Collections.*`) — `DateTimeOffsetMarshaller`, `ExceptionMarshaller`, `TimeSpanMarshaller`, `TypeMarshaller`, `MapChangedEventHandlerEventSource`, `VectorChangedEventHandlerEventSource`. Emitted IL calls these to marshal custom-mapped values to/from their ABI form. +- **Scalar/object/delegate marshallers** (`WindowsRuntime.InteropServices.Marshalling`) — `WindowsRuntimeObjectMarshaller`, `WindowsRuntimeValueTypeMarshaller`, `WindowsRuntimeDelegateMarshaller`, `WindowsRuntimeKeyValuePairTypeMarshaller`, `WindowsRuntimeInterfaceMarshaller`, `WindowsRuntimeUnknownMarshaller`, `WindowsRuntimeUnsealedObjectMarshaller`, `HStringMarshaller`/`HStringReference`, `RestrictedErrorInfoExceptionMarshaller`. Generated vtable bodies call their `ConvertToUnmanaged`/`ConvertToManaged`/`Free` methods to marshal parameters and return values. +- **Array marshallers and element marshaller interfaces** (`WindowsRuntime.InteropServices.Marshalling`, under `SzArrays/`) — `WindowsRuntimeArrayMarshaller`, `WindowsRuntimeObjectArrayMarshaller`, `WindowsRuntimeBlittableValueTypeArrayMarshaller`, `WindowsRuntimeReferenceTypeArrayMarshaller`, `WindowsRuntimeManagedValueTypeArrayMarshaller`, `WindowsRuntimeUnmanagedValueTypeArrayMarshaller`, `WindowsRuntimeKeyValuePairTypeArrayMarshaller`, `WindowsRuntimeNullableTypeArrayMarshaller`, plus the `IWindowsRuntime*ArrayElementMarshaller<...>` interfaces. Generated SZ-array marshaller types call the array marshallers (parameterized by an element marshaller), and emitted element marshallers implement the element interfaces (see `references/marshalling-arrays.md`). +- **Native object (RCW) base wrappers** (`WindowsRuntime`, defined under `NativeObjects/`) — `WindowsRuntimeList<...>`, `WindowsRuntimeReadOnlyList<...>`, `WindowsRuntimeDictionary<...>`, `WindowsRuntimeReadOnlyDictionary<...>`, `WindowsRuntimeEnumerable<...>`, `WindowsRuntimeEnumerator<...>`, `WindowsRuntimeObservableVector<...>`, `WindowsRuntimeObservableMap<...>`, `WindowsRuntimeAsyncOperation<...>`, `WindowsRuntimeAsyncActionWithProgress<...>`, `WindowsRuntimeAsyncOperationWithProgress<...>`, `DictionaryKeyCollection<...>`/`DictionaryValueCollection<...>` (and read-only variants). The generated sealed native object class for each generic instantiation derives from one of these. +- **Interface method implementations** (`WindowsRuntime.InteropServices`, under `Collections/`, `AsyncInfo/`, `ProjectionImpls/`) — the `*Methods`/`*MethodsImpl`/`*Impl` static holders containing the per-interface marshalling logic: `IEnumerableMethods`, `IListMethods`/`IListMethods`, `IDictionaryMethods`, `IReadOnlyListMethods`, `IIteratorMethods`, `IVectorMethodsImpl`, `IMapMethodsImpl`, `IMapViewMethodsImpl`, `IIterableMethodsImpl`, `IAsyncOperationMethodsImpl`, `IAsyncActionWithProgressMethodsImpl`, and the built-in COM impls `IUnknownImpl`, `IInspectableImpl`, `IStringableImpl`, `IPropertyValueImpl`, `IMarshalImpl`, `IAgileObjectImpl`, `IWeakReferenceSourceImpl`. Generated `TMethods` types and vtable bodies forward into these. +- **Collection adapters and adapter extensions** (`WindowsRuntime.InteropServices`, under `Collections/`) — `IListAdapter`, `IReadOnlyListAdapter`, `IDictionaryAdapter`, `IReadOnlyDictionaryAdapter`, `IEnumerableAdapter`, `IEnumeratorAdapter`, `BindableIReadOnlyListAdapter`, plus the per-element-category `*AdapterReferenceTypeExtensions` / `*BlittableValueTypeExtensions` / `*ManagedValueTypeExtensions` / `*UnmanagedValueTypeExtensions` / `*KeyValuePairTypeExtensions` / `*NullableTypeExtensions` types. Generated `GetMany` and collection vtable bodies call into the adapter extensions. +- **Object reference and ComWrappers infrastructure** (`WindowsRuntime.InteropServices`, under `ObjectReference/`, `Callbacks/`) — `WindowsRuntimeObjectReference`, `WindowsRuntimeObjectReferenceValue`, and the callback interfaces `IWindowsRuntimeObjectComWrappersCallback`, `IWindowsRuntimeArrayComWrappersCallback`, `IWindowsRuntimeUnsealedObjectComWrappersCallback`. Generated methods take/return `WindowsRuntimeObjectReference`/`WindowsRuntimeObjectReferenceValue` and manage COM lifetime (`AsValue`, `GetThisPtrUnsafe`, `Dispose`); generated ComWrappers callbacks implement the callback interfaces. +- **Event sources** (`WindowsRuntime.InteropServices`, mostly under `Events/`) — `EventSource`, `EventHandlerEventSource`/`EventHandlerEventSource`, `EventRegistrationToken`, `EventRegistrationTokenTable`, `IObservableVectorEventSourceFactory`, `IObservableMapEventSourceFactory`. Generated event marshalling derives from or instantiates these. +- **Type-map groups and metadata/marshalling attributes** (`WindowsRuntime`, `WindowsRuntime.InteropServices`, under `TypeMapGroups/`, `Attributes/`) — the markers `WindowsRuntimeComWrappersTypeMapGroup`, `WindowsRuntimeMetadataTypeMapGroup`, `DynamicInterfaceCastableImplementationTypeMapGroup`, and the attributes stamped onto generated types: `WindowsRuntimeMetadataAttribute`, `WindowsRuntimeMappedMetadataAttribute`, `WindowsRuntimeMetadataTypeNameAttribute`, `WindowsRuntimeDefaultInterfaceAttribute`, `WindowsRuntimeExclusiveToInterfaceAttribute`, `WindowsRuntimeReferenceTypeAttribute`, `WindowsRuntimeManagedOnlyTypeAttribute`, `WindowsRuntimeMappedTypeAttribute`, `WindowsRuntimeComWrappersMarshallerAttribute`. +- **IID table and error helpers** (`WindowsRuntime.InteropServices`) — `WellKnownInterfaceIIDs` (the generator emits `get_IID(...)` calls and reads the reserved-IID set) and `RestrictedErrorInfo` (`ThrowExceptionForHR`, etc., used in generated async/collection bodies to translate HRESULTs to exceptions). + +Because these APIs are absent from the `WinRT.Runtime.dll` reference assembly, the generated `WinRT.Interop.dll` references types that exist only in the implementation assembly, and the generator emits assembly-level `[IgnoresAccessChecksTo]` to reach the non-public members among them. This is also why `cswinrtinteropgen` must be version-matched to the `WinRT.Runtime.dll` it targets (see "Version compatibility" above): the shape of these types can change at any time. + ## Key patterns and conventions ### Naming conventions for generated types diff --git a/.github/skills/interop-generator/references/marshalling-arrays.md b/.github/skills/interop-generator/references/marshalling-arrays.md index 4c2bab60bb..0a449343c9 100644 --- a/.github/skills/interop-generator/references/marshalling-arrays.md +++ b/.github/skills/interop-generator/references/marshalling-arrays.md @@ -189,7 +189,7 @@ Five element marshaller interfaces are defined in `WindowsRuntime.InteropService | `IWindowsRuntimeKeyValuePairTypeArrayElementMarshaller` | `KeyValuePair` | `ConvertToUnmanaged(KeyValuePair)`, `ConvertToManaged(void*)` | | `IWindowsRuntimeNullableTypeArrayElementMarshaller` | `Nullable` | `ConvertToUnmanaged(T?)`, `ConvertToManaged(void*)` | -All are `static abstract` interfaces (using the C# static abstract member pattern), `[Obsolete]`, and `[EditorBrowsable(Never)]` — they are implementation details consumed only by generated code. +All are `static abstract` interfaces (using the C# static abstract member pattern) marked with `[WindowsRuntimeImplementationOnlyMember]`, so they are stripped from the `WinRT.Runtime.dll` reference assembly — they are implementation details consumed only by generated code. ### Runtime array marshaller classes (in `WinRT.Runtime.dll`) diff --git a/.github/skills/interop-generator/references/marshalling-generic-interfaces.md b/.github/skills/interop-generator/references/marshalling-generic-interfaces.md index 3797ea4868..4fab3f1fc0 100644 --- a/.github/skills/interop-generator/references/marshalling-generic-interfaces.md +++ b/.github/skills/interop-generator/references/marshalling-generic-interfaces.md @@ -286,7 +286,7 @@ For `GetMany` CCW methods, the runtime's collection adapter extension types (`IE | `IWindowsRuntimeKeyValuePairTypeElementMarshaller` | `KeyValuePair` | `ConvertToUnmanaged(KeyValuePair)` | | `IWindowsRuntimeNullableTypeElementMarshaller` | `Nullable` | `ConvertToUnmanaged(T?)` | -These are `static abstract` interfaces, `[Obsolete]`, and `[EditorBrowsable(Never)]` — implementation details consumed only by generated code. +These are `static abstract` interfaces marked with `[WindowsRuntimeImplementationOnlyMember]`, so they are stripped from the `WinRT.Runtime.dll` reference assembly — implementation details consumed only by generated code. **Runtime consumer example** — a `GetMany` extension method on `IEnumeratorAdapterExtensions`: diff --git a/.github/skills/update-copilot-instructions/SKILL.md b/.github/skills/update-copilot-instructions/SKILL.md index 4ecc0f49eb..acb75cae46 100644 --- a/.github/skills/update-copilot-instructions/SKILL.md +++ b/.github/skills/update-copilot-instructions/SKILL.md @@ -27,6 +27,7 @@ Launch parallel explore agents for each of the 12 CsWinRT 3.0 projects listed in - T4 templates (`.tt` files) are accurately listed - Project settings (TFM, language version, nullable, unsafe, etc.) are current - Namespace organization matches + - Reference assembly build is documented: the dual implementation/reference build driven by `CsWinRTBuildReferenceAssembly`, the `WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY` / `WINDOWS_RUNTIME_REFERENCE_ASSEMBLY` / `WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE` compilation symbols, the `[WindowsRuntimeImplementationOnlyMember]` marker attribute (`Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs`), the `BannedSymbols.txt` + `Microsoft.CodeAnalysis.BannedApiAnalyzers` guard (`RS0030` as error), the reference-assembly-only `WindowsRuntimeObject()` constructor (`CSWINRT3001` obsolete diagnostic), and packaging into `ref\net10.0\` alongside the implementation in `lib\net10.0\` (`src/build.cmd`, `nuget/Microsoft.Windows.CsWinRT.nuspec`) 2. **WinRT.SourceGenerator2 (`src/Authoring/WinRT.SourceGenerator2/`)** - Source generators listed still exist and generate what's described diff --git a/.github/skills/update-interop-generator-instructions/SKILL.md b/.github/skills/update-interop-generator-instructions/SKILL.md index 63ec9b20d5..d5bd89f9c5 100644 --- a/.github/skills/update-interop-generator-instructions/SKILL.md +++ b/.github/skills/update-interop-generator-instructions/SKILL.md @@ -96,6 +96,7 @@ Launch an explore agent to verify: - **Resolver classes** in `Resolvers/` are complete and accurately described (including `InterfaceIIDResolver`, which resolves IIDs from generated `ABI.InterfaceIIDs` types) - **Reference classes** in `References/` are complete (note the CsWinRT public key and system public key tokens come from `WellKnownPublicKeys`/`WellKnownPublicKeyTokens` in `WinRT.Generator.Core`) +- **Implementation-only types inventory** — verify the "Implementation-only types consumed from WinRT.Runtime" list in the `SKILL.md` "Control flow between generated code and WinRT.Runtime" section is complete and current. Cross-check its categories and representative type names against the WinRT.Runtime type references in `References/InteropReferences.cs` and against the `[WindowsRuntimeImplementationOnlyMember]`-marked types (and the stripped folders `ABI/`, `NativeObjects/`, and most of `InteropServices/`) in `src/WinRT.Runtime2/`. If implementation-only APIs were added to or removed from WinRT.Runtime, update the inventory accordingly - **Well-known interface IIDs** are current (native interface entry order, and the `ReservedIIDsMap` set — verify whether `IMarshal` is included; it is currently excluded because it can be user-overridden) - **Marshaller type resolution** logic is current @@ -154,6 +155,7 @@ These docs describe the *design* of the generated code patterns. If the actual g - `marshalling-arrays.md` includes the element marshaller infrastructure (runtime interfaces, runtime array marshaller classes, generated element marshaller types, selection logic table) - `marshalling-generic-interfaces.md` includes the collection element marshaller infrastructure (runtime interfaces, GetMany adapter extension methods, generated element marshaller types, emission/reuse pattern) +- The "implementation details only" APIs in `WinRT.Runtime.dll` that the generator consumes (the runtime element-marshaller interfaces, array marshaller classes, etc.) are marked with `[WindowsRuntimeImplementationOnlyMember]` and stripped from the `WinRT.Runtime.dll` reference assembly. If this marking scheme changes, update the `SKILL.md` "Version compatibility" section and the runtime-interface descriptions in both reference docs accordingly ### Step 14: update this skill if needed From af7069a60691fe9fe4756e799e46110f8d25bb06 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 1 Jul 2026 15:40:13 -0700 Subject: [PATCH 8/8] Add end-to-end smoke tests for the CsWinRT NuGet package (#2456) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add isolated infrastructure for end-to-end smoke tests Adds blank Directory.Build.props/.targets and a Directory.Packages.props that disables central package management, so the smoke tests can consume the real CsWinRT NuGet package in full isolation from the repository build infrastructure. A .gitignore keeps their default bin/obj output out of source control. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add consumption end-to-end smoke test A .NET app that parses a JSON object from Windows.Data.Json and round-trips it via Stringify, exercising the Windows SDK projection, the interop generator, and the WinRT.Runtime ref/impl assemblies against the real NuGet package. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add authoring end-to-end smoke test A Windows Runtime component library exposing a minimal class, exercising WinMD generation, the reference projection, and the forwarder assembly against the real NuGet package. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Build and run smoke tests in local and CI builds Adds a runner that builds and runs the consumption test and builds the authoring test against a given package source and version, and wires it into build.cmd (after the pack step, on x64) and the PublishToNuGet CI steps (after packing). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Verify the authoring smoke test produces a .winmd defining the expected type After building the component, the runner now locates the generated Authoring.winmd and asserts it is a Windows Runtime metadata file that defines the Authoring.Greeter type, using a dependency-free inspection that works in any PowerShell host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Trim comments and whitespace in smoke tests Remove explanatory comments and extra blank lines from SmokeTests projects and source files to reduce noise. Changes touch Authoring.csproj, Greeter.cs, Consumption.csproj, Program.cs, Directory.Build.props, Directory.Build.targets, and Directory.Packages.props. No functional code changes — only formatting and comment cleanup to keep the smoke test files minimal. * Centralize shared smoke test configuration in Directory.Build.props Moves the target framework, Windows SDK ref pack pin, NuGet restore sources, CsWinRT package version/source, and the CsWinRT package reference (all previously duplicated in both smoke test projects) into the shared SmokeTests Directory.Build.props. Each project now only declares what makes it different: the consumption app's output type and the authoring library's component flag. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Document the smoke tests and refresh test documentation Updates the testing skill and docs/structure.md to account for the new SmokeTests projects, and fixes other outdated test documentation: expands the SourceGenerator2Test analyzer test list (now CSWINRT2009-2017), corrects the AuthoringTest status and TFM, fixes the TestComponentCSharp IDL filename and the cswinrt.slnx reference, and lists the missing test projects in the repository structure doc. Also adds a smoke-tests verification step to the update-testing-instructions skill. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use the CsWinRTDependencies feed for smoke test restore CI agents cannot reach public NuGet (api.nuget.org), which broke the smoke test restore. Restore the preview Windows SDK ref pack from the repository's standard CsWinRTDependencies feed instead (the same feed the rest of the repo uses, e.g. src/WinRT.Internal), keeping the local CsWinRT build output as the source for the package under test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Keep type map group types in the WinRT.Runtime reference assembly The type map group types (WindowsRuntimeComWrappersTypeMapGroup, WindowsRuntimeMetadataTypeMapGroup, and DynamicInterfaceCastableImplementationTypeMapGroup) were stripped from the reference assembly as implementation-only types. However, they are referenced by code the CsWinRT source generator emits into consumer assemblies (the '[assembly: TypeMapAssemblyTarget]' attributes that register assemblies for the interop type map infrastructure), which is compiled against the reference assembly. Stripping them broke consumers with CS0234. Keep these three types in the reference assembly, and instead mark them '[Obsolete]' (with the new CSWINRT3002 diagnostic) and '[EditorBrowsable(Never)]', only in the reference assembly, to discourage direct use in user code. This mirrors the reference-assembly-only obsolete pattern already used for the parameterless 'WindowsRuntimeObject' constructor (CSWINRT3001). The marker is reference-assembly-only because the implementation assembly has internal '[assembly: TypeMap]' usages that would otherwise trip the obsolete warning. The projection writer's generated-file header now also suppresses CSWINRT3002, since the generated projection code references these types. Adds the docs/diagnostics/cswinrt3002.md page. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Run each smoke test as its own CI step with a final failure gate Previously all smoke tests ran in a single CI step, so a failure didn't make it obvious which one failed. Following the unit test pattern in CsWinRT-Test-Steps.yml, each smoke test now runs as its own step with 'continueOnError' (an individual failure only marks the job as 'SucceededWithIssues'), and a final gate step turns any such issue into an actual failure. This makes it clear exactly which smoke test failed while still letting every test run and report. The runner script gains a '-Test' parameter (Consumption, Authoring, or All) so CI can invoke a single test per step; local builds keep using the default 'All'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Compile generated projections against the WinRT.Runtime implementation assembly The NuGet package ships WinRT.Runtime as both a reference assembly (ref/net10.0, with implementation-only types stripped) and an implementation assembly (lib/net10.0). The projection and interop generators compile and inspect generated implementation projection code that references those implementation-only types (e.g. WindowsRuntimeObjectReferenceValue, RestrictedErrorInfo, the marshallers), so they must use the implementation assembly rather than the reference assembly that MSBuild resolves for compilation. Introduce a CsWinRTRuntimeImplementationAssemblyPath property (defaulting to the package lib layout) and swap WinRT.Runtime for it in each affected generator target. Repo-internal builds override the property to point at the locally built implementation assembly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Make the WinRT.Runtime reference assembly swap an explicit opt-out The prior commit made the projection and interop generators unconditionally swap the WinRT.Runtime reference assembly for an implementation assembly, and overrode CsWinRTRuntimeImplementationAssemblyPath in src/Directory.Build.props to point at src/WinRT.Runtime2/bin//net10.0/WinRT.Runtime.dll. The official build rebuilds that bin output as the stripped reference assembly (CsWinRTBuildReferenceAssembly=true), so the override pointed the generators at the stripped assembly and broke repo builds. The package always lays out both the reference assembly (ref/net10.0) and the implementation assembly (lib/net10.0), so the generators can simply assume the implementation assembly is present and swap to it; if it were ever missing, the smoke tests (and any real consumer) would fail loudly. The swap is now controlled by CsWinRTSwapRuntimeReferenceAssembly (default true). This repo references WinRT.Runtime directly as its implementation assembly, so it opts out via src/Directory.Build.props. The fragile bin-pointing override is removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Expose the authoring component assembly attributes in the reference assembly (CSWINRT3003) The authoring smoke test failed to build because the CsWinRT source generator emits '[assembly: WindowsRuntimeComponentAssembly]' and '[assembly: WindowsRuntimeComponentAssemblyExportsType(...)]' into the component (in 'ManagedExports.g.cs'), but both attributes were stripped from the 'WinRT.Runtime' reference assembly (they were marked as implementation-only files), so the component compilation could not resolve them. Keep both attributes in the reference assembly and mark them, only there, with a reference-assembly-only '[Obsolete]' (new diagnostic CSWINRT3003) plus '[EditorBrowsable(Never)]', exactly like the type map group types (CSWINRT3002). The generated code that applies them already suppresses warnings, so normal builds are unaffected, while direct use in user code is discouraged. Add a 'docs/diagnostics/cswinrt3003.md' page describing the diagnostic. Also fix a related leak: the 'ReferenceVftbl' struct in the projection writer's 'InspectableVftbl' baseline declared its 'GetTrustLevel' slot as 'TrustLevel*', referencing the implementation-only 'Windows.Foundation.TrustLevel' enum. The slot is layout-only (the vtable is populated by copying 'IInspectableImpl.Vtable' and only 'get_Value' is set), so type it as 'int*' to match 'IInspectableVftbl.GetTrustLevel' and keep 'TrustLevel' out of the generated component projection. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Move vtable types to runtime and add assembly attributes Relocate and consolidate vtable and assembly metadata: removed the duplicate InspectableVftbl resource and added a shared AssemblyAttributes.cs. Updated ReferenceImplFactory to reference IReferenceVftbl. Adjusted IInspectableVftbl, IReferenceVftbl and IUnknownVftbl visibility and API surface (made structs public, marked with WindowsRuntimeImplementationOnlyMember, tightened helper methods to internal, and added pragma disables). These changes centralize vtable definitions in the runtime project and unify assembly-level attributes (DisableRuntimeMarshalling / trimmable/AOT metadata) for projection builds. * Remove unsupported-marshalling remarks from enums Drop redundant XML comments that stated marshalling was not supported for TrustLevel and TypeKind. Clean up TrustLevel.cs and TypeKind.cs by removing the two-line remarks blocks so the enum docs are concise. No behavior changes. * Skip the reference projection generator for input-less authored components When a project is an authored Windows Runtime component ('CsWinRTComponent=true') that does not reference any input .winmd files, there are no Windows Runtime types for 'cswinrtprojectionrefgen' to project: the component only authors its own types, which are described by the .winmd that 'cswinrtwinmdgen' emits and projected into 'WinRT.Component.dll' by 'cswinrtprojectiongen'. Skip invoking the reference projection generator in that case. This keeps authoring-only builds faster and avoids emitting projection support code (and its assembly-level attributes) into the component's own assembly. The skip is decided in the target body, where '@(CsWinRTInputs)' is reliably populated by the 'CsWinRTRemoveWinMDReferences' dependency (a target condition would evaluate before that item is populated). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Set DisableRuntimeMarshalling for the smoke test projects CsWinRT relies on runtime marshalling being disabled for its interop. Authored components normally get '[assembly: DisableRuntimeMarshalling]' emitted in generated projection source, but an input-less component now skips the reference projection generator entirely, so the project must opt in itself. Set it in the shared smoke test 'Directory.Build.props', exactly as a real component author would in their own project. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Run the smoke tests on both CoreCLR and Native AOT Add a '-Runtime' parameter to the smoke test runner: 'CoreCLR' (default) keeps the existing build-and-run behavior, while 'NativeAot' publishes the project with 'PublishAot=true' for win-x64, exercising the full publish pipeline (projection and interop generators, then ILC). Consumption publishes a self-contained app and runs it directly from the '.exe'; authoring just verifies the component publishes cleanly (the output is never loaded). In CI, suffix the existing smoke test steps with '(CoreCLR)' and add a '(NAOT)' step after each, so a failure points at the exact runtime. All four keep 'continueOnError' and feed the existing final gate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Document the public-but-hidden implementation-only type strategy CsWinRT now keeps a few implementation-only types public in the reference assembly but hidden (reference-assembly-only [Obsolete] + [EditorBrowsable(Never)]), instead of stripping them entirely. Explain both strategies and why stripping is not always possible: when CsWinRT-generated user code names the type and is compiled against the reference assembly, stripping would cause CS0234/CS0246, so the type must remain present but discouraged. Cover the current cases (CSWINRT3002 type map groups, CSWINRT3003 component authoring attributes, CSWINRT3004 TrustLevel) and update the runtime error-id table accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Cover the public-but-hidden implementation-only type strategy in the maintenance skills The two 'update-*-instructions' skills drive the self-maintenance of copilot-instructions.md and the interop-generator SKILL.md, but their checklists did not mention the public-but-hidden implementation-only type strategy that those docs now describe. Extend the WinRT.Runtime and source-generator verification items in the copilot-instructions maintenance skill to cover the two strategies (strip-entirely vs public-but-hidden) and the current CSWINRT3001-3004 cases, and extend the interop-generator maintenance skill (resolvers/references and related-docs steps) to verify the public-but-hidden note and the marking scheme. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Include RestrictedErrorInfoExceptionMarshaller Add an explicit for InteropServices/Marshalling/RestrictedErrorInfoExceptionMarshaller.cs so the public RestrictedErrorInfoExceptionMarshaller type is present in reference assemblies. The file was previously excluded by the blanket removals; we add it back manually for simplicity while keeping other implementation-only folders excluded. * Add a projection smoke test for the real NuGet package Add a third smoke test that generates a reference projection for a third-party Windows Runtime component, exactly as a NuGet projection author would. It sets 'CsWinRTGenerateReferenceProjection=true' and points 'CsWinRTInputs' at a '.winmd', exercising 'cswinrtprojectionrefgen' and 'cswinrtimplgen' end-to-end against the packed package. The projected metadata is reused from the sibling 'Authoring' smoke test: a build-ordering 'ProjectReference' (ReferenceOutputAssembly/Private both false, mirroring 'src/WinRT.Internal') ensures 'Authoring.winmd' exists before this project runs the generator, avoiding a separate hand-authored '.winmd'. The test is build-only (CoreCLR), verifying both a forwarder and a 'ref' reference assembly are produced. Wire it into 'run-smoke-tests.ps1' (-Test Projection, skipped for Native AOT), 'src/build.cmd', and a CoreCLR CI step, and document it in docs/structure.md and the testing skills. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Make WindowsRuntimeReferenceAssemblyAttribute public-but-hidden (CSWINRT3004) The reference projection generator emits '[assembly: WindowsRuntimeReferenceAssembly]' into the projection assemblies it produces (via the projection writer's 'AssemblyAttributes.cs' base resource), and that attribute genuinely ships in the reference projection assemblies of Windows Runtime projection NuGet packages. It must therefore remain resolvable in the 'WinRT.Runtime.dll' reference assembly, so it cannot be stripped like other implementation-only types. Apply the same public-but-hidden strategy already used for the type map group types (CSWINRT3002) and the component authoring attributes (CSWINRT3003): keep the type in the reference assembly but mark it reference-assembly-only '[Obsolete(DiagnosticId = CSWINRT3004)]' + '[EditorBrowsable(Never)]' to discourage direct use. Add the obsolete message/diagnostic-id constants, a 'docs/diagnostics/cswinrt3004.md' page, and suppress the diagnostic in the generated 'AssemblyAttributes.cs'. Update the copilot instructions (the two-strategies note and the error-id table) and the maintenance skill, repurposing the previously-stale CSWINRT3004 id (it had been documented for a since-reverted 'TrustLevel' case that no longer exists). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Stop reference projections from referencing implementation-only types A reference projection ships in a Windows Runtime projection NuGet package and is compiled (with 'ProduceOnlyReferenceAssembly') against the stripped 'WinRT.Runtime.dll' reference assembly, which contains only the public API surface. The projection writer was emitting code that referenced implementation-only types in signature positions (field types, method parameters, base types, attributes) that do not exist in that reference assembly, so building a reference projection from the package failed to compile (CS0246/CS0234). In reference-projection mode, stop emitting the implementation-only signatures: the '[WindowsRuntimeMetadata]' attribute, the private '_objRef_*' fields (typed 'WindowsRuntimeObjectReference'), the static activation-factory object references, the activation-factory plumbing (factory callback classes and args structs), and the '[UnsafeAccessor]' static extern declarations (whose parameters are typed 'WindowsRuntimeObjectReference'). Constructors keep their public signatures but emit a 'throw null' body instead of a base call referencing implementation-only activation types. Member bodies are unaffected: a reference assembly compile does not bind method bodies, so the public member signatures are all that needs to resolve. Implementation-mode output is unchanged. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Broaden the authoring smoke test to cover more projection shapes The authoring smoke test produces 'Authoring.winmd', which the projection smoke test then generates a reference projection for. Add a richer set of authored Windows Runtime types alongside the existing 'Greeter' so the projection path exercises more codegen: two enums (including a [Flags] enum), a struct, a delegate, an interface, and a runtime class with two constructors (default and parameterized), instance methods, a settable property, an interface-implemented property, an event, and static members. Validated end-to-end locally: the types compile, 'cswinrtwinmdgen' emits a valid '.winmd' for them, and the resulting reference projection compiles cleanly against the stripped 'WinRT.Runtime' reference assembly (no implementation-only types referenced). Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Recognize reference projection types in interop generator discovery The interop generator identified projected Windows Runtime types via the per-type [WindowsRuntimeMetadata] attribute (IsProjectedWindowsRuntimeType). That attribute is now stripped from reference projections (it is an implementation-only type, absent from the WinRT.Runtime reference assembly that reference projections compile against), so the type-hierarchy discovery crawl over reference projection assemblies stopped recognizing any projected classes and failed with CSWINRTINTEROPGEN0036 (no type hierarchy key-value pairs discovered). Add IsReferenceProjectionWindowsRuntimeType, which recognizes a projected type by its declaring assembly's [WindowsRuntimeReferenceAssembly] marker, mirroring the existing IsComponentWindowsRuntimeType handling for authored components (which likewise expose projected types without the per-type attribute). Fold it into the five "is this a projected Windows Runtime type" gates that can observe reference projection definitions directly (type hierarchy base-type tracking, IsProjectedWindowsRuntimeClassType, IsWindowsRuntimeType, IsNotExclusiveToWindowsRuntimeType, and the projected interface branch in InteropInterfaceEntriesResolver). The type-hierarchy base-type check now inspects the resolved base type definition (instead of the unresolved reference) so the assembly-level marker can be read off it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Recover Windows Runtime metadata name from the implementation projection The interop type-name marker for a third-party (non-well-known) projected type must be the source .winmd stem, because the projection writer encodes that same stem into the [UnsafeAccessorType] references it bakes into the implementation projection (WinRT.Projection.dll). The generator read that stem from the per-type [WindowsRuntimeMetadata] attribute. That attribute is now stripped from reference projections (it is an implementation-only attribute, absent from the WinRT.Runtime reference assembly they compile against). The discovery input set keeps the reference projection and excludes the forwarder/impl .dll, so a third-party type resolves to the reference projection where the attribute is gone. The marker would then fall back to the reference projection's own assembly name, which is not guaranteed to equal the .winmd stem (e.g. WinUI / Windows App SDK merge several .winmd files into one projection assembly), producing [UnsafeAccessor] references that don't match the generated interop type names. Add a TypeDefinition.GetWindowsRuntimeMetadataName(RuntimeContext) overload that reads the attribute directly when present, and otherwise — for a type from a reference projection — recovers the stem from the matching type in the third-party implementation projection (WinRT.Projection.dll), which retains it. The implementation projection is located through RuntimeContext.GetLoadedAssemblies(), which returns assemblies loaded via LoadModule even when they are outside the resolver's path set, so this needs no changes to the many InteropUtf8NameFactory call sites (they already flow the RuntimeContext through). When the stem cannot be found, the caller's fallback to the assembly name is preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Emit XAML struct metadata attributes only for implementation projections The hand-authored full-replacement XAML struct additions (CornerRadius, Duration, GridLength, KeyTime, RepeatBehavior, Matrix3D, for both the Windows.UI.Xaml and Microsoft.UI.Xaml namespaces) carried their [WindowsRuntimeMetadata("...")] attribute outside the '#if !CSWINRT_REFERENCE_PROJECTION' block, so it was also emitted into reference projections. That attribute is implementation-only and is stripped from the WinRT.Runtime reference assembly, so a reference projection compiled against that reference assembly would fail to resolve it. Move the attribute inside the existing '#if !CSWINRT_REFERENCE_PROJECTION' block, alongside the other implementation-only attributes ([WindowsRuntimeClassName] and the ComWrappers marshaller), so it is only emitted for implementation projections. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Emit GetDefaultInterface helper only for implementation projections The 'internal new GetDefaultInterface()' helper emitted on unsealed projected runtime classes returns 'WindowsRuntimeObjectReferenceValue', which is an implementation-only type stripped from the WinRT.Runtime reference assembly. It was emitted in both implementation and reference-projection modes, but its only consumer is the ABI marshaller (also implementation-only and not emitted in reference-projection mode). As a result, the helper was dead code in a reference projection, yet it still failed to compile against the WinRT.Runtime reference assembly that reference projections bind against. This only surfaced for unsealed classes: the helper exists so that overrides on derived classes can hide it with 'new', so sealed classes never emit it. That is why simple sealed components (e.g. the authoring smoke test) never hit it, while the Windows SDK XAML projections (full of unsealed base classes) did. Gate the helper on '!context.Settings.ReferenceProjection', matching the sibling 'IWindowsRuntimeInterface.GetInterface()' helper, so neither is emitted into reference projections. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify runtime class shapes in Thermometer test Update Thermometer smoke test comments to mention both a sealed (non-derivable) runtime class and an unsealed (derivable) runtime class. Add a commented-out Weather class (TODO) to represent an unsealed runtime class for future authoring support. The change documents intended coverage and leaves a placeholder for when unsealed class authoring is supported. * Guard implementation-only TokenizerHelper usage in reference projections The hand-authored XAML struct/Color additions (CornerRadius, Thickness, Matrix, Matrix3D for both Windows.UI.Xaml and Microsoft.UI.Xaml, plus Windows.UI.Color) format their ToString output using 'WindowsRuntime.InteropServices.TokenizerHelper' to get the culture's numeric list separator. That helper is an implementation-only API ([WindowsRuntimeImplementationOnlyMember]) that is stripped from the WinRT.Runtime reference assembly, so a reference projection that includes any of these types fails to compile against that reference assembly (CS0234). Following the same pattern the runtime uses for its reference-assembly stubs, guard each affected method body with '#if CSWINRT_REFERENCE_PROJECTION' / 'throw null;' / '#else' / the existing implementation / '#endif'. The implementation projection keeps the real body; the reference projection gets a stub, so it no longer references the stripped helper. The bodies are never executed in a reference projection (the real implementation is generated at app build time). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Guard implementation-only DispatcherQueueSynchronizationContext wrappers The DispatcherQueueSynchronizationContext additions (Windows.System and Microsoft.UI.Dispatching) wrap the implementation-only 'WindowsRuntime.InteropServices.DispatcherQueueSynchronizationContext' ([WindowsRuntimeImplementationOnlyMember], stripped from the WinRT.Runtime reference assembly). The impl-only type appeared in a private field, both constructors, and every method body, so a reference projection that included these types failed to compile against the reference assembly. Guard the implementation-only members (the private '_innerContext' field and the private copy constructor) with '#if !CSWINRT_REFERENCE_PROJECTION', and stub the public API bodies (the public constructor, Post, Send, CreateCopy) with '#if CSWINRT_REFERENCE_PROJECTION' / 'throw null;' / '#else'. The reference projection keeps the public API surface but no longer references the stripped type; the real implementation is generated for the implementation projection at app build time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Stub mapped-interface members in reference projections MappedInterfaceStubFactory emits the C# collection-interface members (IList, IDictionary, IEnumerable, IDisposable, the bindable collections, and INotifyDataErrorInfo) on classes that implement the corresponding WinRT interfaces. It already skipped its implementation-only '[UnsafeAccessor]' externs in reference-projection mode, but it still emitted the member *bodies*, which reference those skipped externs (the '*Methods_*' helpers), the skipped '_objRef_*' fields, and the implementation-only 'ABI.*Methods' helpers. None of those exist in a reference projection, so a reference projection that included any mapped-collection class failed to compile against the stripped WinRT.Runtime reference assembly. Give each per-interface 'Emit*' method a reference-projection-first branch that emits the full member set as a single stub (every body is 'throw null'), keeping the public member signatures identical to the implementation projection. The implementation path is unchanged. The previously inline switch cases (IBindableIterable, IBindableIterator, INotifyDataErrorInfo) are extracted into their own 'Emit*' methods so they follow the same shape. Validated that the implementation-projection output is byte-for-byte identical to before across the full Windows SDK projection (no runtime impact), and that the reference projection no longer references any of the stripped plumbing. This removes ~4,900 of the reference-projection compile errors against the stripped reference assembly (the remaining errors are tracked separately in #2468). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Make the synthetic ref-mode ctor accessible to derived projected classes In a reference projection, a projected class with no activatable/composable constructors gets a synthetic 'private TypeName() { throw null; }' ctor to suppress the C# compiler's implicit public default constructor. When such a class is the base of another projected class (e.g. 'UriActionEntity : ActionEntity'), the derived class's own synthetic ctor implicitly chains to the base's parameterless ctor -- which was 'private', so the derived class failed to compile against the stripped WinRT.Runtime reference assembly (CS0122). The real 'WindowsRuntimeObjectReference'-based ctor that derived classes chain to in the implementation projection is not emitted in a reference projection, so the synthetic ctor is the only one available. Emit the synthetic ctor as 'private protected' for unsealed classes (which can be base classes), so derived projected classes in the same projection can chain to it. Sealed classes keep 'private'. The ctor stays non-public, so it still suppresses the implicit public default constructor and does not widen the public API surface. The implementation projection is unaffected (its output is unchanged). This removes the CS0122 reference-projection errors (tracked in #2468). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Emit accessible parameterless ctor for unsealed composable classes in ref projections In reference-projection mode the real WindowsRuntimeObjectReference-based base constructor is not emitted, so a derived projected class's ref-mode constructor (whose implicit base() call has no target) fails to compile against an unsealed base that only exposes parameterized composable constructors. Emit a 'private protected TypeName() { throw null; }' for unsealed classes that don't already emit a public parameterless constructor (a default [Activatable], or a factory/composable method with no user parameters), giving derived projected classes a base-chain target. Sealed classes keep the existing behavior (a synthetic ctor only to suppress the implicit public default ctor when none are emitted). Validated byte-identical implementation-mode output for the full Windows SDK projection; reduces the reference-projection compile from 192 to 12 errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Guard implementation-only storage-extension bodies in reference projections WindowsRuntimeStorageExtensions calls implementation-only APIs (WindowsRuntimeIOHelpers and the IStorage*HandleAccessMethods classes) that are absent from the WinRT.Runtime reference assembly, so the hand-authored Windows.Storage addition failed to compile in reference-projection mode. Following the same pattern the runtime uses for its reference-assembly stubs (and the earlier TokenizerHelper guard), wrap each affected method body with '#if CSWINRT_REFERENCE_PROJECTION' / 'throw null;' / '#else' / the existing implementation / '#endif'. The implementation projection keeps the real body; the reference projection gets a stub. The added directives are inert when CSWINRT_REFERENCE_PROJECTION is undefined, so implementation-mode output is unchanged. With this fix the full Windows SDK reference projection compiles with 0 errors against the stripped WinRT.Runtime reference assembly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add Windows SDK and XAML reference-projection smoke tests Generating the Windows SDK reference projections (the 'Microsoft.Windows.SDK.NET.Ref' projection packages) is exactly what a downstream repository does with the CsWinRT package, and it is where reference-projection codegen regressions surface: the generated projection must compile against the stripped 'WinRT.Runtime' reference assembly, with no references to implementation-only runtime types. Add two end-to-end smoke tests that exercise this so such regressions fail here, early, instead of breaking that package. * WindowsSdkProjection generates the base Windows SDK reference projection from the 'Microsoft.Windows.SDK.Contracts' '.winmd' files. * WindowsSdkXamlProjection generates the 'Windows.UI.Xaml' reference projection, which references the base projection above (mirroring how the UWP XAML projection package depends on the base Windows SDK projection package). Both mirror the existing 'Projection' smoke test (CsWinRTGenerateReferenceProjection) and the Windows SDK metadata staging in 'WinRT.Sdk.Projection.csproj', and use the same namespace include/exclude split the projection generator applies for 'WinRT.Sdk.Projection' and 'WinRT.Sdk.Xaml.Projection' (see 'WriteWindowsSdkFilters'). The shared 'WindowsSdkContracts.targets' downloads 'Microsoft.Windows.SDK.Contracts' and feeds its '.winmd' files into '@(CsWinRTInputs)'. That package, like the preview Windows SDK ref pack, is restored from the CsWinRTDependencies feed, alongside the local package under test. The reference-projection verification in 'run-smoke-tests.ps1' (forwarder + reference assembly produced) is shared across all three reference-projection tests, and both new tests are build-only (CoreCLR), wired into the CI as their own 'continueOnError' steps. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Build the Windows SDK projection smoke tests as plain net10.0 The two Windows SDK reference-projection smoke tests inherited the '-windows10.0.26100.1' target framework from the shared 'Directory.Build.props'. That target framework makes the .NET SDK add an implicit reference to the prebuilt Windows SDK projection ('Microsoft.Windows.SDK.NET.dll') -- the very projection these tests regenerate -- so every generated type collided with its prebuilt counterpart (tens of thousands of CS0436), and 'ApiContractAttribute' collided between 'Microsoft.Windows.SDK.NET' and 'WinRT.Runtime' (CS0433), failing the build. Override the target framework to plain 'net10.0' for both projects, exactly as the real Windows SDK projection is built ('src/WinRT.Sdk.Projection/WinRT.Sdk.Projection.csproj'): generating the Windows SDK projection means it cannot reference the Windows SDK projection. The base 'Windows.*' types the XAML projection needs come from the sibling 'WindowsSdkProjection' reference assembly instead. The '-windows'-specific properties the shared props also set ('TargetPlatformMinVersion', 'WindowsSdkPackageVersion') are inert without a target platform. The package's reference-projection flow fully supports this (CsWinRTExeTFM resolves to 'net10.0' for any net10.0+ target framework), and the generated projection still compiles against the packaged 'WinRT.Runtime' reference assembly (NuGet uses 'ref/net10.0' at compile time), which is what these tests validate. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> * Simplify over-escaped interpolated raw strings in MappedInterfaceStubFactory Several reference- and implementation-mode stub strings used the '$$""" + ... + """' form (with '{{x}}' interpolation holes) even though their content has no literal braces, so the doubled '$$' was unnecessary. Reduce those six to a single '$' (with '{x}' holes). The strings that do contain literal braces (indexers, event accessors, 'Dispose() { }') still need '$$' and are left unchanged. This is a purely cosmetic change: the generated text is identical. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update testing skill for the Windows SDK projection smoke tests The smoke tests section listed three projects; it now documents all five, adding 'WindowsSdkProjection' and 'WindowsSdkXamlProjection' (the Windows SDK reference projections built from 'Microsoft.Windows.SDK.Contracts', staged by the shared 'WindowsSdkContracts.targets'). Also correct the smoke tests' shared configuration: 'RestoreSources' uses the local package output plus the 'CsWinRTDependencies' feed (not public NuGet), the two SDK projection tests override the target framework to plain 'net10.0', and the reference-projection verification is shared across all three reference-projection tests (build-only, CoreCLR). Refresh the 'Authoring' smoke test description to reflect its broader authored type catalog ('Thermometer.cs'), and update the routing table accordingly. Update the 'update-testing-instructions' skill's smoke-test verification step to match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use tag for TypeDefinition in docs Replace XML tag with a reference in the GetWindowsRuntimeMetadataName documentation to produce a proper XML doc reference and improve IntelliSense/linking. No functional changes. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 7 +- .github/skills/interop-generator/SKILL.md | 4 +- .../references/name-mangling-scheme.md | 2 +- .github/skills/testing/SKILL.md | 58 +++- .../update-copilot-instructions/SKILL.md | 2 + .../SKILL.md | 3 +- .../update-testing-instructions/SKILL.md | 26 +- .../CsWinRT-PublishToNuGet-Steps.yml | 95 ++++++ docs/diagnostics/cswinrt3002.md | 28 ++ docs/diagnostics/cswinrt3003.md | 25 ++ docs/diagnostics/cswinrt3004.md | 25 ++ docs/structure.md | 24 +- ...crosoft.Windows.CsWinRT.CsWinRTGen.targets | 55 ++- nuget/Microsoft.Windows.CsWinRT.targets | 19 +- src/Directory.Build.props | 8 + src/Tests/SmokeTests/.gitignore | 5 + .../SmokeTests/Authoring/Authoring.csproj | 15 + src/Tests/SmokeTests/Authoring/Greeter.cs | 9 + src/Tests/SmokeTests/Authoring/Thermometer.cs | 105 ++++++ .../SmokeTests/Consumption/Consumption.csproj | 13 + src/Tests/SmokeTests/Consumption/Program.cs | 8 + src/Tests/SmokeTests/Directory.Build.props | 55 +++ src/Tests/SmokeTests/Directory.Build.targets | 10 + src/Tests/SmokeTests/Directory.Packages.props | 13 + .../SmokeTests/Projection/Projection.csproj | 39 +++ .../SmokeTests/WindowsSdkContracts.targets | 56 ++++ .../WindowsSdkProjection.csproj | 59 ++++ .../WindowsSdkXamlProjection.csproj | 66 ++++ src/Tests/SmokeTests/run-smoke-tests.ps1 | 280 ++++++++++++++++ ...tomMappedTypeMapEntriesBuilder.ICommand.cs | 2 +- ...EntriesBuilder.INotifyCollectionChanged.cs | 2 +- ...apEntriesBuilder.INotifyPropertyChanged.cs | 2 +- ...ynamicCustomMappedTypeMapEntriesBuilder.cs | 37 ++- .../InteropTypeDefinitionBuilder.Delegate.cs | 37 ++- ...nteropTypeDefinitionBuilder.EventSource.cs | 18 +- ...nitionBuilder.IAsyncActionWithProgress1.cs | 17 +- ...pTypeDefinitionBuilder.IAsyncOperation1.cs | 17 +- ...ionBuilder.IAsyncOperationWithProgress2.cs | 17 +- ...initionBuilder.ICollectionKeyValuePair2.cs | 9 +- ...teropTypeDefinitionBuilder.IDictionary2.cs | 34 +- ...teropTypeDefinitionBuilder.IEnumerable1.cs | 25 +- ...teropTypeDefinitionBuilder.IEnumerator1.cs | 30 +- .../InteropTypeDefinitionBuilder.IList1.cs | 31 +- ...DefinitionBuilder.IMapChangedEventArgs1.cs | 17 +- ...opTypeDefinitionBuilder.IObservableMap2.cs | 27 +- ...ypeDefinitionBuilder.IObservableVector1.cs | 27 +- ...uilder.IReadOnlyCollectionKeyValuePair2.cs | 9 +- ...eDefinitionBuilder.IReadOnlyDictionary2.cs | 25 +- ...ropTypeDefinitionBuilder.IReadOnlyList1.cs | 27 +- ...teropTypeDefinitionBuilder.KeyValuePair.cs | 24 +- .../InteropTypeDefinitionBuilder.SzArray.cs | 35 +- ...opTypeDefinitionBuilder.UserDefinedType.cs | 16 +- .../Builders/InteropTypeDefinitionBuilder.cs | 24 +- .../Discovery/InteropTypeDiscovery.cs | 8 +- .../Extensions/WindowsRuntimeExtensions.cs | 112 ++++++- ...ionFactory.IEnumeratorElementMarshaller.cs | 21 +- ...actory.IReadOnlyCollectionKeyValuePair2.cs | 6 +- ...initionFactory.SzArrayElementMarshaller.cs | 21 +- ...TypeDefinitionFactory.SzArrayMarshaller.cs | 40 ++- .../Factories/InteropUtf8NameFactory.cs | 25 +- .../Generation/InteropGenerator.Emit.cs | 110 +++++- .../Helpers/SignatureGenerator.cs | 15 +- .../References/InteropDefinitions.cs | 5 + .../Resolvers/InteropImplTypeResolver.cs | 4 +- .../InteropInterfaceEntriesResolver.cs | 5 +- .../Builders/ProjectionFileBuilder.cs | 8 +- .../Extensions/ProjectionWriterExtensions.cs | 1 + .../Factories/ClassFactory.cs | 88 ++--- .../ClassMembersFactory.WriteClassMembers.cs | 6 +- ...assMembersFactory.WriteInterfaceMembers.cs | 63 ++-- .../ConstructorFactory.AttributedTypes.cs | 119 +++++-- .../ConstructorFactory.Composable.cs | 19 +- .../Factories/InterfaceFactory.cs | 2 +- .../Factories/MappedInterfaceStubFactory.cs | 312 +++++++++++++++--- .../Factories/MetadataAttributeFactory.cs | 37 ++- .../Factories/RefModeStubFactory.cs | 51 ++- .../Factories/ReferenceImplFactory.cs | 2 +- .../Helpers/ObjRefNameGenerator.cs | 11 +- ...g.DispatcherQueueSynchronizationContext.cs | 20 ++ ...crosoft.UI.Xaml.Media.Animation.KeyTime.cs | 2 +- ....UI.Xaml.Media.Animation.RepeatBehavior.cs | 2 +- ...icrosoft.UI.Xaml.Media.Media3D.Matrix3D.cs | 6 +- .../Microsoft.UI.Xaml.Media.Matrix.cs | 4 + .../Microsoft.UI.Xaml.CornerRadius.cs | 6 +- .../Microsoft.UI.Xaml.Duration.cs | 2 +- .../Microsoft.UI.Xaml.GridLength.cs | 2 +- .../Microsoft.UI.Xaml.Thickness.cs | 4 + .../WindowsRuntimeStorageExtensions.cs | 24 ++ ...Windows.UI.Xaml.Media.Animation.KeyTime.cs | 2 +- ....UI.Xaml.Media.Animation.RepeatBehavior.cs | 2 +- .../Windows.UI.Xaml.Media.Media3D.Matrix3D.cs | 6 +- .../Windows.UI.Xaml.Media.Matrix.cs | 4 + ...m.DispatcherQueueSynchronizationContext.cs | 20 ++ .../Windows.UI.Xaml.CornerRadius.cs | 6 +- .../Windows.UI.Xaml.Duration.cs | 2 +- .../Windows.UI.Xaml.GridLength.cs | 2 +- .../Windows.UI.Xaml.Thickness.cs | 4 + .../Additions/Windows.UI/Windows.UI.Color.cs | 4 + .../Resources/Base/AssemblyAttributes.cs | 14 + .../Resources/Base/InspectableVftbl.cs | 49 --- ...indowsRuntimeComponentAssemblyAttribute.cs | 13 +- ...meComponentAssemblyExportsTypeAttribute.cs | 13 +- ...indowsRuntimeReferenceAssemblyAttribute.cs | 18 +- ...rfaceCastableImplementationTypeMapGroup.cs | 13 +- .../WindowsRuntimeComWrappersTypeMapGroup.cs | 13 +- .../WindowsRuntimeMetadataTypeMapGroup.cs | 13 +- .../Vtables/IInspectableVftbl.cs | 11 +- .../Vtables/IReferenceVftbl.cs | 7 +- .../InteropServices/Vtables/IUnknownVftbl.cs | 13 +- .../Properties/WindowsRuntimeConstants.cs | 45 +++ src/WinRT.Runtime2/WinRT.Runtime.csproj | 19 +- .../Windows.Foundation/TrustLevel.cs | 3 - .../Windows.UI.Xaml.Interop/TypeKind.cs | 4 - src/build.cmd | 17 + 114 files changed, 2611 insertions(+), 492 deletions(-) create mode 100644 docs/diagnostics/cswinrt3002.md create mode 100644 docs/diagnostics/cswinrt3003.md create mode 100644 docs/diagnostics/cswinrt3004.md create mode 100644 src/Tests/SmokeTests/.gitignore create mode 100644 src/Tests/SmokeTests/Authoring/Authoring.csproj create mode 100644 src/Tests/SmokeTests/Authoring/Greeter.cs create mode 100644 src/Tests/SmokeTests/Authoring/Thermometer.cs create mode 100644 src/Tests/SmokeTests/Consumption/Consumption.csproj create mode 100644 src/Tests/SmokeTests/Consumption/Program.cs create mode 100644 src/Tests/SmokeTests/Directory.Build.props create mode 100644 src/Tests/SmokeTests/Directory.Build.targets create mode 100644 src/Tests/SmokeTests/Directory.Packages.props create mode 100644 src/Tests/SmokeTests/Projection/Projection.csproj create mode 100644 src/Tests/SmokeTests/WindowsSdkContracts.targets create mode 100644 src/Tests/SmokeTests/WindowsSdkProjection/WindowsSdkProjection.csproj create mode 100644 src/Tests/SmokeTests/WindowsSdkXamlProjection/WindowsSdkXamlProjection.csproj create mode 100644 src/Tests/SmokeTests/run-smoke-tests.ps1 create mode 100644 src/WinRT.Projection.Writer/Resources/Base/AssemblyAttributes.cs delete mode 100644 src/WinRT.Projection.Writer/Resources/Base/InspectableVftbl.cs diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 57575b09e5..f44b28c3fe 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -251,7 +251,10 @@ WinRT.Runtime2/ - **Compilation symbols**: the implementation build defines `WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY`; the reference build defines `WINDOWS_RUNTIME_REFERENCE_ASSEMBLY`. Members that differ between the two (e.g. the explicit interface implementations on `WindowsRuntimeObject`, which become `throw null` stubs) are guarded with `#if`/`#elif` on these symbols. An entire source file can opt out of the reference assembly by placing `#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE` at the top: the `RemoveWindowsRuntimeImplementationOnlyFiles` target removes those files (plus the whole `ABI/`, `NativeObjects/`, `Exceptions/`, `Windows.UI.Xaml.Interop/`, and most `InteropServices/` subfolders) before `CoreCompile`. - **`ProduceReferenceAssembly = false`**: the implementation build disables the SDK's automatic reference assembly, because `WinRT.Runtime` ships its own (the SDK-generated one would leak the implementation-only types to consumers and break reference projections). -- **`[WindowsRuntimeImplementationOnlyMember]`** (`Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs`): an `internal sealed`, `[Conditional("WINDOWS_RUNTIME_REFERENCE_ASSEMBLY")]` marker placed on implementation-only types/members (including most of the marker attributes under `Attributes/`). It replaces the older `[Obsolete] + [EditorBrowsable(Never)]` combination, makes the intent explicit, and is only ever emitted into the reference assembly (where it is stripped along with the members it marks). +- **`[WindowsRuntimeImplementationOnlyMember]`** (`Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs`): an `internal sealed`, `[Conditional("WINDOWS_RUNTIME_REFERENCE_ASSEMBLY")]` marker placed on implementation-only types/members (including most of the marker attributes under `Attributes/`). For the **common case** (a type/member that nothing outside the implementation assembly needs to reference), it replaces the older `[Obsolete] + [EditorBrowsable(Never)]` combination, makes the intent explicit, and is only ever emitted into the reference assembly (where it is stripped along with the members it marks). +- **Two strategies for implementation-only API** — there are two ways CsWinRT keeps an implementation detail out of the supported surface, and the choice depends on whether *generated code that compiles against the reference assembly* needs to name the type: + 1. **Strip it entirely** (the default, preferred): mark it `[WindowsRuntimeImplementationOnlyMember]` (or place it in a file/folder excluded from the reference build) so it is **absent** from the reference assembly. This is the cleanest option and is used for everything that is only reached at runtime or via `[IgnoresAccessChecksTo]` from `WinRT.Interop.dll` (e.g. the ABI marshallers, native object wrappers, vtable helpers). + 2. **Keep it public but hidden** (the exception): leave the type in the reference assembly, but — only there (`#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY`) — mark it `[Obsolete(..., DiagnosticId = "CSWINRT3xxx", UrlFormat = ...)]` + `[EditorBrowsable(Never)]`. This is required when **CsWinRT-generated code** references the type by name *and that code is compiled against the reference assembly* (so stripping would cause `CS0234`/`CS0246`). Such generated code suppresses the diagnostic (e.g. `#pragma warning disable`), so normal builds are unaffected, while direct use in user code surfaces the obsolete warning. The obsolete message/diagnostic-id constants live in `Properties/WindowsRuntimeConstants.cs`, and each id has a docs page under `docs/diagnostics/`. Current cases: the three type map group types (`CSWINRT3002`; referenced by the source generator's `[assembly: TypeMapAssemblyTarget]` output), the component authoring attributes `WindowsRuntimeComponentAssemblyAttribute`/`WindowsRuntimeComponentAssemblyExportsTypeAttribute` (`CSWINRT3003`; referenced by the authoring source generator's `ManagedExports.g.cs`), and `WindowsRuntimeReferenceAssemblyAttribute` (`CSWINRT3004`; emitted as `[assembly: WindowsRuntimeReferenceAssembly]` by the projection writer's `AssemblyAttributes.cs` base resource, and — unlike the others — also genuinely shipped in the reference projection assemblies of Windows Runtime projection NuGet packages). The reference-assembly-only `WindowsRuntimeObject()` constructor (`CSWINRT3001`) is the same mechanism applied to a constructor. - **Banned API analyzer**: the reference build references `Microsoft.CodeAnalysis.BannedApiAnalyzers` and lists `WindowsRuntimeImplementationOnlyMemberAttribute` in `BannedSymbols.txt`, with `RS0030` promoted to an error, so the build fails if any implementation-only type ever leaks into the reference surface. It also suppresses warnings that only appear in the stripped build (`CS8597`, `IDE0005`, `IDE0380`). - **Reference-assembly-only `WindowsRuntimeObject()` constructor**: a parameterless `protected` constructor exists only in the reference assembly (`#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY`). It is marked `[Obsolete(..., DiagnosticId = "CSWINRT3001")]`, so user code that derives from `WindowsRuntimeObject` gets the `CSWINRT3001` warning; because the constructor is absent from the implementation assembly, doing so throws `MissingMethodException` at runtime. Only CsWinRT-generated projections may derive from `WindowsRuntimeObject`. The related messages live in `Properties/WindowsRuntimeConstants.cs`. - **Packaging**: the implementation assembly ships in `lib\net10.0\` of the `Microsoft.Windows.CsWinRT` NuGet package, and the reference assembly (with its XML documentation, trimmed to the reference surface) ships in `ref\net10.0\`. The dual build and staging are driven by `src/build.cmd` and the Azure Pipelines build steps. @@ -727,7 +730,7 @@ All five .NET build tools (`cswinrtprojectionrefgen`, `cswinrtprojectiongen`, `c | Impl Generator | `CSWINRTIMPLGENxxxx` | `0001`–`0014`, `9999` | | Interop Generator | `CSWINRTINTEROPGENxxxx` | `0001`–`0097`, `9999` | | WinMD Generator | `CSWINRTWINMDGENxxxx` | `0001`–`0010`, `9999` | -| Runtime (obsolete markers) | `CSWINRT3xxx` | `CSWINRT3001` (deriving from `WindowsRuntimeObject`) | +| Runtime (obsolete markers) | `CSWINRT3xxx` | `CSWINRT3001` (deriving from `WindowsRuntimeObject`), `CSWINRT3002` (type map group types), `CSWINRT3003` (component authoring attributes), `CSWINRT3004` (`WindowsRuntimeReferenceAssemblyAttribute`) | --- diff --git a/.github/skills/interop-generator/SKILL.md b/.github/skills/interop-generator/SKILL.md index a85c8beaa9..673a9d5f99 100644 --- a/.github/skills/interop-generator/SKILL.md +++ b/.github/skills/interop-generator/SKILL.md @@ -287,7 +287,7 @@ The generator processes two categories of assemblies: - `System.Collections.Concurrent.ConditionalWeakTable<,>` — Memory semantics conflict **Type inclusion criteria:** -- Must be a projected Windows Runtime type (marked with `[WindowsRuntimeMetadata]` or similar) +- Must be a projected Windows Runtime type. A type is recognized as projected in any of three ways: it carries the per-type `[WindowsRuntimeMetadata]` attribute (implementation projections and types in `WinRT.Runtime.dll`); it is a public type from an authored component assembly (`IsComponentWindowsRuntimeType`); or it is defined in a reference projection assembly marked `[WindowsRuntimeReferenceAssembly]` (`IsReferenceProjectionWindowsRuntimeType`). The latter two do **not** carry the per-type `[WindowsRuntimeMetadata]` attribute — reference projections shipped in NuGet packages have it stripped (it is an implementation-only attribute, absent from the `WinRT.Runtime.dll` reference assembly they compile against), so the interop generator recognizes them by their assembly-level marker instead. - Generic types must be fully constructed (no open generic parameters) - Type hierarchy must be fully resolvable (no missing dependencies) - Must not be a managed-only type (types that never cross the Windows Runtime boundary) @@ -737,6 +737,8 @@ Almost everything the generated code calls into lives in `WinRT.Runtime.dll` as Because these APIs are absent from the `WinRT.Runtime.dll` reference assembly, the generated `WinRT.Interop.dll` references types that exist only in the implementation assembly, and the generator emits assembly-level `[IgnoresAccessChecksTo]` to reach the non-public members among them. This is also why `cswinrtinteropgen` must be version-matched to the `WinRT.Runtime.dll` it targets (see "Version compatibility" above): the shape of these types can change at any time. +> **Note:** A small subset of the types listed above is not stripped but instead kept **public but hidden** in the reference assembly — most notably the three type map group types, which are marked reference-assembly-only `[Obsolete(DiagnosticId = "CSWINRT3002")]` + `[EditorBrowsable(Never)]`. The reason: those types are also named by the CsWinRT source generator's `[assembly: TypeMapAssemblyTarget]` output, which is compiled into user code **against the reference assembly**, so stripping them would break that compilation. The interop generator is unaffected by the distinction (it always resolves the implementation assembly), but it must still treat them as unstable, version-matched implementation details. See the "Two strategies for implementation-only API" note in `.github/copilot-instructions.md` for the full rationale and the other cases (`CSWINRT3003`, `CSWINRT3004`). + ## Key patterns and conventions ### Naming conventions for generated types diff --git a/.github/skills/interop-generator/references/name-mangling-scheme.md b/.github/skills/interop-generator/references/name-mangling-scheme.md index 9ddfa2a95a..9db179e955 100644 --- a/.github/skills/interop-generator/references/name-mangling-scheme.md +++ b/.github/skills/interop-generator/references/name-mangling-scheme.md @@ -38,7 +38,7 @@ These are the well-known assemblies and their compact identifiers: Compact identifiers are prefixed with `#` to distinguish them from user-defined assembly names. -For types not belonging to any well-known assembly, the implementation also checks for a `[WindowsRuntimeMetadata]` attribute on the resolved type definition. If the attribute is present, the Windows Runtime metadata name from the attribute is used as the assembly identifier instead of the actual assembly name. This allows types carrying WinRT metadata to be identified by their canonical Windows Runtime name rather than the .NET assembly they happen to live in. If the attribute is not present, the raw assembly name is used as-is. +For types not belonging to any well-known assembly, the implementation also derives the assembly identifier from the type's `[WindowsRuntimeMetadata]` value (the source `.winmd` module name, i.e. its "stem") instead of the actual assembly name. This allows types carrying WinRT metadata to be identified by their canonical Windows Runtime name rather than the .NET assembly they happen to live in. The stem is read directly from the attribute when present — implementation projections, the authored component projection, and manually projected types in `WinRT.Runtime.dll` all carry it. Reference projections shipped in Windows Runtime projection NuGet packages have the attribute **stripped** (it is an implementation-only attribute, absent from the `WinRT.Runtime.dll` reference assembly they compile against); for a type defined in such a reference projection (detected via `IsReferenceProjectionWindowsRuntimeType`), the stem is instead recovered from the matching type in the third-party implementation projection (`WinRT.Projection.dll`), located through `RuntimeContext.GetLoadedAssemblies()`. This recovery is essential because the projection writer encodes that very same stem into the `[UnsafeAccessorType]` references it emits into the implementation projection, and the reference projection's own assembly name can differ from the stem (e.g. when several `.winmd` files are merged into a single projection assembly, as with WinUI / Windows App SDK). If the stem cannot be found anywhere, the raw assembly name is used as-is. The recovery logic lives in `GetWindowsRuntimeMetadataName` (`src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs`). > [!NOTE] > Not all BCL types live in `System.Runtime`. For example, the `System.Numerics` types (`Matrix3x2`, `Matrix4x4`, `Plane`, `Quaternion`, `Vector2`, `Vector3`, `Vector4`) are in the `System.Numerics.Vectors` assembly, so their assembly identifier is `System-Numerics-Vectors` (not `#corlib`) after the `.` → `-` substitution. The assembly used is always the one from the type's actual metadata scope, not the namespace. diff --git a/.github/skills/testing/SKILL.md b/.github/skills/testing/SKILL.md index c735aa5d2d..7875decfeb 100644 --- a/.github/skills/testing/SKILL.md +++ b/.github/skills/testing/SKILL.md @@ -13,7 +13,7 @@ Before adding tests, always check whether tests for the same functionality alrea ## Test project overview -CsWinRT 3.0 has 5 primary test project areas, each serving a different purpose. Additional specialized test projects also exist under `src/Tests/`: +CsWinRT 3.0 has 6 primary test project areas, each serving a different purpose. Additional specialized test projects also exist under `src/Tests/`: ### 1. Unit tests (`src/Tests/UnitTest/`) @@ -25,8 +25,8 @@ CsWinRT 3.0 has 5 primary test project areas, each serving a different purpose. - **Test framework:** MSTest (`[TestClass]`, `[TestMethod]`, `Assert.*`) - **TFM:** Variable via `$(AppBuildTFMs)`, multi-platform (x86/x64) - **Output type:** Exe, self-contained, AOT-enabled -- **Key dependencies:** MSTest.TestFramework, MSTest.Engine, MSTest.SourceGeneration, Microsoft.Windows.CsWin32, Newtonsoft.Json -- **References:** WinRT.SourceGenerator2 (as analyzer), Test/Windows/WinAppSDK projections +- **Key dependencies:** MSTest.TestFramework, MSTest.Engine, MSTest.SourceGeneration, Microsoft.Windows.CsWin32, Newtonsoft.Json, Microsoft.VCRTForwarders.140 +- **References:** WinRT.SourceGenerator2 (as analyzer), Test/TestSubset/Windows/WinAppSDK projections **Test organization:** - Single namespace: `UnitTest` @@ -132,9 +132,16 @@ return 100; | Test class | What it tests | |------------|---------------| | `Test_CustomPropertyProviderGenerator` | `CustomPropertyProviderGenerator` source generator output | -| `Test_GeneratedCustomPropertyProviderAttributeArgumentAnalyzer` | CSWINRT2004–2008 diagnostics | | `Test_GeneratedCustomPropertyProviderTargetTypeAnalyzer` | CSWINRT2000–2001 diagnostics | | `Test_GeneratedCustomPropertyProviderExistingMemberImplementationAnalyzer` | CSWINRT2003 diagnostic | +| `Test_GeneratedCustomPropertyProviderAttributeArgumentAnalyzer` | CSWINRT2004–2008 diagnostics | +| `Test_ComImportInterfaceAnalyzer` | CSWINRT2009 diagnostic (casts to `[ComImport]` interfaces) | +| `Test_ValidApiContractEnumTypeAnalyzer` | CSWINRT2010 diagnostic | +| `Test_ValidContractVersionAttributeAnalyzer` | CSWINRT2011–2013 diagnostics | +| `Test_ApiContractTypeRequiresContractVersionAnalyzer` | CSWINRT2014 diagnostic | +| `Test_PublicTypeRequiresVersioningAnalyzer` | CSWINRT2015 diagnostic | +| `Test_PublicTypeRequiresContractVersionAnalyzer` | CSWINRT2016 diagnostic | +| `Test_PublicTypeMixedVersioningAttributesAnalyzer` | CSWINRT2017 diagnostic | **Test helpers (in `Helpers/`):** - `CSharpGeneratorTest` — runs a generator on source code and compares output @@ -183,6 +190,7 @@ public async Task InvalidType_Warns() - Use `{|DIAGNOSTIC_ID:target|}` inline syntax to mark expected diagnostics - Or use explicit `expectedDiagnostics` array with `DiagnosticResult` for complex cases +- Pass `isCsWinRTComponent: true` to `VerifyAnalyzerAsync` for analyzers that only apply to authored components (e.g. the contract-versioning analyzers) - Test naming convention: `Condition_ExpectedBehavior` (e.g. `NullPropertyName_Warns`, `ValidClass_DoesNotWarn`) ### 4. Object lifetime tests (`src/Tests/ObjectLifetimeTests/`) @@ -201,18 +209,41 @@ public async Task InvalidType_Warns() - `AsyncQueue` helper for scheduling actions on UI thread and forcing GC - Tests named `BasicTestN()`, `CycleTestN()`, `LeakTestN()` -### 5. Authoring tests (`src/Tests/AuthoringTest/`) — currently disabled, WIP +### 5. Authoring tests (`src/Tests/AuthoringTest/`) -**What it tests:** Authoring a WinRT component in C# — validates that diverse type patterns (enums, structs, classes, interfaces, delegates, collections, XAML controls, async operations, data binding types) can be successfully projected as a WinRT component. +**What it tests:** Authoring a WinRT component in C# — validates that diverse type patterns (enums, structs, classes, interfaces, delegates, collections, XAML controls, async operations, data binding types, and contract-versioning attributes) can be successfully projected as a WinRT component. The component itself builds (build-time validation); the C++ consumption tests that exercise it (`AuthoringConsumptionTest*`) are not yet enabled in the solution. -**When to add tests here:** Currently disabled. When enabled, for testing new WinRT component authoring scenarios. +**When to add tests here:** For testing new WinRT component authoring scenarios — new type shapes, attributes, or versioning patterns. **Project settings:** -- **Type:** Class library with `CsWinRTComponent=true` -- **TFM:** `net10.0` -- **Release x64:** NativeAOT self-contained mode +- **Type:** `CsWinRTComponent=true` class library; Release x64 publishes as a Native AOT shared library (`OutputType=Exe`, `PublishAot=true`, `SelfContained=true`, `NativeLib=Shared`) +- **TFM:** `net10.0-windows10.0.26100.1` - Build-time validation (compilation succeeds = test passes) +### 6. Smoke tests (`src/Tests/SmokeTests/`) + +**What it tests:** End-to-end consumption of the **real** `Microsoft.Windows.CsWinRT` NuGet package — a consuming app, an authoring component, a third-party projection, and the Windows SDK reference projections — fully isolated from the repository build infrastructure. Validates that the packaged `ref`/`lib` assemblies, the build targets, and all post-build generators work correctly for an external customer. + +**When to add tests here:** For verifying that the produced NuGet package works in a real, isolated environment (correct `ref`/`lib` assemblies referenced, generators running). Keep these minimal — they are smoke tests, not feature coverage. Use `UnitTest/` or `FunctionalTests/` for marshalling/feature coverage instead. + +**Project structure:** Five standalone projects, intentionally kept out of `cswinrt.slnx` (the package they consume only exists after the build packs it). They are isolated from the repo build infrastructure via blank `Directory.Build.props`/`.targets` and a local `Directory.Packages.props` (central package management disabled). All shared configuration lives in `Directory.Build.props`, so each `.csproj` only carries what makes it different; the two Windows SDK projection tests additionally share `WindowsSdkContracts.targets` (which stages the SDK `.winmd` inputs). + +**Existing tests:** +| Project | Tests | +|---------|-------| +| `Consumption/` | An `Exe` that calls `JsonObject.Parse(...)` then `Stringify()` from `Windows.Data.Json`, exercising the Windows SDK projection, the interop generator, and the `WinRT.Runtime` ref/impl assemblies | +| `Authoring/` | A `CsWinRTComponent` library exposing a `Greeter` class plus a richer catalog of authored type shapes in `Thermometer.cs` (enums, a flags enum, a struct, a delegate, an interface, and a sealed runtime class with constructors, properties, an event, and static members), exercising WinMD generation, the reference projection, and the forwarder assembly. The breadth deliberately gives the `Projection` smoke test more projection shapes to cover | +| `Projection/` | A `CsWinRTGenerateReferenceProjection` library that generates a reference projection for the `Authoring` component's `.winmd` (reused via a build-ordering `ProjectReference`), exercising `cswinrtprojectionrefgen` and `cswinrtimplgen`, exactly as a NuGet projection author would | +| `WindowsSdkProjection/` | A `CsWinRTGenerateReferenceProjection` library that generates the base Windows SDK reference projection from the `Microsoft.Windows.SDK.Contracts` `.winmd` files (staged by `WindowsSdkContracts.targets`), exactly as the `Microsoft.Windows.SDK.NET.Ref` projection package is produced. Catches reference-projection codegen regressions against the full Windows SDK surface | +| `WindowsSdkXamlProjection/` | As `WindowsSdkProjection`, but for the `Windows.UI.Xaml` surface; it references the `WindowsSdkProjection` reference assembly, mirroring how the UWP XAML projection package depends on the base Windows SDK projection package | + +**Shared configuration (`Directory.Build.props`):** +- **TFM:** `net10.0-windows10.0.26100.1` (the `.1` CsWinRT 3.0 revision), with a pinned `WindowsSdkPackageVersion` so the build uses the real .NET SDK targeting pack (mirrors `src/WinRT.Internal`). The two Windows SDK projection tests override this to plain `net10.0` (a `-windows` TFM would implicitly reference the prebuilt Windows SDK projection they regenerate, colliding with every generated type), exactly as `src/WinRT.Sdk.Projection` +- `RestoreSources` overrides all inherited NuGet sources: the local CsWinRT build output (`CsWinRTPackageSource`) plus the `CsWinRTDependencies` feed (`CsWinRTDependenciesSource`), which provides the preview Windows SDK ref pack and `Microsoft.Windows.SDK.Contracts` +- `CsWinRTPackageVersion`/`CsWinRTPackageSource` default to the local `build.cmd x64 Release` output and are overridden by the build/CI that produced the package + +**How they run:** `run-smoke-tests.ps1` (parameterized by `-Test` and `-Runtime`) builds and runs the consumption app (asserting a clean exit code), builds the authoring component and verifies the generated `Authoring.winmd` defines `Authoring.Greeter`, and builds each reference-projection library (`Projection`, `WindowsSdkProjection`, `WindowsSdkXamlProjection`) verifying it produces both a forwarder and a `ref` reference assembly (shared verification). The consumption and authoring tests run on both CoreCLR and Native AOT (`-Runtime`); the three reference-projection tests are build-only and run on CoreCLR only. It is invoked after the `nuget pack` step in `src/build.cmd` (x64 only; skippable via `cswinrt_run_smoke_tests=false`) and as individual steps in `build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml`. + ## Deciding where to add tests | You want to test... | Add test to... | @@ -226,14 +257,15 @@ public async Task InvalidType_Warns() | An analyzer diagnostic | `SourceGenerator2Test/` (new `Test_*Analyzer` class or add to existing) | | GC/reference tracking behavior | `ObjectLifetimeTests/` | | XAML visual tree element lifetime | `ObjectLifetimeTests/` | -| WinRT component authoring patterns | `AuthoringTest/` (when enabled) | +| WinRT component authoring patterns | `AuthoringTest/` | +| The produced NuGet package works end-to-end (real `ref`/`lib` assemblies, generators) | `SmokeTests/` (`Consumption/`, `Authoring/`, or a reference-projection project) | | Generated projection code patterns or cross-ABI control flow | Update `TestComponentCSharp/` and add tests in `UnitTest/` or `FunctionalTests/` | ## Test component: TestComponentCSharp (`src/Tests/TestComponentCSharp/`) -A **WinRT test component** (defined in `class.idl`, implemented in C++) that complements the general `TestComponent` from the [TestWinRT](https://github.com/microsoft/TestWinRT/) submodule. It tests scenarios specific to the C#/WinRT language projection. +A **WinRT test component** (defined in `TestComponentCSharp.idl`, implemented in C++) that complements the general `TestComponent` from the [TestWinRT](https://github.com/microsoft/TestWinRT/) submodule. It tests scenarios specific to the C#/WinRT language projection. -**When to update this project:** When you need to validate generated projection code patterns or cross-ABI control flow — e.g. a C# type calling a method on a projected object with specific parameters, and the native implementation validating the result. New types and members can be added to `class.idl` as needed. +**When to update this project:** When you need to validate generated projection code patterns or cross-ABI control flow — e.g. a C# type calling a method on a projected object with specific parameters, and the native implementation validating the result. New types and members can be added to `TestComponentCSharp.idl` as needed. **Referenced from:** unit tests (`UnitTest/`), functional tests (`FunctionalTests/`), and projection test projects (`Projections/Test/`). diff --git a/.github/skills/update-copilot-instructions/SKILL.md b/.github/skills/update-copilot-instructions/SKILL.md index acb75cae46..b3ed52dd1c 100644 --- a/.github/skills/update-copilot-instructions/SKILL.md +++ b/.github/skills/update-copilot-instructions/SKILL.md @@ -28,9 +28,11 @@ Launch parallel explore agents for each of the 12 CsWinRT 3.0 projects listed in - Project settings (TFM, language version, nullable, unsafe, etc.) are current - Namespace organization matches - Reference assembly build is documented: the dual implementation/reference build driven by `CsWinRTBuildReferenceAssembly`, the `WINDOWS_RUNTIME_IMPLEMENTATION_ASSEMBLY` / `WINDOWS_RUNTIME_REFERENCE_ASSEMBLY` / `WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE` compilation symbols, the `[WindowsRuntimeImplementationOnlyMember]` marker attribute (`Attributes/WindowsRuntimeImplementationOnlyMemberAttribute.cs`), the `BannedSymbols.txt` + `Microsoft.CodeAnalysis.BannedApiAnalyzers` guard (`RS0030` as error), the reference-assembly-only `WindowsRuntimeObject()` constructor (`CSWINRT3001` obsolete diagnostic), and packaging into `ref\net10.0\` alongside the implementation in `lib\net10.0\` (`src/build.cmd`, `nuget/Microsoft.Windows.CsWinRT.nuspec`) + - The **two strategies for keeping API out of the supported surface** are documented and current: (1) **strip entirely** (the default — `[WindowsRuntimeImplementationOnlyMember]` or an excluded file/folder, so the type is absent from the reference assembly), and (2) **public but hidden** (the exception — the type stays in the reference assembly but is marked reference-assembly-only `[Obsolete(..., DiagnosticId = "CSWINRT3xxx")]` + `[EditorBrowsable(Never)]`). Strategy 2 is required only when CsWinRT-generated code that compiles against the reference assembly names the type (stripping would then cause `CS0234`/`CS0246`); the generated code suppresses the diagnostic so normal builds are unaffected. Verify the list of current strategy-2 cases is accurate and complete by checking the `CSWINRT3xxx` constants in `Properties/WindowsRuntimeConstants.cs` and the per-diagnostic pages under `docs/diagnostics/`: `CSWINRT3001` (the `WindowsRuntimeObject()` constructor), `CSWINRT3002` (the three type map group types, named by the source generator's `[assembly: TypeMapAssemblyTarget]` output), `CSWINRT3003` (`WindowsRuntimeComponentAssemblyAttribute` / `WindowsRuntimeComponentAssemblyExportsTypeAttribute`, named by the authoring generator's `ManagedExports.g.cs`), and `CSWINRT3004` (`WindowsRuntimeReferenceAssemblyAttribute`, emitted as `[assembly: WindowsRuntimeReferenceAssembly]` by the projection writer's `AssemblyAttributes.cs` base resource and shipped in reference projection assemblies). If a `CSWINRT3xxx` diagnostic is added or removed, update both the reference-assembly section and the runtime row of the "Error ID ranges" table in the instructions 2. **WinRT.SourceGenerator2 (`src/Authoring/WinRT.SourceGenerator2/`)** - Source generators listed still exist and generate what's described + - Generated output that references **public-but-hidden** runtime types still suppresses the corresponding obsolete diagnostics: `TypeMapAssemblyTargetGenerator`'s `[assembly: TypeMapAssemblyTarget]` output names the three type map group types (`CSWINRT3002`), and `AuthoringExportTypesGenerator`'s `ManagedExports.g.cs` names the component authoring attributes (`CSWINRT3003`). If a generator starts or stops emitting references to a strategy-2 type, keep this in sync with the "Two strategies for implementation-only API" coverage in the WinRT.Runtime entry above - Diagnostic analyzer list is complete and IDs are correct (check `DiagnosticDescriptors.cs` and `AnalyzerReleases.Shipped.md`) - Diagnostic ID range is accurate - Project dependencies are current diff --git a/.github/skills/update-interop-generator-instructions/SKILL.md b/.github/skills/update-interop-generator-instructions/SKILL.md index d5bd89f9c5..473f7c34f2 100644 --- a/.github/skills/update-interop-generator-instructions/SKILL.md +++ b/.github/skills/update-interop-generator-instructions/SKILL.md @@ -97,6 +97,7 @@ Launch an explore agent to verify: - **Resolver classes** in `Resolvers/` are complete and accurately described (including `InterfaceIIDResolver`, which resolves IIDs from generated `ABI.InterfaceIIDs` types) - **Reference classes** in `References/` are complete (note the CsWinRT public key and system public key tokens come from `WellKnownPublicKeys`/`WellKnownPublicKeyTokens` in `WinRT.Generator.Core`) - **Implementation-only types inventory** — verify the "Implementation-only types consumed from WinRT.Runtime" list in the `SKILL.md` "Control flow between generated code and WinRT.Runtime" section is complete and current. Cross-check its categories and representative type names against the WinRT.Runtime type references in `References/InteropReferences.cs` and against the `[WindowsRuntimeImplementationOnlyMember]`-marked types (and the stripped folders `ABI/`, `NativeObjects/`, and most of `InteropServices/`) in `src/WinRT.Runtime2/`. If implementation-only APIs were added to or removed from WinRT.Runtime, update the inventory accordingly +- **Public-but-hidden implementation-only types** — verify the `> **Note:**` that follows the implementation-only types inventory is accurate. A small subset of the consumed types (currently the three type map group types) is **not** stripped from the reference assembly but kept **public but hidden**, marked reference-assembly-only `[Obsolete(DiagnosticId = "CSWINRT3002")]` + `[EditorBrowsable(Never)]`, because CsWinRT-generated code compiled against the reference assembly names them (the source generator's `[assembly: TypeMapAssemblyTarget]` output). Confirm the note still names the right types and `CSWINRT3xxx` id(s), still states that the interop generator itself is unaffected by the distinction (it always resolves the implementation assembly, but must still treat the types as unstable and version-matched), and still points at the "Two strategies for implementation-only API" note in `.github/copilot-instructions.md`. If the set of public-but-hidden types the generator touches changes, update the note - **Well-known interface IIDs** are current (native interface entry order, and the `ReservedIIDsMap` set — verify whether `IMarshal` is included; it is currently excluded because it can be user-overridden) - **Marshaller type resolution** logic is current @@ -155,7 +156,7 @@ These docs describe the *design* of the generated code patterns. If the actual g - `marshalling-arrays.md` includes the element marshaller infrastructure (runtime interfaces, runtime array marshaller classes, generated element marshaller types, selection logic table) - `marshalling-generic-interfaces.md` includes the collection element marshaller infrastructure (runtime interfaces, GetMany adapter extension methods, generated element marshaller types, emission/reuse pattern) -- The "implementation details only" APIs in `WinRT.Runtime.dll` that the generator consumes (the runtime element-marshaller interfaces, array marshaller classes, etc.) are marked with `[WindowsRuntimeImplementationOnlyMember]` and stripped from the `WinRT.Runtime.dll` reference assembly. If this marking scheme changes, update the `SKILL.md` "Version compatibility" section and the runtime-interface descriptions in both reference docs accordingly +- The "implementation details only" APIs in `WinRT.Runtime.dll` that the generator consumes (the runtime element-marshaller interfaces, array marshaller classes, etc.) are marked with `[WindowsRuntimeImplementationOnlyMember]` and stripped from the `WinRT.Runtime.dll` reference assembly (a small subset — e.g. the type map group types — is instead kept **public but hidden** via reference-assembly-only `[Obsolete(DiagnosticId = "CSWINRT3xxx")]` + `[EditorBrowsable(Never)]`; see the public-but-hidden note in the `SKILL.md` "Control flow between generated code and WinRT.Runtime" section). If this marking scheme changes, update the `SKILL.md` "Version compatibility" section and the runtime-interface descriptions in both reference docs accordingly ### Step 14: update this skill if needed diff --git a/.github/skills/update-testing-instructions/SKILL.md b/.github/skills/update-testing-instructions/SKILL.md index 6ffe5ff9c8..5f2b42d2a2 100644 --- a/.github/skills/update-testing-instructions/SKILL.md +++ b/.github/skills/update-testing-instructions/SKILL.md @@ -68,7 +68,17 @@ Launch an explore agent to verify: - **Project settings** are current: output type, TFM, `CsWinRTComponent` setting, AOT mode - **What it tests** description is accurate -### Step 7: verify TestComponentCSharp (`src/Tests/TestComponentCSharp/`) +### Step 7: verify smoke tests (`src/Tests/SmokeTests/`) + +Launch an explore agent (or inspect directly) to verify: + +- **Project list** is accurate — the `Consumption/` app, the `Authoring/` component, the `Projection/` reference projection, and the `WindowsSdkProjection/`/`WindowsSdkXamlProjection/` Windows SDK reference projections, kept out of `cswinrt.slnx` +- **Isolation** is intact: blank `Directory.Build.props`/`.targets` and a local `Directory.Packages.props` (central package management disabled) +- **Shared configuration** in `Directory.Build.props` is current: TFM (`.1` revision; the two Windows SDK projection tests override to plain `net10.0`), pinned `WindowsSdkPackageVersion`, `RestoreSources` (local package output + the `CsWinRTDependencies` feed, which provides the preview Windows SDK ref pack and `Microsoft.Windows.SDK.Contracts`), `DisableRuntimeMarshalling`, and the `CsWinRTPackageVersion`/`CsWinRTPackageSource` defaults. Also verify `WindowsSdkContracts.targets` (the shared SDK `.winmd` staging the two SDK projection tests import) +- **What each test does** is accurate (the consumption app's `JsonObject.Parse`/`Stringify` call; the authoring component's class and `.winmd` verification; the `Projection`/`WindowsSdkProjection`/`WindowsSdkXamlProjection` libraries' reference projections, each verifying a forwarder and a `ref` assembly are produced — `Projection` over the authoring component's `.winmd`, the SDK ones over the `Microsoft.Windows.SDK.Contracts` `.winmd` files) +- **How they run** is current: the `run-smoke-tests.ps1` runner (its `-Test` and `-Runtime` parameters — consumption/authoring run on both CoreCLR and Native AOT, the three reference-projection tests on CoreCLR only via the shared forwarder + `ref` assembly verification), and the invocations in `src/build.cmd` and `build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml` + +### Step 8: verify TestComponentCSharp (`src/Tests/TestComponentCSharp/`) Launch an explore agent to verify: @@ -76,7 +86,7 @@ Launch an explore agent to verify: - **"Referenced from" list** is current - **"When to update" guidance** is still correct -### Step 8: verify the "deciding where to add tests" table +### Step 9: verify the "deciding where to add tests" table Check every row in the routing table against the actual test projects. Verify: @@ -85,7 +95,7 @@ Check every row in the routing table against the actual test projects. Verify: - No new test project categories exist that should be added as rows - The `TestComponentCSharp` guidance is still accurate -### Step 9: verify code examples +### Step 10: verify code examples For each code example in the testing skill, verify it matches the conventions actually used in the test files: @@ -94,7 +104,7 @@ For each code example in the testing skill, verify it matches the conventions ac - **Generator test pattern**: verify the `VerifySources` call matches the actual method signature and style. Check an actual test method in `Test_CustomPropertyProviderGenerator` to confirm - **Analyzer test pattern**: verify the `VerifyAnalyzerAsync` call matches the actual method signature and style. Check an actual test method in the analyzer test files to confirm -### Step 10: update the testing instructions +### Step 11: update the testing instructions Apply surgical edits to `.github/skills/testing/SKILL.md` to fix any discrepancies found. Typical updates include: @@ -115,17 +125,17 @@ Apply surgical edits to `.github/skills/testing/SKILL.md` to fix any discrepanci - Do not add unnecessary commentary or explanation beyond what's needed for test placement guidance -### Step 11: update this skill if needed +### Step 12: update this skill if needed If significant changes to the test suite were discovered (e.g. test projects added or removed, new categories of tests, changed validation criteria), also update this skill file (`.github/skills/update-testing-instructions/SKILL.md`) to reflect those changes. In particular: -- The **per-project verification steps** (steps 2–7) must stay in sync with the actual test projects. If a test project is added or removed, add or remove its verification step accordingly. +- The **per-project verification steps** (steps 2–8) must stay in sync with the actual test projects. If a test project is added or removed, add or remove its verification step accordingly. - The **verification criteria** for each step should reflect what is actually worth checking. If a project gains new aspects worth validating (e.g. new test helper classes, new build settings), add those to the checklist. -- The **code example verification step** (step 9) should list all code examples present in the testing skill. +- The **code example verification step** (step 10) should list all code examples present in the testing skill. This ensures the skill remains useful and accurate for future runs. -### Step 12: summarize changes +### Step 13: summarize changes After editing, provide a clear summary of what was updated and why, so the user can review the changes before committing. diff --git a/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml b/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml index 4fb62c6480..0c318ce774 100644 --- a/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml +++ b/build/AzurePipelineTemplates/CsWinRT-PublishToNuGet-Steps.yml @@ -124,6 +124,101 @@ steps: commit=$(Build.SourceVersion)" packDestination: $(ob_outputDirectory)\packages + # Build and run the end-to-end smoke tests against the freshly packed NuGet package. These + # verify that the real package (ref/lib assemblies, generators, and build targets) works for + # a consuming app, a component author, a projection author, and the Windows SDK projection packages, + # fully isolated from the repo build infrastructure. The smoke tests restore the package being tested + # from the packed output above, and all other dependencies (notably the preview Windows SDK ref pack + # and 'Microsoft.Windows.SDK.Contracts') from the CsWinRTDependencies feed. + # + # Each smoke test runs as its own step with 'continueOnError' (so a failure only marks the job + # as 'SucceededWithIssues' and makes it obvious which one failed); a final gate step below turns + # any such issue into an actual failure. This mirrors the unit test steps in CsWinRT-Test-Steps.yml. + # The consumption and authoring tests each run twice: once on CoreCLR and once with Native AOT, so a + # failure points at the exact runtime. The projection, Windows SDK projection, and Windows SDK XAML + # projection tests are build-only, so they run once on CoreCLR. Native AOT publishes are x64 (this job + # only runs on an x64 host). + - task: UseDotNet@2 + displayName: Use .NET SDK for smoke tests + inputs: + packageType: sdk + version: $(_DotnetVersion) + + - task: PowerShell@2 + displayName: Run Consumption smoke test (CoreCLR) + continueOnError: true + inputs: + targetType: filePath + filePath: $(Build.SourcesDirectory)\src\Tests\SmokeTests\run-smoke-tests.ps1 + arguments: -PackageSource "$(ob_outputDirectory)\packages" -PackageVersion "$(NugetVersion)" -Test Consumption -Runtime CoreCLR + workingDirectory: $(Build.SourcesDirectory) + + - task: PowerShell@2 + displayName: Run Consumption smoke test (NAOT) + continueOnError: true + inputs: + targetType: filePath + filePath: $(Build.SourcesDirectory)\src\Tests\SmokeTests\run-smoke-tests.ps1 + arguments: -PackageSource "$(ob_outputDirectory)\packages" -PackageVersion "$(NugetVersion)" -Test Consumption -Runtime NativeAot + workingDirectory: $(Build.SourcesDirectory) + + - task: PowerShell@2 + displayName: Run Authoring smoke test (CoreCLR) + continueOnError: true + inputs: + targetType: filePath + filePath: $(Build.SourcesDirectory)\src\Tests\SmokeTests\run-smoke-tests.ps1 + arguments: -PackageSource "$(ob_outputDirectory)\packages" -PackageVersion "$(NugetVersion)" -Test Authoring -Runtime CoreCLR + workingDirectory: $(Build.SourcesDirectory) + + - task: PowerShell@2 + displayName: Run Authoring smoke test (NAOT) + continueOnError: true + inputs: + targetType: filePath + filePath: $(Build.SourcesDirectory)\src\Tests\SmokeTests\run-smoke-tests.ps1 + arguments: -PackageSource "$(ob_outputDirectory)\packages" -PackageVersion "$(NugetVersion)" -Test Authoring -Runtime NativeAot + workingDirectory: $(Build.SourcesDirectory) + + - task: PowerShell@2 + displayName: Run Projection smoke test (CoreCLR) + continueOnError: true + inputs: + targetType: filePath + filePath: $(Build.SourcesDirectory)\src\Tests\SmokeTests\run-smoke-tests.ps1 + arguments: -PackageSource "$(ob_outputDirectory)\packages" -PackageVersion "$(NugetVersion)" -Test Projection -Runtime CoreCLR + workingDirectory: $(Build.SourcesDirectory) + + - task: PowerShell@2 + displayName: Run Windows SDK projection smoke test (CoreCLR) + continueOnError: true + inputs: + targetType: filePath + filePath: $(Build.SourcesDirectory)\src\Tests\SmokeTests\run-smoke-tests.ps1 + arguments: -PackageSource "$(ob_outputDirectory)\packages" -PackageVersion "$(NugetVersion)" -Test WindowsSdkProjection -Runtime CoreCLR + workingDirectory: $(Build.SourcesDirectory) + + - task: PowerShell@2 + displayName: Run Windows SDK XAML projection smoke test (CoreCLR) + continueOnError: true + inputs: + targetType: filePath + filePath: $(Build.SourcesDirectory)\src\Tests\SmokeTests\run-smoke-tests.ps1 + arguments: -PackageSource "$(ob_outputDirectory)\packages" -PackageVersion "$(NugetVersion)" -Test WindowsSdkXamlProjection -Runtime CoreCLR + workingDirectory: $(Build.SourcesDirectory) + + # Fail the job if any smoke test above failed. Each smoke test uses 'continueOnError', so an + # individual failure only marks the job as 'SucceededWithIssues'; this turns that into a real + # failure, while still letting every smoke test run and report first. + - task: PowerShell@2 + displayName: Fail if any smoke test failed + condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues') + inputs: + targetType: inline + script: | + Write-Host "##vso[task.logissue type=error]One or more smoke tests failed. See above for details." + exit 1 + - ${{ if eq(parameters.IsGitHub, false) }}: # NuGet signing diff --git a/docs/diagnostics/cswinrt3002.md b/docs/diagnostics/cswinrt3002.md new file mode 100644 index 0000000000..193102af5b --- /dev/null +++ b/docs/diagnostics/cswinrt3002.md @@ -0,0 +1,28 @@ +# CsWinRT warning CSWINRT3002 + +The Windows Runtime type map group types (`WindowsRuntimeComWrappersTypeMapGroup`, `WindowsRuntimeMetadataTypeMapGroup`, and `DynamicInterfaceCastableImplementationTypeMapGroup`, all in the `WindowsRuntime.InteropServices` namespace) are a private implementation detail of `WinRT.Runtime.dll`. They are only meant to be used as type map group type arguments for the `System.Runtime.InteropServices.TypeMapping` APIs, in marshalling code generated by CsWinRT. They are exposed in the reference assembly for `WinRT.Runtime.dll` solely so that this generated code can reference them, and they are not intended for direct use in user code. + +For instance, the following sample generates CSWINRT3002: + +```csharp +using System.Runtime.InteropServices; +using WindowsRuntime.InteropServices; + +namespace MyProgram; + +// CSWINRT3002: the type map group types are a private implementation detail +[assembly: TypeMapAssemblyTarget("MyComponent")] +``` + +## Additional resources + +`CSWINRT3002` is emitted when user code references one of the Windows Runtime type map group types directly. These types act as type map group markers for the .NET interop type map infrastructure: the CsWinRT source generator emits `[assembly: TypeMapAssemblyTarget(...)]` attributes to register the assemblies that contain type map entries, and the interop generator (`cswinrtinteropgen.exe`) emits the corresponding entries. All of that generated code suppresses this diagnostic, so it never affects normal builds. + +The type map group types are not considered part of the versioned API surface of `WinRT.Runtime.dll`, and they may be modified or removed across any version change. Using them in user code is undefined behavior and not supported. + +## Recommended action + +- Do not reference the type map group types in user code, and let CsWinRT generate the type map registration for you. +- If you are authoring or consuming a Windows Runtime component, the required `[assembly: TypeMapAssemblyTarget(...)]` attributes are generated automatically; no manual registration is needed. + +Keeping the type map group types exclusive to generated code is what allows CsWinRT to evolve the interop type map infrastructure rapidly. Respecting the diagnostic ensures your applications remain stable across updates. diff --git a/docs/diagnostics/cswinrt3003.md b/docs/diagnostics/cswinrt3003.md new file mode 100644 index 0000000000..c5840a7d07 --- /dev/null +++ b/docs/diagnostics/cswinrt3003.md @@ -0,0 +1,25 @@ +# CsWinRT warning CSWINRT3003 + +The Windows Runtime component assembly attributes (`WindowsRuntimeComponentAssemblyAttribute` and `WindowsRuntimeComponentAssemblyExportsTypeAttribute`, both in the `WindowsRuntime.InteropServices` namespace) are a private implementation detail of `WinRT.Runtime.dll`. They are only meant to be applied to authored Windows Runtime component assemblies by CsWinRT, to mark them and to identify the generated type that contains their activation factory entry point. They are exposed in the reference assembly for `WinRT.Runtime.dll` solely so that this generated code can reference them, and they are not intended for direct use in user code. + +For instance, the following sample generates CSWINRT3003: + +```csharp +using WindowsRuntime.InteropServices; + +// CSWINRT3003: the component assembly attributes are a private implementation detail +[assembly: WindowsRuntimeComponentAssembly] +``` + +## Additional resources + +`CSWINRT3003` is emitted when user code references one of the Windows Runtime component assembly attributes directly. These attributes identify an authored Windows Runtime component assembly and the generated type that exposes its managed `GetActivationFactory` method: the CsWinRT source generator emits them automatically when building a Windows Runtime component (when `CsWinRTComponent` is set to `true`), and other CsWinRT tooling (the source generator, the projection generator, and the interop generator) reads them to merge activation factories across referenced components. All of that generated code suppresses this diagnostic, so it never affects normal builds. + +The component assembly attributes are not considered part of the versioned API surface of `WinRT.Runtime.dll`, and they may be modified or removed across any version change. Using them in user code is undefined behavior and not supported. + +## Recommended action + +- Do not reference the component assembly attributes in user code, and let CsWinRT emit them for you. +- If you are authoring a Windows Runtime component, set `CsWinRTComponent` to `true` and let CsWinRT generate the activation factory exports (and the attributes that identify them) automatically; no manual annotation is needed. + +Keeping the component assembly attributes exclusive to generated code is what allows CsWinRT to evolve the authoring infrastructure rapidly. Respecting the diagnostic ensures your applications remain stable across updates. diff --git a/docs/diagnostics/cswinrt3004.md b/docs/diagnostics/cswinrt3004.md new file mode 100644 index 0000000000..4874c87c32 --- /dev/null +++ b/docs/diagnostics/cswinrt3004.md @@ -0,0 +1,25 @@ +# CsWinRT warning CSWINRT3004 + +The `WindowsRuntimeReferenceAssemblyAttribute` type (in the `WindowsRuntime.InteropServices` namespace) is a private implementation detail of `WinRT.Runtime.dll`. It is only meant to be applied (via `[assembly: WindowsRuntimeReferenceAssembly]`) to generated Windows Runtime projection assemblies by CsWinRT, to identify them as containing projected Windows Runtime APIs. Unlike most other CsWinRT implementation details, it is not stripped from the reference assembly for `WinRT.Runtime.dll`, because the reference projection assemblies that ship in Windows Runtime projection NuGet packages carry it and it must remain resolvable when those assemblies are consumed. It is not intended for direct use in user code. + +For instance, the following sample generates CSWINRT3004: + +```csharp +using WindowsRuntime.InteropServices; + +// CSWINRT3004: the reference assembly attribute is a private implementation detail +[assembly: WindowsRuntimeReferenceAssembly] +``` + +## Additional resources + +`CSWINRT3004` is emitted when user code references the `WindowsRuntimeReferenceAssemblyAttribute` type directly. This attribute marks an assembly as containing generated Windows Runtime APIs from a given Windows Runtime metadata file (`.winmd`): CsWinRT emits it automatically into the reference projection assemblies it produces (via `cswinrtprojectionrefgen.exe` and `cswinrtprojectiongen.exe`), and CsWinRT tooling reads it to recognize those assemblies. All of that generated code suppresses this diagnostic, so it never affects normal builds. + +The reference assembly attribute is not considered part of the versioned API surface of `WinRT.Runtime.dll`, and it may be modified or removed across any version change. Using it in user code is undefined behavior and not supported. + +## Recommended action + +- Do not reference the `WindowsRuntimeReferenceAssemblyAttribute` type in user code, and let CsWinRT emit it for you. +- If you are authoring a Windows Runtime projection to ship in a NuGet package, set `CsWinRTGenerateReferenceProjection` to `true` and let CsWinRT generate the reference projection (and the attribute that identifies it) automatically; no manual annotation is needed. + +Keeping the reference assembly attribute exclusive to generated code is what allows CsWinRT to evolve the projection infrastructure rapidly. Respecting the diagnostic ensures your applications remain stable across updates. diff --git a/docs/structure.md b/docs/structure.md index e0895712cd..e6d320fbab 100644 --- a/docs/structure.md +++ b/docs/structure.md @@ -41,15 +41,31 @@ Contains several projects for generating and building projections from the Windo Contains various testing-related projects: -- [`TestComponentCSharp`](../src/Tests/TestComponentCSharp): This is an implementation of a WinRT test component, defined in `class.idl` and used by the UnitTest project. To complement the general TestComponent above, the TestComponentCSharp tests scenarios specific to the C#/WinRT language projection. +- [`TestComponentCSharp`](../src/Tests/TestComponentCSharp): An implementation of a WinRT test component, defined in `TestComponentCSharp.idl` and used by the UnitTest and functional test projects. To complement the general TestComponent above, the TestComponentCSharp tests scenarios specific to the C#/WinRT language projection. -- [`UnitTest`](../src/Tests/UnitTest): Unit tests for validating the Windows SDK, WinUI, and Test projections generated above. All pull requests should ensure that this project executes without errors. +- [`UnitTest`](../src/Tests/UnitTest): MSTest unit tests for validating the Windows SDK, WinUI, and Test projections generated above, plus core marshalling, COM interop, exceptions, and source-generator integration. All pull requests should ensure that this project executes without errors. -- [`HostTest`](../src/Tests/HostTest): Unit tests for WinRT.Host.dll, which provides hosting for runtime components written in C#. +- [`FunctionalTests`](../src/Tests/FunctionalTests): A collection of standalone console applications, each validating a specific interop scenario (async, collections, events, CCW, dynamic casting, structs, and more) under real publishing conditions such as trimming and Native AOT. Each test reports success with exit code `100`. + +- [`SourceGenerator2Test`](../src/Tests/SourceGenerator2Test): MSTest unit tests for the source generators and diagnostic analyzers in `WinRT.SourceGenerator2`, built on the Roslyn testing libraries. + +- [`ObjectLifetimeTests`](../src/Tests/ObjectLifetimeTests): A WinUI application-style MSTest project validating reference tracking, garbage collection behavior, and XAML element lifetime. + +- [`SmokeTests`](../src/Tests/SmokeTests): Minimal, isolated end-to-end smoke tests that consume the real `Microsoft.Windows.CsWinRT` NuGet package — a consumption app (`Consumption`), an authoring component (`Authoring`), a reference projection for a third-party `.winmd` (`Projection`), and reference projections for the Windows SDK (`WindowsSdkProjection`) and its `Windows.UI.Xaml` surface (`WindowsSdkXamlProjection`) — to verify the produced package works correctly outside the repository build infrastructure. + +- [`AuthoringTest`](../src/Tests/AuthoringTest): A C#-authored WinRT component (`CsWinRTComponent=true`) covering a broad set of authoring type patterns. Companion projects exercise consuming authored components — `AuthoringTest2`/`AuthoringTest3`, the `AuthoringConsumptionTest*` C++ consumers, and the WUX (`Windows.UI.Xaml`) and WinUI variants — several of which are still work in progress. + +- [`HostTest`](../src/Tests/HostTest): C++ (gtest) tests for `WinRT.Host.dll`, which provides hosting for runtime components written in C#. + +- [`DiagnosticTests`](../src/Tests/DiagnosticTests): Tests for the CsWinRT diagnostic and analyzer rules, driven by positive and negative source snippets. + +- [`BuildDeterminismTest`](../src/Tests/BuildDeterminismTest): Builds a component twice and compares the hashes of the generated `WinRT.Interop.dll` to verify deterministic builds. + +- [`OOPExe`](../src/Tests/OOPExe): An out-of-process executable harness used by the authoring test scenarios. ## [`src/TestWinRT`](https://github.com/microsoft/TestWinRT/) -C#/WinRT makes use of the standalone [TestWinRT](https://github.com/microsoft/TestWinRT/) repository for general language projection test coverage. This repo is cloned into the root of the C#/WinRT repo, via `get_testwinrt.cmd`, so that `cswinrt.sln` can resolve its reference to `TestComponent.vcxproj`. The resulting `TestComponent` and `BenchmarkComponent` files are consumed by the UnitTest and Benchmarks projects above. +C#/WinRT makes use of the standalone [TestWinRT](https://github.com/microsoft/TestWinRT/) repository for general language projection test coverage. This repo is cloned into the root of the C#/WinRT repo, via `get_testwinrt.cmd`, so that `cswinrt.slnx` can resolve its reference to `TestComponent.vcxproj`. The resulting `TestComponent` and `BenchmarkComponent` files are consumed by the UnitTest and Benchmarks projects above. ## [`src/WinRT.Generator.Tasks`](../src/WinRT.Generator.Tasks) diff --git a/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets b/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets index bf683b9dff..8886ce220b 100644 --- a/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets +++ b/nuget/Microsoft.Windows.CsWinRT.CsWinRTGen.targets @@ -81,6 +81,27 @@ Copyright (C) Microsoft Corporation. All rights reserved. --> <_CsWinRTSdkProjectionAssemblyPath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '$(IntermediateOutputPath)', 'WinRT.Sdk.Projection.dll')) + + $([MSBuild]::NormalizePath('$(CsWinRTPath)', 'lib', 'net10.0', 'WinRT.Runtime.dll')) + + + true + $(DefineConstants);CSWINRT_REFERENCE_PROJECTION @@ -171,10 +192,18 @@ Copyright (C) Microsoft Corporation. All rights reserved. Outputs="$(_CsWinRTGeneratorInteropAssemblyPath)" Condition="'$(CsWinRTGenerateInteropAssembly2)' == 'true'"> + + + <_InteropReferenceAssemblyPaths Include="@(ReferencePathWithRefAssemblies)" Condition="'%(FileName)' != 'WinRT.Runtime' or '$(CsWinRTSwapRuntimeReferenceAssembly)' != 'true'" /> + <_InteropReferenceAssemblyPaths Include="$(CsWinRTRuntimeImplementationAssemblyPath)" Condition="'$(CsWinRTSwapRuntimeReferenceAssembly)' == 'true'" /> + <_InteropImplementationAssemblyPaths Include="@(ReferencePath)" Condition="'%(FileName)' != 'WinRT.Runtime' or '$(CsWinRTSwapRuntimeReferenceAssembly)' != 'true'" /> + <_InteropImplementationAssemblyPaths Include="$(CsWinRTRuntimeImplementationAssemblyPath)" Condition="'$(CsWinRTSwapRuntimeReferenceAssembly)' == 'true'" /> + + <_WinMDPathsList Include="$(CsWinRTInteropMetadata)" /> - <_MergedProjectionReferenceAssemblyPaths Include="@(ReferencePathWithRefAssemblies)" /> + + + <_MergedProjectionReferenceAssemblyPaths Include="@(ReferencePathWithRefAssemblies)" Condition="'%(FileName)' != 'WinRT.Runtime' or '$(CsWinRTSwapRuntimeReferenceAssembly)' != 'true'" /> + <_MergedProjectionReferenceAssemblyPaths Include="$(CsWinRTRuntimeImplementationAssemblyPath)" Condition="'$(CsWinRTSwapRuntimeReferenceAssembly)' == 'true'" /> <_MergedProjectionReferenceAssemblyPaths Include="$(_CsWinRTSdkProjectionAssemblyPath)" /> <_MergedProjectionReferenceAssemblyPaths Include="$(_CsWinRTSdkXamlAssemblyPath)" Condition="'$(CsWinRTUseWindowsUIXamlProjections)' == 'true'" /> @@ -397,8 +429,12 @@ Copyright (C) Microsoft Corporation. All rights reserved. Condition="'$(CsWinRTGenerateInteropAssembly2)' == 'true'"> - <_ComponentProjectionReferenceAssemblyPaths Include="@(ReferencePath)" Condition="!$([System.String]::new('%(Identity)').EndsWith('.winmd'))" /> + + + <_ComponentProjectionReferenceAssemblyPaths Include="@(ReferencePath)" Condition="!$([System.String]::new('%(Identity)').EndsWith('.winmd')) and ('%(FileName)' != 'WinRT.Runtime' or '$(CsWinRTSwapRuntimeReferenceAssembly)' != 'true')" /> + <_ComponentProjectionReferenceAssemblyPaths Include="$(CsWinRTRuntimeImplementationAssemblyPath)" Condition="'$(CsWinRTSwapRuntimeReferenceAssembly)' == 'true'" /> <_ComponentProjectionReferenceAssemblyPaths Include="@(IntermediateAssembly)" Condition="'$(CsWinRTComponent)' == 'true'" /> + <_ComponentWinMDPaths Include="@(_WinMDPathsList)" /> <_ComponentWinMDPaths Include="$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '$(IntermediateOutputPath)', '$(AssemblyName).winmd'))" @@ -479,11 +515,15 @@ Copyright (C) Microsoft Corporation. All rights reserved. <_SdkWinMDPathsList Include="$([MSBuild]::ValueOrDefault('%(_SdkReferencePathsWithWinMDs.CsWinRTInputs)', '').Split(';'))" Condition="'%(_SdkReferencePathsWithWinMDs.CsWinRTInputs)' != ''" /> <_SdkWinMDPathsList Include="$(CsWinRTInteropMetadata)" /> + + + <_SdkProjectionReferenceAssemblyPaths Include="@(ReferencePathWithRefAssemblies)" Condition="'%(FileName)' != 'WinRT.Runtime' or '$(CsWinRTSwapRuntimeReferenceAssembly)' != 'true'" /> + <_SdkProjectionReferenceAssemblyPaths Include="$(CsWinRTRuntimeImplementationAssemblyPath)" Condition="'$(CsWinRTSwapRuntimeReferenceAssembly)' == 'true'" /> <_SdkXamlWinMDPathsList Include="$(CsWinRTInteropMetadata)" /> - <_SdkXamlProjectionReferenceAssemblyPaths Include="@(ReferencePathWithRefAssemblies)" /> + + + <_SdkXamlProjectionReferenceAssemblyPaths Include="@(ReferencePathWithRefAssemblies)" Condition="'%(FileName)' != 'WinRT.Runtime' or '$(CsWinRTSwapRuntimeReferenceAssembly)' != 'true'" /> + <_SdkXamlProjectionReferenceAssemblyPaths Include="$(CsWinRTRuntimeImplementationAssemblyPath)" Condition="'$(CsWinRTSwapRuntimeReferenceAssembly)' == 'true'" /> <_SdkXamlProjectionReferenceAssemblyPaths Include="$(_CsWinRTSdkProjectionAssemblyPath)" /> diff --git a/nuget/Microsoft.Windows.CsWinRT.targets b/nuget/Microsoft.Windows.CsWinRT.targets index f49b39b545..af55bcd22b 100644 --- a/nuget/Microsoft.Windows.CsWinRT.targets +++ b/nuget/Microsoft.Windows.CsWinRT.targets @@ -237,12 +237,25 @@ Copyright (C) Microsoft Corporation. All rights reserved. DependsOnTargets="CsWinRTPrepareProjection;CsWinRTRemoveWinMDReferences;CsWinRTResolveWindowsMetadata;_ResolveCsWinRToolsDirectory" Condition="'$(CsWinRTGenerateProjection)' == 'true'"> + + + <_CsWinRTSkipProjectionRefGeneration Condition="'$(CsWinRTComponent)' == 'true' and '@(CsWinRTInputs)' == ''">true + + - @@ -319,8 +332,10 @@ Copyright (C) Microsoft Corporation. All rights reserved. <_CsWinRTRefInputs Include="@(_CsWinRTRefInteropInputs)" /> - + + $(MSBuildThisFileDirectory)WinRT.Projection.Ref.Generator\bin\$(Configuration)\net10.0\$(_CsWinRTToolsArchFolder) $(MSBuildThisFileDirectory)WinRT.WinMD.Generator\bin\$(Configuration)\net10.0\$(_CsWinRTToolsArchFolder) AnyCPU + + + false diff --git a/src/Tests/SmokeTests/.gitignore b/src/Tests/SmokeTests/.gitignore new file mode 100644 index 0000000000..3f4be6546e --- /dev/null +++ b/src/Tests/SmokeTests/.gitignore @@ -0,0 +1,5 @@ +# The smoke tests are isolated from the repository build infrastructure and use the default +# project-relative build output folders (rather than the repo's '_build' output), so ignore +# them here to keep build artifacts out of source control. +bin/ +obj/ diff --git a/src/Tests/SmokeTests/Authoring/Authoring.csproj b/src/Tests/SmokeTests/Authoring/Authoring.csproj new file mode 100644 index 0000000000..42d7c28cfe --- /dev/null +++ b/src/Tests/SmokeTests/Authoring/Authoring.csproj @@ -0,0 +1,15 @@ + + + + + + + true + + diff --git a/src/Tests/SmokeTests/Authoring/Greeter.cs b/src/Tests/SmokeTests/Authoring/Greeter.cs new file mode 100644 index 0000000000..12a1de64df --- /dev/null +++ b/src/Tests/SmokeTests/Authoring/Greeter.cs @@ -0,0 +1,9 @@ +namespace Authoring; + +public sealed class Greeter +{ + public string Greet(string name) + { + return $"Hello, {name}!"; + } +} diff --git a/src/Tests/SmokeTests/Authoring/Thermometer.cs b/src/Tests/SmokeTests/Authoring/Thermometer.cs new file mode 100644 index 0000000000..2832e9e3ac --- /dev/null +++ b/src/Tests/SmokeTests/Authoring/Thermometer.cs @@ -0,0 +1,105 @@ +using System; + +namespace Authoring; + +// A richer set of authored Windows Runtime types, exercised end-to-end by the projection smoke +// test: building the component produces 'Authoring.winmd', which the projection smoke test then +// generates a reference projection for. Between them, these cover the main projection shapes: +// enums, a flags enum, a struct, a delegate, an interface, a sealed runtime class with multiple +// constructors, instance methods, properties, an event, and static members, and an unsealed +// (derivable) runtime class. + +public enum Season +{ + Spring, + Summer, + Autumn, + Winter +} + +[Flags] +public enum SensorCapabilities : uint +{ + None = 0, + Temperature = 1, + Humidity = 2, + All = Temperature | Humidity +} + +public struct Measurement +{ + public int Value; + public Season Season; +} + +public delegate void TemperatureChangedHandler(int previousValue, int currentValue); + +public interface IThermometer +{ + int Temperature { get; } + + void Reset(); +} + +public sealed class Thermometer : IThermometer +{ + private int _temperature; + + public event TemperatureChangedHandler? TemperatureChanged; + + public Thermometer() + { + } + + public Thermometer(int initialTemperature) + { + _temperature = initialTemperature; + } + + public static int AbsoluteZero => -273; + + public int Temperature => _temperature; + + public string Label { get; set; } + + public Season CurrentSeason { get; set; } + + public SensorCapabilities Capabilities { get; set; } + + public static Thermometer CreateFreezing() + { + return new Thermometer(0); + } + + public void Reset() + { + SetTemperature(0); + } + + public void SetTemperature(int value) + { + int previousValue = _temperature; + + _temperature = value; + + TemperatureChanged?.Invoke(previousValue, value); + } + + public Measurement Measure() + { + return new Measurement { Value = _temperature, Season = CurrentSeason }; + } +} + +// TODO: uncomment this when authoring unsealed classes is supported +// public class Weather +// { +// public string Location { get; set; } +// +// public Season CurrentSeason { get; set; } +// +// public int Forecast() +// { +// return CurrentSeason == Season.Winter ? -5 : 20; +// } +// } diff --git a/src/Tests/SmokeTests/Consumption/Consumption.csproj b/src/Tests/SmokeTests/Consumption/Consumption.csproj new file mode 100644 index 0000000000..e473292ceb --- /dev/null +++ b/src/Tests/SmokeTests/Consumption/Consumption.csproj @@ -0,0 +1,13 @@ + + + + + Exe + + diff --git a/src/Tests/SmokeTests/Consumption/Program.cs b/src/Tests/SmokeTests/Consumption/Program.cs new file mode 100644 index 0000000000..81318c24f0 --- /dev/null +++ b/src/Tests/SmokeTests/Consumption/Program.cs @@ -0,0 +1,8 @@ +using System; +using Windows.Data.Json; + +JsonObject json = JsonObject.Parse("""{ "a": 42 }"""); + +string stringified = json.Stringify(); + +return stringified.Contains("42") ? 0 : 1; diff --git a/src/Tests/SmokeTests/Directory.Build.props b/src/Tests/SmokeTests/Directory.Build.props new file mode 100644 index 0000000000..c08d0cc326 --- /dev/null +++ b/src/Tests/SmokeTests/Directory.Build.props @@ -0,0 +1,55 @@ + + + + + net10.0-windows10.0.26100.1 + 10.0.17763.0 + 10.0.26100.85-preview + + + true + + + + + 0.0.0-private.0 + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..', '..', '_build', 'x64', 'Release', 'cswinrt', 'bin')) + + + https://pkgs.dev.azure.com/shine-oss/CsWinRT/_packaging/CsWinRTDependencies/nuget/v3/index.json + + + $(CsWinRTPackageSource);$(CsWinRTDependenciesSource) + + + + + + diff --git a/src/Tests/SmokeTests/Directory.Build.targets b/src/Tests/SmokeTests/Directory.Build.targets new file mode 100644 index 0000000000..9751b5521c --- /dev/null +++ b/src/Tests/SmokeTests/Directory.Build.targets @@ -0,0 +1,10 @@ + + + + diff --git a/src/Tests/SmokeTests/Directory.Packages.props b/src/Tests/SmokeTests/Directory.Packages.props new file mode 100644 index 0000000000..631be2ff9a --- /dev/null +++ b/src/Tests/SmokeTests/Directory.Packages.props @@ -0,0 +1,13 @@ + + + + + false + + diff --git a/src/Tests/SmokeTests/Projection/Projection.csproj b/src/Tests/SmokeTests/Projection/Projection.csproj new file mode 100644 index 0000000000..066d7854a9 --- /dev/null +++ b/src/Tests/SmokeTests/Projection/Projection.csproj @@ -0,0 +1,39 @@ + + + + + + + true + + + Authoring + + + + + + + + + + + diff --git a/src/Tests/SmokeTests/WindowsSdkContracts.targets b/src/Tests/SmokeTests/WindowsSdkContracts.targets new file mode 100644 index 0000000000..fa2f0425d2 --- /dev/null +++ b/src/Tests/SmokeTests/WindowsSdkContracts.targets @@ -0,0 +1,56 @@ + + + + + <_SdkContractsPackageName>Microsoft.Windows.SDK.Contracts + + + <_SdkContractsPackageVersion>10.0.26100.7705 + + + + + + + + + + + + <_SdkContractsWinMDFolder>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', '$(_SdkContractsPackageName)', '$(_SdkContractsPackageVersion)', 'ref', 'netstandard2.0')) + + + + + + + + + diff --git a/src/Tests/SmokeTests/WindowsSdkProjection/WindowsSdkProjection.csproj b/src/Tests/SmokeTests/WindowsSdkProjection/WindowsSdkProjection.csproj new file mode 100644 index 0000000000..9fec3e58a4 --- /dev/null +++ b/src/Tests/SmokeTests/WindowsSdkProjection/WindowsSdkProjection.csproj @@ -0,0 +1,59 @@ + + + + + + + net10.0 + + + true + + + Windows; + Windows.UI.Xaml.Interop; + Windows.UI.Xaml.Data.BindableAttribute; + Windows.UI.Xaml.Markup.ContentPropertyAttribute + + + Windows.UI.Colors; + Windows.UI.ColorHelper; + Windows.UI.IColorHelper; + Windows.UI.IColors; + Windows.UI.Text.FontWeights; + Windows.UI.Text.IFontWeights; + Windows.UI.Xaml; + Windows.ApplicationModel.Store.Preview.WebAuthenticationCoreManagerHelper; + Windows.ApplicationModel.Store.Preview.IWebAuthenticationCoreManagerHelper + + + + + + diff --git a/src/Tests/SmokeTests/WindowsSdkXamlProjection/WindowsSdkXamlProjection.csproj b/src/Tests/SmokeTests/WindowsSdkXamlProjection/WindowsSdkXamlProjection.csproj new file mode 100644 index 0000000000..926598c697 --- /dev/null +++ b/src/Tests/SmokeTests/WindowsSdkXamlProjection/WindowsSdkXamlProjection.csproj @@ -0,0 +1,66 @@ + + + + + + + net10.0 + + + true + + + Windows.UI.Colors; + Windows.UI.ColorHelper; + Windows.UI.IColorHelper; + Windows.UI.IColors; + Windows.UI.Text.FontWeights; + Windows.UI.Text.IFontWeights; + Windows.UI.Xaml; + Windows.ApplicationModel.Store.Preview.WebAuthenticationCoreManagerHelper; + Windows.ApplicationModel.Store.Preview.IWebAuthenticationCoreManagerHelper + + + Windows; + Windows.UI.Xaml.Interop; + Windows.UI.Xaml.Data.BindableAttribute; + Windows.UI.Xaml.Markup.ContentPropertyAttribute + + + + + + + + + + $(MSBuildThisFileDirectory)..\WindowsSdkProjection\bin\$(Configuration)\$(TargetFramework)\ref\WindowsSdkProjection.dll + false + + + + + + diff --git a/src/Tests/SmokeTests/run-smoke-tests.ps1 b/src/Tests/SmokeTests/run-smoke-tests.ps1 new file mode 100644 index 0000000000..a58dd0ff2c --- /dev/null +++ b/src/Tests/SmokeTests/run-smoke-tests.ps1 @@ -0,0 +1,280 @@ +#!/usr/bin/env pwsh + +<# +.SYNOPSIS + Builds and runs the C#/WinRT end-to-end smoke tests against a real + 'Microsoft.Windows.CsWinRT' NuGet package. + +.DESCRIPTION + These smoke tests verify that the real NuGet package works for the two main consumer + scenarios, in isolation from the CsWinRT repository build infrastructure: + + * Consumption: a .NET app that uses a Windows SDK projection ('Windows.Data.Json') is + built and run, validating that the generated projection and interop assemblies, and + the 'WinRT.Runtime' ref/impl assemblies, are wired up correctly. + + * Authoring: a Windows Runtime component library is built, validating WinMD + generation, the reference projection, and the forwarder assembly. + + * Projection: a class library generates a reference projection for a third-party + component's '.winmd' (reusing the one emitted by the authoring test), validating the + reference projection generator and the forwarder generator, exactly as a NuGet + projection author would. + + * WindowsSdkProjection: a class library generates the base Windows SDK reference projection + from the 'Microsoft.Windows.SDK.Contracts' '.winmd' files, exactly as the + 'Microsoft.Windows.SDK.NET.Ref' projection package is produced. This validates that the full + Windows SDK surface generates and compiles against the packaged 'WinRT.Runtime' reference + assembly, catching reference-projection codegen regressions before they break that package. + + * WindowsSdkXamlProjection: as above, but for the 'Windows.UI.Xaml' surface, which references the + base Windows SDK reference projection (mirroring how the UWP XAML projection package depends on + the base Windows SDK projection package). + + The smoke tests reference the package via 'RestoreSources' (see the '.csproj' files), so + no global NuGet configuration changes are required. + +.PARAMETER PackageSource + Folder containing the built 'Microsoft.Windows.CsWinRT' NuGet package. + +.PARAMETER PackageVersion + Version of the 'Microsoft.Windows.CsWinRT' package to consume. + +.PARAMETER Test + Which smoke test(s) to run: 'Consumption', 'Authoring', 'Projection', 'WindowsSdkProjection', + 'WindowsSdkXamlProjection', or 'All' (the default). The CI runs each test as its own step (passing a + single value), so an individual failure is reported in isolation; local builds use the default 'All'. + +.PARAMETER Runtime + Which runtime to target: 'CoreCLR' (the default) builds and runs on the managed runtime; + 'NativeAot' publishes the project with Native AOT ('PublishAot=true', win-x64), exercising the + full publish pipeline (projection and interop generators, then ILC). The CI runs both as + separate steps so a failure points at the exact runtime. The 'Projection', 'WindowsSdkProjection', + and 'WindowsSdkXamlProjection' tests are build-only and therefore CoreCLR-only; they are skipped for + 'NativeAot'. + +.PARAMETER Configuration + Build configuration to use (defaults to 'Release'). + +.EXAMPLE + ./run-smoke-tests.ps1 -PackageSource ../../_build/x64/Release/cswinrt/bin -PackageVersion 0.0.0-private.0 + +.EXAMPLE + ./run-smoke-tests.ps1 -PackageSource ./packages -PackageVersion 3.0.0-preview.1 -Test Consumption -Runtime NativeAot +#> + +[CmdletBinding()] +param ( + [Parameter(Mandatory = $true)] + [string] $PackageSource, + + [Parameter(Mandatory = $true)] + [string] $PackageVersion, + + [ValidateSet('All', 'Consumption', 'Authoring', 'Projection', 'WindowsSdkProjection', 'WindowsSdkXamlProjection')] + [string] $Test = 'All', + + [ValidateSet('CoreCLR', 'NativeAot')] + [string] $Runtime = 'CoreCLR', + + [string] $Configuration = 'Release' +) + +$ErrorActionPreference = 'Stop' + +# Native AOT publishes are always x64: the NuGet publish job that runs the smoke tests only runs +# on an x64 host. +$nativeAotRid = 'win-x64' + +$smokeTestsRoot = $PSScriptRoot +$consumptionProject = [IO.Path]::Combine($smokeTestsRoot, 'Consumption', 'Consumption.csproj') +$authoringProject = [IO.Path]::Combine($smokeTestsRoot, 'Authoring', 'Authoring.csproj') +$projectionProject = [IO.Path]::Combine($smokeTestsRoot, 'Projection', 'Projection.csproj') +$windowsSdkProjectionProject = [IO.Path]::Combine($smokeTestsRoot, 'WindowsSdkProjection', 'WindowsSdkProjection.csproj') +$windowsSdkXamlProjectionProject = [IO.Path]::Combine($smokeTestsRoot, 'WindowsSdkXamlProjection', 'WindowsSdkXamlProjection.csproj') + +# Resolve the package source to an absolute path (NuGet rejects relative '--source' values). +$resolvedPackageSource = (Resolve-Path -Path $PackageSource).Path + +Write-Host "Smoke tests: consuming CsWinRT package '$PackageVersion' from '$resolvedPackageSource'" -ForegroundColor Cyan + +$commonBuildArgs = @( + '--configuration', $Configuration + "-p:CsWinRTPackageSource=$resolvedPackageSource" + "-p:CsWinRTPackageVersion=$PackageVersion" +) + +function Invoke-Dotnet { + param ([string[]] $Arguments) + + Write-Host "> dotnet $($Arguments -join ' ')" -ForegroundColor DarkGray + & dotnet @Arguments + if ($LASTEXITCODE -ne 0) { + throw "Command 'dotnet $($Arguments -join ' ')' failed with exit code $LASTEXITCODE." + } +} + +function Assert-WinMDDefinesType { + param ( + [Parameter(Mandatory = $true)] [string] $Path, + [Parameter(Mandatory = $true)] [string] $Namespace, + [Parameter(Mandatory = $true)] [string] $TypeName + ) + + # Deliberately lightweight inspection (no managed-metadata dependencies, works in any + # PowerShell host): a Windows Runtime metadata file carries the 'WindowsRuntime 1.4' + # metadata version, and a type's namespace and name are stored as separate, null-terminated + # entries in the metadata strings heap. + $text = [Text.Encoding]::ASCII.GetString([IO.File]::ReadAllBytes($Path)) + + if (-not $text.Contains('WindowsRuntime 1.4')) { + throw "'$Path' is not a Windows Runtime metadata (.winmd) file." + } + + foreach ($name in @($Namespace, $TypeName)) { + if (-not $text.Contains("$name`0")) { + throw "'$Path' does not define '$Namespace.$TypeName' (missing '$name')." + } + } + + Write-Host "Verified '$([IO.Path]::GetFileName($Path))' defines '$Namespace.$TypeName'." -ForegroundColor DarkGray +} + +# Consumption: build (CoreCLR) or Native AOT publish, then run (must not crash). +function Invoke-ConsumptionSmokeTest { + Write-Host "`n=== Consumption smoke test ($Runtime) ===" -ForegroundColor Green + + if ($Runtime -eq 'NativeAot') { + # Publish the whole app with Native AOT (self-contained, no managed host). + Invoke-Dotnet (@('publish', $consumptionProject, '--runtime', $nativeAotRid, '-p:PublishAot=true') + $commonBuildArgs) + } + else { + Invoke-Dotnet (@('build', $consumptionProject) + $commonBuildArgs) + } + + # Locate the freshly built app, asserting a clean (zero) exit code when run. A Native AOT + # publish drops a self-contained '.exe' under a 'publish' folder, so filter to it; a CoreCLR + # build leaves the '.exe' directly under the target framework folder. + $consumptionExe = Get-ChildItem -Path ([IO.Path]::Combine($smokeTestsRoot, 'Consumption', 'bin')) -Filter 'Consumption.exe' -Recurse | + Where-Object { $Runtime -ne 'NativeAot' -or $_.FullName -match '\\publish\\' } | + Sort-Object LastWriteTime -Descending | + Select-Object -First 1 + + if ($null -eq $consumptionExe) { + throw "Could not find the built 'Consumption.exe'." + } + + Write-Host "Running '$($consumptionExe.FullName)'" -ForegroundColor DarkGray + & $consumptionExe.FullName + if ($LASTEXITCODE -ne 0) { + throw "Consumption smoke test crashed or failed with exit code $LASTEXITCODE." + } +} + +# Authoring: build and verify the generated Windows Runtime metadata (CoreCLR), or just verify the +# component publishes cleanly with Native AOT (we don't load the published output). +function Invoke-AuthoringSmokeTest { + Write-Host "`n=== Authoring smoke test ($Runtime) ===" -ForegroundColor Green + + if ($Runtime -eq 'NativeAot') { + Invoke-Dotnet (@('publish', $authoringProject, '--runtime', $nativeAotRid, '-p:PublishAot=true') + $commonBuildArgs) + return + } + + Invoke-Dotnet (@('build', $authoringProject) + $commonBuildArgs) + + # The authoring build emits a '.winmd' next to the component assembly. Verify it was produced + # and that it defines the expected Windows Runtime type. + $authoringWinMD = Get-ChildItem -Path ([IO.Path]::Combine($smokeTestsRoot, 'Authoring', 'bin')) -Filter 'Authoring.winmd' -Recurse -ErrorAction SilentlyContinue | + Sort-Object LastWriteTime -Descending | + Select-Object -First 1 + + if ($null -eq $authoringWinMD) { + throw "The authoring build did not produce 'Authoring.winmd'." + } + + Assert-WinMDDefinesType -Path $authoringWinMD.FullName -Namespace 'Authoring' -TypeName 'Greeter' +} + +# Projection: build a reference projection for a third-party component's '.winmd' (CoreCLR only). This +# is a build-time artifact, so there is nothing to publish with Native AOT. +function Invoke-ProjectionSmokeTest { + Write-Host "`n=== Projection smoke test ($Runtime) ===" -ForegroundColor Green + + Invoke-ReferenceProjectionSmokeTest -Name 'Projection' -Project $projectionProject +} + +# Windows SDK projection: build the base Windows SDK reference projection, exactly as the +# 'Microsoft.Windows.SDK.NET.Ref' projection package is produced (CoreCLR only; build-time artifact). +function Invoke-WindowsSdkProjectionSmokeTest { + Write-Host "`n=== Windows SDK projection smoke test ($Runtime) ===" -ForegroundColor Green + + Invoke-ReferenceProjectionSmokeTest -Name 'WindowsSdkProjection' -Project $windowsSdkProjectionProject +} + +# Windows SDK XAML projection: build the 'Windows.UI.Xaml' reference projection (which references the +# base Windows SDK reference projection above), exactly as the UWP XAML projection package is produced +# (CoreCLR only; build-time artifact). +function Invoke-WindowsSdkXamlProjectionSmokeTest { + Write-Host "`n=== Windows SDK XAML projection smoke test ($Runtime) ===" -ForegroundColor Green + + Invoke-ReferenceProjectionSmokeTest -Name 'WindowsSdkXamlProjection' -Project $windowsSdkXamlProjectionProject +} + +# Shared implementation for the reference-projection smoke tests. Building a reference projection produces +# a forwarder assembly (from 'cswinrtimplgen') next to a 'ref' reference assembly (compiled from the +# 'cswinrtprojectionrefgen' sources). Verifying both were produced confirms the package wired up and ran +# both generators correctly, and that the generated reference projection compiled against the packaged +# 'WinRT.Runtime' reference assembly. A reference projection is a build-time artifact, so there is nothing +# to publish with Native AOT and these tests run on CoreCLR only. +function Invoke-ReferenceProjectionSmokeTest { + param ( + [Parameter(Mandatory = $true)] [string] $Name, + [Parameter(Mandatory = $true)] [string] $Project + ) + + if ($Runtime -eq 'NativeAot') { + Write-Host "Skipping the $Name smoke test for Native AOT (a reference projection is a build-time artifact)." -ForegroundColor DarkGray + return + } + + Invoke-Dotnet (@('build', $Project) + $commonBuildArgs) + + $projectDirectory = [IO.Path]::GetDirectoryName($Project) + $assemblies = Get-ChildItem -Path ([IO.Path]::Combine($projectDirectory, 'bin')) -Filter "$Name.dll" -Recurse -ErrorAction SilentlyContinue + + $forwarder = $assemblies | Where-Object { $_.FullName -notmatch '\\ref\\' } | Select-Object -First 1 + $referenceAssembly = $assemblies | Where-Object { $_.FullName -match '\\ref\\' } | Select-Object -First 1 + + if ($null -eq $forwarder) { + throw "The $Name build did not produce the '$Name.dll' forwarder assembly." + } + + if ($null -eq $referenceAssembly) { + throw "The $Name build did not produce the 'ref\$Name.dll' reference assembly." + } + + Write-Host "Verified the $Name projection produced both a forwarder and a reference assembly." -ForegroundColor DarkGray +} + +if ($Test -in @('All', 'Consumption')) { + Invoke-ConsumptionSmokeTest +} + +if ($Test -in @('All', 'Authoring')) { + Invoke-AuthoringSmokeTest +} + +if ($Test -in @('All', 'Projection')) { + Invoke-ProjectionSmokeTest +} + +if ($Test -in @('All', 'WindowsSdkProjection')) { + Invoke-WindowsSdkProjectionSmokeTest +} + +if ($Test -in @('All', 'WindowsSdkXamlProjection')) { + Invoke-WindowsSdkXamlProjectionSmokeTest +} + +Write-Host "`nSmoke tests passed." -ForegroundColor Green diff --git a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.ICommand.cs b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.ICommand.cs index 90a94dbee9..0b1ea36bef 100644 --- a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.ICommand.cs +++ b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.ICommand.cs @@ -37,7 +37,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(interfaceType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(interfaceType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(interfaceType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { diff --git a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyCollectionChanged.cs b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyCollectionChanged.cs index b023b0b4da..d3274eae85 100644 --- a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyCollectionChanged.cs +++ b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyCollectionChanged.cs @@ -37,7 +37,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(interfaceType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(interfaceType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(interfaceType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { diff --git a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyPropertyChanged.cs b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyPropertyChanged.cs index aa5f3d6320..d875da4620 100644 --- a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyPropertyChanged.cs +++ b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.INotifyPropertyChanged.cs @@ -37,7 +37,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(interfaceType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(interfaceType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(interfaceType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { diff --git a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs index f8a752bfcc..e93ecaa7b8 100644 --- a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs +++ b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs @@ -38,6 +38,7 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.IEnumerable.ToReferenceTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -47,6 +48,7 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.IEnumerator.ToReferenceTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -56,6 +58,7 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.IList.ToReferenceTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -83,6 +86,7 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.NotifyCollectionChangedEventArgs.ToReferenceTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections); @@ -91,6 +95,7 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.PropertyChangedEventArgs.ToReferenceTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections); @@ -99,6 +104,7 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.NotifyCollectionChangedEventHandler.ToReferenceTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections); @@ -107,6 +113,7 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.PropertyChangedEventHandler.ToReferenceTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections); @@ -115,11 +122,13 @@ public static void AssemblyAttributes( windowsUIXamlMetadata: "Windows.Foundation.UniversalApiContract", microsoftUIXamlMetadata: "Microsoft.UI.Xaml.WinUIContract", trimTarget: interopReferences.NotifyCollectionChangedAction.ToValueTypeSignature(), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections); IBindableVectorViewType( + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections); @@ -131,6 +140,7 @@ public static void AssemblyAttributes( /// The metadata name for Windows.UI.Xaml. /// The metadata name for Microsoft.UI.Xaml. /// + /// The instance to use. /// The instance to use. /// The module that the attribute will be used from. /// Whether to use Windows.UI.Xaml projections. @@ -139,6 +149,7 @@ private static void InterfaceType( string windowsUIXamlMetadata, string microsoftUIXamlMetadata, TypeSignature trimTarget, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -157,7 +168,7 @@ private static void InterfaceType( // that is used, we can't define this proxy type in advance even if the interface type itself is not generic. InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(trimTarget, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(trimTarget, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(trimTarget, interopDefinitions), mappedMetadata: metadata, runtimeClassName: null, metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(trimTarget, useWindowsUIXamlProjections), @@ -209,7 +220,7 @@ private static void ICommandInterfaceType( // Define the proxy type for the 'ICommand' interface type (it needs a dynamic one, same as the other interface types above) InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(trimTarget, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(trimTarget, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(trimTarget, interopDefinitions), mappedMetadata: metadata, runtimeClassName: null, metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(trimTarget, useWindowsUIXamlProjections), @@ -266,7 +277,7 @@ private static void INotifyCollectionChangedInterfaceType( // Define the proxy type for the 'INotifyCollectionChanged' interface type InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(trimTarget, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(trimTarget, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(trimTarget, interopDefinitions), mappedMetadata: metadata, runtimeClassName: null, metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(trimTarget, useWindowsUIXamlProjections), @@ -323,7 +334,7 @@ private static void INotifyPropertyChangedInterfaceType( // Define the proxy type for the 'INotifyPropertyChanged' interface type InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(trimTarget, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(trimTarget, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(trimTarget, interopDefinitions), mappedMetadata: metadata, runtimeClassName: null, metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(trimTarget, useWindowsUIXamlProjections), @@ -364,6 +375,7 @@ private static void INotifyPropertyChangedInterfaceType( /// The metadata name for Windows.UI.Xaml. /// The metadata name for Microsoft.UI.Xaml. /// + /// The instance to use. /// The instance to use. /// The module that the attribute will be used from. /// Whether to use Windows.UI.Xaml projections. @@ -371,6 +383,7 @@ private static void ClassType( string windowsUIXamlMetadata, string microsoftUIXamlMetadata, TypeSignature trimTarget, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections) @@ -382,7 +395,7 @@ private static void ClassType( // able to do lookups correctly (this attribute will be used, since the input type is a normal class type). InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(trimTarget, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(trimTarget, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(trimTarget, interopDefinitions), mappedMetadata: metadata, runtimeClassName: RuntimeClassNameGenerator.GetRuntimeClassName(trimTarget, interopReferences.RuntimeContext, useWindowsUIXamlProjections), metadataTypeName: null, @@ -417,6 +430,7 @@ private static void ClassType( /// The metadata name for Windows.UI.Xaml. /// The metadata name for Microsoft.UI.Xaml. /// + /// The instance to use. /// The instance to use. /// The module that the attribute will be used from. /// Whether to use Windows.UI.Xaml projections. @@ -424,6 +438,7 @@ private static void DelegateType( string windowsUIXamlMetadata, string microsoftUIXamlMetadata, TypeSignature trimTarget, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections) @@ -434,7 +449,7 @@ private static void DelegateType( // metadata type name is not fixed. This type can be instantiated and boxed, so we need both possible names. InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(trimTarget, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(trimTarget, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(trimTarget, interopDefinitions), mappedMetadata: metadata, runtimeClassName: RuntimeClassNameGenerator.GetRuntimeClassName(trimTarget, interopReferences.RuntimeContext, useWindowsUIXamlProjections), metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(trimTarget, useWindowsUIXamlProjections), @@ -467,6 +482,7 @@ private static void DelegateType( /// The metadata name for Windows.UI.Xaml. /// The metadata name for Microsoft.UI.Xaml. /// + /// The instance to use. /// The instance to use. /// The module that the attribute will be used from. /// Whether to use Windows.UI.Xaml projections. @@ -474,6 +490,7 @@ private static void ValueType( string windowsUIXamlMetadata, string microsoftUIXamlMetadata, TypeSignature trimTarget, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections) @@ -484,7 +501,7 @@ private static void ValueType( // metadata type name, as above, but we also need to reference the boxed type instantiation for this type. InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(trimTarget, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(trimTarget, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(trimTarget, interopDefinitions), mappedMetadata: metadata, runtimeClassName: RuntimeClassNameGenerator.GetRuntimeClassName(trimTarget, interopReferences.RuntimeContext, useWindowsUIXamlProjections), metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(trimTarget, useWindowsUIXamlProjections), @@ -514,10 +531,12 @@ private static void ValueType( /// /// Creates a new custom attribute value for for IBindableVectorView. /// + /// The instance to use. /// The instance to use. /// The module that the attribute will be used from. /// Whether to use Windows.UI.Xaml projections. private static void IBindableVectorViewType( + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections) @@ -533,7 +552,7 @@ private static void IBindableVectorViewType( // a proxy type for it, with the correct runtime class name, and an entry just in the marshalling proxy type map. InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(adapterType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(adapterType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(adapterType, interopDefinitions), mappedMetadata: null, runtimeClassName: runtimeClassName, metadataTypeName: null, @@ -646,4 +665,4 @@ private static TypeDefinition GetMethodsType(TypeSignature type, InteropReferenc return methodsType; } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs index ffc5895aaa..aec8b8286b 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs @@ -42,7 +42,7 @@ public static void IIDs( { // 'IDelegate' IID IID( - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions), interopDefinitions: interopDefinitions, interopReferences: interopReferences, iid: GuidGenerator.CreateIID(delegateType, interopDefinitions, interopReferences, useWindowsUIXamlProjections), @@ -55,7 +55,7 @@ public static void IIDs( // scenario. This is different than boxed value type, which instead are // just always projected as and using 'Nullable' to represent this. IID( - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "Reference"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "Reference"), interopDefinitions: interopDefinitions, interopReferences: interopReferences, iid: GuidGenerator.CreateIID(delegateType.MakeBoxedType(), interopDefinitions, interopReferences, useWindowsUIXamlProjections), @@ -104,7 +104,7 @@ public static void Vftbl( { vftblType = WellKnownTypeDefinitionFactory.DelegateVftbl( ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "Vftbl"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "Vftbl"), senderType: senderType.GetAbiType(interopReferences), argsType: argsType.GetAbiType(interopReferences), interopReferences: interopReferences); @@ -120,6 +120,7 @@ static void GetOrCreateVftbl( TypeSignature argsType, TypeSignature displaySenderType, TypeSignature displayArgsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -139,7 +140,7 @@ static void GetOrCreateVftbl( // Construct a new specialized vtable type TypeDefinition newVftblType = WellKnownTypeDefinitionFactory.DelegateVftbl( ns: InteropUtf8NameFactory.TypeNamespace(sharedEventHandlerType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(sharedEventHandlerType, interopReferences.RuntimeContext, "Vftbl"), + name: InteropUtf8NameFactory.TypeName(sharedEventHandlerType, interopDefinitions, "Vftbl"), senderType: senderType, argsType: argsType, interopReferences: interopReferences); @@ -162,6 +163,7 @@ static void GetOrCreateVftbl( argsType: argsType.GetAbiType(interopReferences), displaySenderType: interopReferences.Object, displayArgsType: argsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -174,6 +176,7 @@ static void GetOrCreateVftbl( argsType: interopReferences.Void.MakePointerType(), displaySenderType: senderType, displayArgsType: interopReferences.Object, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -288,7 +291,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIUnknown, ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "Impl"), vftblType: vftblType, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -396,7 +399,7 @@ public static void ReferenceImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "ReferenceImpl"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "ReferenceImpl"), vftblType: interopDefinitions.DelegateReferenceVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -430,7 +433,7 @@ public static void InterfaceEntriesImpl( { InteropTypeDefinitionBuilder.InterfaceEntriesImpl( ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "InterfaceEntriesImpl"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "InterfaceEntriesImpl"), entriesFieldType: interopDefinitions.DelegateInterfaceEntries, interopReferences: interopReferences, module: module, @@ -453,6 +456,7 @@ public static void InterfaceEntriesImpl( /// The for the type. /// The type returned by . /// The 'IID' get method for the 'IDelegate' interface. + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting callback type. @@ -460,6 +464,7 @@ public static void ComWrappersCallbackType( TypeSignature delegateType, TypeDefinition nativeDelegateType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition callbackType) @@ -467,7 +472,7 @@ public static void ComWrappersCallbackType( // We're declaring an 'internal abstract class' type callbackType = new( ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "ComWrappersCallback"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "ComWrappersCallback"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -538,7 +543,7 @@ public static void NativeDelegateType( // We're declaring an 'internal static class' type nativeDelegateType = new( ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "NativeDelegate"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "NativeDelegate"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -685,7 +690,7 @@ public static void ComWrappersMarshallerAttribute( // We're declaring an 'internal sealed class' type marshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "ComWrappersMarshallerAttribute"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); @@ -785,6 +790,7 @@ public static void ComWrappersMarshallerAttribute( /// The instance returned by . /// The 'IID' get method for the 'IDelegate' interface. /// The resulting 'IID' get method for the boxed 'IDelegate' interface. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. @@ -794,6 +800,7 @@ public static void Marshaller( TypeDefinition delegateComWrappersCallbackType, MethodDefinition get_IidMethod, MethodDefinition get_ReferenceIidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -802,7 +809,7 @@ public static void Marshaller( // We're declaring an 'internal static class' type marshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext, "Marshaller"), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions, "Marshaller"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -913,6 +920,7 @@ public static void Marshaller( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// Whether to use Windows.UI.Xaml projections. @@ -920,6 +928,7 @@ public static void Marshaller( public static void Proxy( TypeSignature delegateType, TypeDefinition comWrappersMarshallerAttributeType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -930,7 +939,7 @@ public static void Proxy( // '[WindowsRuntimeMetadataTypeName]', as that's different than the runtime class name (which uses 'IReference'). InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(delegateType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(delegateType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(delegateType, interopDefinitions), mappedMetadata: "Windows.Foundation.FoundationContract", runtimeClassName: RuntimeClassNameGenerator.GetRuntimeClassName(delegateType, interopReferences.RuntimeContext, useWindowsUIXamlProjections), metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(delegateType, useWindowsUIXamlProjections), @@ -946,7 +955,7 @@ public static void Proxy( /// Creates the type map attributes for some type. /// /// The for the type. - /// The instance returned by . + /// The instance returned by . /// The instance to use. /// The module that will contain the type being created. /// Whether to use Windows.UI.Xaml projections. @@ -975,4 +984,4 @@ public static void TypeMapAttributes( module: module); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs index 4caf22e65b..dbcec17d58 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs @@ -24,12 +24,14 @@ public static class EventSource /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting event source type. public static void EventHandler1( GenericInstanceTypeSignature delegateType, TypeDefinition marshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition eventSourceType) @@ -41,6 +43,7 @@ public static void EventHandler1( baseEventSourceType: interopReferences.EventHandler1EventSource, baseEventSource_ctor: interopReferences.EventHandler1EventSource_ctor(eventArgsType), marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, eventSourceType: out eventSourceType); @@ -51,12 +54,14 @@ public static void EventHandler1( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting event source type. public static void EventHandler2( GenericInstanceTypeSignature delegateType, TypeDefinition marshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition eventSourceType) @@ -69,6 +74,7 @@ public static void EventHandler2( baseEventSourceType: interopReferences.EventHandler2EventSource, baseEventSource_ctor: interopReferences.EventHandler2EventSource_ctor(senderType, eventArgsType), marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, eventSourceType: out eventSourceType); @@ -79,6 +85,7 @@ public static void EventHandler2( /// /// The for the delegate type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. @@ -86,6 +93,7 @@ public static void EventHandler2( public static void VectorChangedEventHandler1( GenericInstanceTypeSignature delegateType, TypeDefinition marshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -98,6 +106,7 @@ public static void VectorChangedEventHandler1( baseEventSourceType: interopReferences.VectorChangedEventHandler1EventSource, baseEventSource_ctor: interopReferences.VectorChangedEventHandler1EventSource_ctor(elementType), marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, eventSourceType: out eventSourceType); @@ -111,6 +120,7 @@ public static void VectorChangedEventHandler1( /// /// The for the delegate type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. @@ -118,6 +128,7 @@ public static void VectorChangedEventHandler1( public static void MapChangedEventHandler2( GenericInstanceTypeSignature delegateType, TypeDefinition marshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -131,6 +142,7 @@ public static void MapChangedEventHandler2( baseEventSourceType: interopReferences.MapChangedEventHandler2EventSource, baseEventSource_ctor: interopReferences.MapChangedEventHandler2EventSource_ctor(keyType, valueType), marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, eventSourceType: out eventSourceType); @@ -146,6 +158,7 @@ public static void MapChangedEventHandler2( /// The for the base event source type. /// The for the constructor of the base event source type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting event source type. @@ -154,6 +167,7 @@ private static void DerivedEventSource( TypeReference baseEventSourceType, MemberReference baseEventSource_ctor, TypeDefinition marshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition eventSourceType) @@ -163,7 +177,7 @@ private static void DerivedEventSource( // We're declaring an 'internal sealed class' type eventSourceType = new( ns: "ABI.WindowsRuntime.InteropServices"u8, - name: InteropUtf8NameFactory.TypeName(baseEventSourceSignature, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(baseEventSourceSignature, interopDefinitions), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: baseEventSourceSignature.ToTypeDefOrRef()); @@ -207,4 +221,4 @@ private static void DerivedEventSource( eventSourceType.Methods.Add(convertToUnmanagedMethod); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs index 95b61f0379..4839e06e79 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs @@ -43,7 +43,7 @@ public static void Methods( // We're declaring an 'internal abstract class' type actionMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(actionType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(actionType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(actionType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -148,12 +148,14 @@ public static void Methods( /// /// The for the async action type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting native object type. public static void NativeObject( GenericInstanceTypeSignature actionType, TypeDefinition actionMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition nativeObjectType) @@ -166,6 +168,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: actionType, nativeObjectBaseType: windowsRuntimeAsyncActionWithProgress1Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -177,6 +180,7 @@ public static void NativeObject( /// The for the async action type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -185,6 +189,7 @@ public static void ComWrappersCallbackType( TypeSignature actionType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -195,6 +200,7 @@ public static void ComWrappersCallbackType( typeSignature: actionType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -206,6 +212,7 @@ public static void ComWrappersCallbackType( /// The for the async action type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -213,6 +220,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature actionType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -221,6 +229,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: actionType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -250,7 +259,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(actionType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(actionType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(actionType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -473,7 +482,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(actionType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(actionType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(actionType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IAsyncActionWithProgressVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -490,4 +499,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, actionType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs index 53b10c7b92..6712afce90 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs @@ -42,7 +42,7 @@ public static void Methods( // We're declaring an 'internal abstract class' type operationMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(operationType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(operationType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(operationType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -102,12 +102,14 @@ public static void Methods( /// /// The for the async operation type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting native object type. public static void NativeObject( GenericInstanceTypeSignature operationType, TypeDefinition operationMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition nativeObjectType) @@ -120,6 +122,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: operationType, nativeObjectBaseType: windowsRuntimeAsyncOperation1Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -131,6 +134,7 @@ public static void NativeObject( /// The for the async operation type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -139,6 +143,7 @@ public static void ComWrappersCallbackType( TypeSignature operationType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -149,6 +154,7 @@ public static void ComWrappersCallbackType( typeSignature: operationType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -160,6 +166,7 @@ public static void ComWrappersCallbackType( /// The for the async operation type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -167,6 +174,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature operationType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -175,6 +183,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: operationType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -204,7 +213,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(operationType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(operationType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(operationType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -349,7 +358,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(operationType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(operationType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(operationType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IAsyncOperationVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -364,4 +373,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, operationType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs index 74cb522378..d9096570a3 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs @@ -43,7 +43,7 @@ public static void Methods( // We're declaring an 'internal abstract class' type operationMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(operationType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(operationType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(operationType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -141,12 +141,14 @@ public static void Methods( /// /// The for the async operation type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting native object type. public static void NativeObject( GenericInstanceTypeSignature operationType, TypeDefinition operationMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition nativeObjectType) @@ -160,6 +162,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: operationType, nativeObjectBaseType: windowsRuntimeAsyncOperationWithProgress2Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -171,6 +174,7 @@ public static void NativeObject( /// The for the async operation type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -179,6 +183,7 @@ public static void ComWrappersCallbackType( TypeSignature operationType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -189,6 +194,7 @@ public static void ComWrappersCallbackType( typeSignature: operationType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -200,6 +206,7 @@ public static void ComWrappersCallbackType( /// The for the async operation type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -207,6 +214,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature operationType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -215,6 +223,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: operationType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -245,7 +254,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(operationType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(operationType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(operationType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -475,7 +484,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(operationType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(operationType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(operationType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IAsyncOperationWithProgressVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -492,4 +501,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, operationType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.ICollectionKeyValuePair2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.ICollectionKeyValuePair2.cs index 2e6c816b47..3899658126 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.ICollectionKeyValuePair2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.ICollectionKeyValuePair2.cs @@ -23,11 +23,13 @@ public static class ICollectionKeyValuePair2 /// Creates a new type definition for the forwarder attribute for a of type. /// /// The for the generic interface type. + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. public static void ForwarderAttribute( GenericInstanceTypeSignature collectionType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition forwarderAttributeType) @@ -40,6 +42,7 @@ public static void ForwarderAttribute( readOnlyCollectionType: collectionType, readOnlyDictionaryType: interopReferences.IDictionary2.MakeGenericReferenceType([keyType, valueType]), readOnlyListType: interopReferences.IList1.MakeGenericReferenceType([keyValuePairType]), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, forwarderAttributeType: out forwarderAttributeType); @@ -50,6 +53,7 @@ public static void ForwarderAttribute( /// /// The for the generic interface type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. @@ -57,6 +61,7 @@ public static void ForwarderAttribute( public static void InterfaceImpl( GenericInstanceTypeSignature collectionType, TypeDefinition forwarderAttributeType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -72,7 +77,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(collectionType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(collectionType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(collectionType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -278,4 +283,4 @@ public static void TypeMapAttributes( module: module); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs index 220ec2d23a..3576808ec6 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs @@ -26,6 +26,7 @@ public static class IDictionary2 /// /// The for the type. /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -33,6 +34,7 @@ public static class IDictionary2 public static void Interface( GenericInstanceTypeSignature dictionaryType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -41,7 +43,7 @@ public static void Interface( // We're declaring an 'internal abstract class' type interfaceType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(dictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(dictionaryType, interopReferences.RuntimeContext, "Interface"), + name: InteropUtf8NameFactory.TypeName(dictionaryType, interopDefinitions, "Interface"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -105,7 +107,7 @@ public static void Vftbl( { vftblType = WellKnownTypeDefinitionFactory.IDictionary2Vftbl( ns: InteropUtf8NameFactory.TypeNamespace(dictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(dictionaryType, interopReferences.RuntimeContext, "Vftbl"), + name: InteropUtf8NameFactory.TypeName(dictionaryType, interopDefinitions, "Vftbl"), keyType: keyType, valueType: valueType, interopReferences: interopReferences); @@ -121,6 +123,7 @@ static void GetOrCreateVftbl( TypeSignature valueType, TypeSignature displayKeyType, TypeSignature displayValueType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -140,7 +143,7 @@ static void GetOrCreateVftbl( // Construct a new specialized vtable type TypeDefinition newVftblType = WellKnownTypeDefinitionFactory.IDictionary2Vftbl( ns: InteropUtf8NameFactory.TypeNamespace(sharedDictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(sharedDictionaryType, interopReferences.RuntimeContext, "Vftbl"), + name: InteropUtf8NameFactory.TypeName(sharedDictionaryType, interopDefinitions, "Vftbl"), keyType: keyType, valueType: valueType, interopReferences: interopReferences); @@ -163,6 +166,7 @@ static void GetOrCreateVftbl( valueType: valueType, displayKeyType: interopReferences.Object, displayValueType: valueType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -175,6 +179,7 @@ static void GetOrCreateVftbl( valueType: interopReferences.Void.MakePointerType(), displayKeyType: keyType, displayValueType: interopReferences.Object, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -187,6 +192,7 @@ static void GetOrCreateVftbl( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -194,6 +200,7 @@ static void GetOrCreateVftbl( public static void IMapMethods( GenericInstanceTypeSignature dictionaryType, TypeDefinition vftblType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -205,7 +212,7 @@ public static void IMapMethods( // We're declaring an 'internal abstract class' type mapMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(dictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(dictionaryType, interopReferences.RuntimeContext, "IMapMethods"), + name: InteropUtf8NameFactory.TypeName(dictionaryType, interopDefinitions, "IMapMethods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -271,6 +278,7 @@ public static void IMapMethods( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -278,6 +286,7 @@ public static void IMapMethods( public static void Methods( GenericInstanceTypeSignature dictionaryType, TypeDefinition mapMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -289,7 +298,7 @@ public static void Methods( // We're declaring an 'internal static class' type dictionaryMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(dictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(dictionaryType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(dictionaryType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -639,6 +648,7 @@ public static void Methods( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -646,6 +656,7 @@ public static void Methods( public static void NativeObject( GenericInstanceTypeSignature dictionaryType, TypeDefinition mapMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -667,6 +678,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: dictionaryType, nativeObjectBaseType: windowsRuntimeDictionary5Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -678,6 +690,7 @@ public static void NativeObject( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -686,6 +699,7 @@ public static void ComWrappersCallbackType( TypeSignature dictionaryType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -696,6 +710,7 @@ public static void ComWrappersCallbackType( typeSignature: dictionaryType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -707,6 +722,7 @@ public static void ComWrappersCallbackType( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -714,6 +730,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature dictionaryType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -722,6 +739,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: dictionaryType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -755,7 +773,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(dictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(dictionaryType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(dictionaryType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -1039,7 +1057,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(dictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(dictionaryType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(dictionaryType, interopDefinitions, "Impl"), vftblType: vftblType, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -1058,4 +1076,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, dictionaryType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs index c2b66936d7..c20a92fb8c 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs @@ -28,6 +28,7 @@ public static class IEnumerable1 /// /// The for the type. /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -35,6 +36,7 @@ public static class IEnumerable1 public static void Interface( GenericInstanceTypeSignature enumerableType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -43,7 +45,7 @@ public static void Interface( // We're declaring an 'internal abstract class' type interfaceType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(enumerableType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumerableType, interopReferences.RuntimeContext, "Interface"), + name: InteropUtf8NameFactory.TypeName(enumerableType, interopDefinitions, "Interface"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -92,7 +94,7 @@ public static void IIterableMethods( // We're declaring an 'internal static class' type iterableMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(enumerableType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumerableType, interopReferences.RuntimeContext, "IIterableMethods"), + name: InteropUtf8NameFactory.TypeName(enumerableType, interopDefinitions, "IIterableMethods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -211,12 +213,14 @@ public static void IIterableMethods( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting methods type. public static void Methods( GenericInstanceTypeSignature enumerableType, TypeDefinition iterableMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition enumerableMethodsType) @@ -226,7 +230,7 @@ public static void Methods( // We're declaring an 'internal static class' type enumerableMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(enumerableType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumerableType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(enumerableType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -258,12 +262,14 @@ public static void Methods( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting native object type. public static void NativeObject( GenericInstanceTypeSignature enumerableType, TypeDefinition iterableMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition nativeObjectType) @@ -276,6 +282,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: enumerableType, nativeObjectBaseType: windowsRuntimeEnumerable1Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -287,6 +294,7 @@ public static void NativeObject( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -295,6 +303,7 @@ public static void ComWrappersCallbackType( TypeSignature enumerableType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -305,6 +314,7 @@ public static void ComWrappersCallbackType( typeSignature: enumerableType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -316,6 +326,7 @@ public static void ComWrappersCallbackType( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -323,6 +334,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature enumerableType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -331,6 +343,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: enumerableType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -360,7 +373,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(enumerableType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumerableType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(enumerableType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -445,7 +458,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(enumerableType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumerableType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(enumerableType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IEnumerable1Vftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -457,4 +470,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, enumerableType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs index f3447076cf..e908cc2876 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs @@ -41,7 +41,7 @@ public static void IID( out MethodDefinition get_IidMethod) { InteropTypeDefinitionBuilder.IID( - name: InteropUtf8NameFactory.TypeName(enumeratorType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(enumeratorType, interopDefinitions), interopDefinitions: interopDefinitions, interopReferences: interopReferences, iid: GuidGenerator.CreateIID(enumeratorType, interopDefinitions, interopReferences, useWindowsUIXamlProjections), @@ -73,7 +73,7 @@ public static void IIteratorMethods( // We're declaring an 'internal abstract class' type iteratorMethodsType = new( ns: InteropUtf8NameFactory.TypeNamespace(enumeratorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumeratorType, interopReferences.RuntimeContext, "IIteratorMethods"), + name: InteropUtf8NameFactory.TypeName(enumeratorType, interopDefinitions, "IIteratorMethods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -210,12 +210,14 @@ public static void IIteratorMethods( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting methods type. public static void Methods( GenericInstanceTypeSignature enumeratorType, TypeDefinition iteratorMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition enumeratorMethodsType) @@ -225,7 +227,7 @@ public static void Methods( // We're declaring an 'internal static class' type enumeratorMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(enumeratorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumeratorType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(enumeratorType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -277,12 +279,14 @@ public static void Methods( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting native object type. public static void NativeObject( GenericInstanceTypeSignature enumeratorType, TypeDefinition iteratorMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition nativeObjectType) @@ -295,6 +299,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: enumeratorType, nativeObjectBaseType: windowsRuntimeEnumerator2Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -306,6 +311,7 @@ public static void NativeObject( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -314,6 +320,7 @@ public static void ComWrappersCallbackType( TypeSignature enumeratorType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -324,6 +331,7 @@ public static void ComWrappersCallbackType( typeSignature: enumeratorType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -335,6 +343,7 @@ public static void ComWrappersCallbackType( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -342,6 +351,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature enumeratorType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -350,6 +360,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: enumeratorType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -379,7 +390,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(enumeratorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumeratorType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(enumeratorType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -529,12 +540,14 @@ public static void InterfaceImpl( /// Creates a new type definition for the element marshaller for some IIterator<T> interface. /// /// The for the type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. /// The resulting element marshaller type. public static void ElementMarshaller( GenericInstanceTypeSignature enumeratorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -559,6 +572,7 @@ public static void ElementMarshaller( { elementMarshallerType = InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.KeyValuePair( enumeratorType: enumeratorType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -568,6 +582,7 @@ public static void ElementMarshaller( { elementMarshallerType = InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.NullableValueType( enumeratorType: enumeratorType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -577,6 +592,7 @@ public static void ElementMarshaller( { elementMarshallerType = InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.ManagedValueType( enumeratorType: enumeratorType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -586,6 +602,7 @@ public static void ElementMarshaller( { elementMarshallerType = InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.UnmanagedValueType( enumeratorType: enumeratorType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -595,6 +612,7 @@ public static void ElementMarshaller( { elementMarshallerType = InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.ReferenceType( enumeratorType: enumeratorType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -647,7 +665,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(enumeratorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(enumeratorType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(enumeratorType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IEnumerator1Vftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -663,4 +681,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, enumeratorType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs index 460d4c078a..515977fb58 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs @@ -27,6 +27,7 @@ public static class IList1 /// /// The for the type. /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -34,6 +35,7 @@ public static class IList1 public static void Interface( GenericInstanceTypeSignature listType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -42,7 +44,7 @@ public static void Interface( // We're declaring an 'internal abstract class' type interfaceType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(listType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(listType, interopReferences.RuntimeContext, "Interface"), + name: InteropUtf8NameFactory.TypeName(listType, interopDefinitions, "Interface"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -97,7 +99,7 @@ public static void Vftbl( // Otherwise, we must construct a new specialized vtable type vftblType = WellKnownTypeDefinitionFactory.IList1Vftbl( ns: InteropUtf8NameFactory.TypeNamespace(listType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(listType, interopReferences.RuntimeContext, "Vftbl"), + name: InteropUtf8NameFactory.TypeName(listType, interopDefinitions, "Vftbl"), elementType: elementType.GetAbiType(interopReferences), interopReferences: interopReferences); @@ -109,6 +111,7 @@ public static void Vftbl( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -116,6 +119,7 @@ public static void Vftbl( public static void IVectorMethods( GenericInstanceTypeSignature listType, TypeDefinition vftblType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -126,7 +130,7 @@ public static void IVectorMethods( // We're declaring an 'internal abstract class' type vectorMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(listType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(listType, interopReferences.RuntimeContext, "IVectorMethods"), + name: InteropUtf8NameFactory.TypeName(listType, interopDefinitions, "IVectorMethods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -204,6 +208,7 @@ public static void IVectorMethods( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -211,6 +216,7 @@ public static void IVectorMethods( public static void Methods( GenericInstanceTypeSignature listType, TypeDefinition vectorMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -221,7 +227,7 @@ public static void Methods( // We're declaring an 'internal static class' type listMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(listType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(listType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(listType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -522,6 +528,7 @@ public static void Methods( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -529,6 +536,7 @@ public static void Methods( public static void NativeObject( GenericInstanceTypeSignature listType, TypeDefinition vectorMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -547,6 +555,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: listType, nativeObjectBaseType: windowsRuntimeList4Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -558,6 +567,7 @@ public static void NativeObject( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -566,6 +576,7 @@ public static void ComWrappersCallbackType( TypeSignature listType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -576,6 +587,7 @@ public static void ComWrappersCallbackType( typeSignature: listType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -587,6 +599,7 @@ public static void ComWrappersCallbackType( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -594,6 +607,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature listType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -602,6 +616,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: listType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -633,7 +648,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(listType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(listType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(listType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -1018,7 +1033,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(listType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(listType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(listType, interopDefinitions, "Impl"), vftblType: vftblType, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -1046,7 +1061,7 @@ public static void ImplType( /// Creates the type map attributes for some IVector<T> interface. /// /// The for the type. - /// The instance returned by . + /// The instance returned by . /// The instance returned by . /// The instance to use. /// The module that will contain the type being created. @@ -1095,4 +1110,4 @@ public static void TypeMapAttributes( } } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs index d0c4dc0e0f..9c47f7da1f 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs @@ -43,7 +43,7 @@ public static void Methods( // We're declaring an 'internal abstract class' type argsMethodsType = new( ns: InteropUtf8NameFactory.TypeNamespace(argsType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(argsType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(argsType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -90,12 +90,14 @@ public static void Methods( /// /// The for the args type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting native object type. public static void NativeObject( GenericInstanceTypeSignature argsType, TypeDefinition argsMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition nativeObjectType) @@ -108,6 +110,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: argsType, nativeObjectBaseType: windowsRuntimeMapChangedEventArgs2Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -119,6 +122,7 @@ public static void NativeObject( /// The for the args type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -127,6 +131,7 @@ public static void ComWrappersCallbackType( TypeSignature argsType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -137,6 +142,7 @@ public static void ComWrappersCallbackType( typeSignature: argsType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -148,6 +154,7 @@ public static void ComWrappersCallbackType( /// The for the args type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -155,6 +162,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature argsType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -163,6 +171,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: argsType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -192,7 +201,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(argsType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(argsType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(argsType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -296,7 +305,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(argsType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(argsType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(argsType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IMapChangedEventArgsVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -308,4 +317,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, argsType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs index ea4708ee8d..4e043664c3 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs @@ -25,12 +25,14 @@ public static class IObservableMap2 /// Creates a new type definition for the event source factory for an IObservableMap<K, V> interface. /// /// The for the map type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. /// The resulting factory type. public static void EventSourceFactory( GenericInstanceTypeSignature mapType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -42,7 +44,7 @@ public static void EventSourceFactory( // We're declaring an 'internal abstract class' type factoryType = new( ns: InteropUtf8NameFactory.TypeNamespace(mapType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(mapType, interopReferences.RuntimeContext, "EventSourceFactory"), + name: InteropUtf8NameFactory.TypeName(mapType, interopDefinitions, "EventSourceFactory"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -88,12 +90,14 @@ public static void EventSourceFactory( /// Creates the cached callback type for the property for the event args for the map. /// /// The for the map type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. /// The resulting callback type. public static void EventSourceCallback( GenericInstanceTypeSignature mapType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -105,7 +109,7 @@ public static void EventSourceCallback( // We're declaring an 'internal sealed class' type callbackType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(mapType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(mapType, interopReferences.RuntimeContext, "EventSourceCallback"), + name: InteropUtf8NameFactory.TypeName(mapType, interopDefinitions, "EventSourceCallback"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -182,12 +186,14 @@ public static void EventSourceCallback( /// /// The for the map type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting methods type. public static void Methods( GenericInstanceTypeSignature mapType, TypeDefinition eventSourceCallbackType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition methodsType) @@ -198,7 +204,7 @@ public static void Methods( // We're declaring an 'internal static class' type methodsType = new( ns: InteropUtf8NameFactory.TypeNamespace(mapType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(mapType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(mapType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -262,6 +268,7 @@ public static void Methods( /// /// The for the map type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -269,6 +276,7 @@ public static void Methods( public static void NativeObject( GenericInstanceTypeSignature mapType, TypeDefinition factoryType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -295,6 +303,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: mapType, nativeObjectBaseType: windowsRuntimeObservableMap2Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -306,6 +315,7 @@ public static void NativeObject( /// The for the map type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -314,6 +324,7 @@ public static void ComWrappersCallbackType( TypeSignature mapType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -324,6 +335,7 @@ public static void ComWrappersCallbackType( typeSignature: mapType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -335,6 +347,7 @@ public static void ComWrappersCallbackType( /// The for the map type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -342,6 +355,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature mapType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -350,6 +364,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: mapType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -386,7 +401,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(mapType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(mapType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(mapType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -518,7 +533,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(mapType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(mapType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(mapType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IObservableMapVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -533,4 +548,4 @@ public static void ImplType( implType.Properties.Add(mapChangedTableProperty); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs index 90707e9a96..09e980d25f 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs @@ -25,12 +25,14 @@ public static class IObservableVector1 /// Creates a new type definition for the event source factory for an IObservableVector<T> interface. /// /// The for the vector type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. /// The resulting factory type. public static void EventSourceFactory( GenericInstanceTypeSignature vectorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -41,7 +43,7 @@ public static void EventSourceFactory( // We're declaring an 'internal abstract class' type factoryType = new( ns: InteropUtf8NameFactory.TypeNamespace(vectorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(vectorType, interopReferences.RuntimeContext, "EventSourceFactory"), + name: InteropUtf8NameFactory.TypeName(vectorType, interopDefinitions, "EventSourceFactory"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -87,12 +89,14 @@ public static void EventSourceFactory( /// Creates the cached callback type for an IObservableVector<T> interface. /// /// The for the vector type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. /// The resulting callback type. public static void EventSourceCallback( GenericInstanceTypeSignature vectorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -103,7 +107,7 @@ public static void EventSourceCallback( // We're declaring an 'internal sealed class' type callbackType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(vectorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(vectorType, interopReferences.RuntimeContext, "EventSourceCallback"), + name: InteropUtf8NameFactory.TypeName(vectorType, interopDefinitions, "EventSourceCallback"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -179,12 +183,14 @@ public static void EventSourceCallback( /// /// The for the vector type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting methods type. public static void Methods( GenericInstanceTypeSignature vectorType, TypeDefinition eventSourceCallbackType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition methodsType) @@ -194,7 +200,7 @@ public static void Methods( // We're declaring an 'internal static class' type methodsType = new( ns: InteropUtf8NameFactory.TypeNamespace(vectorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(vectorType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(vectorType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -258,6 +264,7 @@ public static void Methods( /// /// The for the vector type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -265,6 +272,7 @@ public static void Methods( public static void NativeObject( GenericInstanceTypeSignature vectorType, TypeDefinition factoryType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -288,6 +296,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: vectorType, nativeObjectBaseType: windowsRuntimeObservableVector1Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -299,6 +308,7 @@ public static void NativeObject( /// The for the vector type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -307,6 +317,7 @@ public static void ComWrappersCallbackType( TypeSignature vectorType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -317,6 +328,7 @@ public static void ComWrappersCallbackType( typeSignature: vectorType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -328,6 +340,7 @@ public static void ComWrappersCallbackType( /// The for the vector type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -335,6 +348,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature vectorType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -343,6 +357,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: vectorType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -372,7 +387,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(vectorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(vectorType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(vectorType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -503,7 +518,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(vectorType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(vectorType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(vectorType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IObservableVectorVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -521,4 +536,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, vectorType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyCollectionKeyValuePair2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyCollectionKeyValuePair2.cs index fb351c5ee7..ed8db77ec2 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyCollectionKeyValuePair2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyCollectionKeyValuePair2.cs @@ -22,11 +22,13 @@ public static class IReadOnlyCollectionKeyValuePair2 /// Creates a new type definition for the forwarder attribute for a of type. /// /// The for the generic interface type. + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. public static void ForwarderAttribute( GenericInstanceTypeSignature readOnlyCollectionType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition forwarderAttributeType) @@ -39,6 +41,7 @@ public static void ForwarderAttribute( readOnlyCollectionType: readOnlyCollectionType, readOnlyDictionaryType: interopReferences.IReadOnlyDictionary2.MakeGenericReferenceType([keyType, valueType]), readOnlyListType: interopReferences.IReadOnlyList1.MakeGenericReferenceType([keyValuePairType]), + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, forwarderAttributeType: out forwarderAttributeType); @@ -49,6 +52,7 @@ public static void ForwarderAttribute( /// /// The for the generic interface type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. @@ -56,6 +60,7 @@ public static void ForwarderAttribute( public static void InterfaceImpl( GenericInstanceTypeSignature readOnlyCollectionType, TypeDefinition forwarderAttributeType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -71,7 +76,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyCollectionType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyCollectionType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(readOnlyCollectionType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -148,4 +153,4 @@ public static void TypeMapAttributes( module: module); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs index 031deed436..26c762b133 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs @@ -67,7 +67,7 @@ public static void Vftbl( // Otherwise, we must construct a new specialized vtable type TypeDefinition newVftblType = WellKnownTypeDefinitionFactory.IReadOnlyDictionary2Vftbl( ns: InteropUtf8NameFactory.TypeNamespace(sharedReadOnlyDictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(sharedReadOnlyDictionaryType, interopReferences.RuntimeContext, "Vftbl"), + name: InteropUtf8NameFactory.TypeName(sharedReadOnlyDictionaryType, interopDefinitions, "Vftbl"), keyType: keyType, valueType: interopReferences.Void, interopReferences: interopReferences); @@ -87,6 +87,7 @@ public static void Vftbl( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -94,6 +95,7 @@ public static void Vftbl( public static void IMapViewMethods( GenericInstanceTypeSignature readOnlyDictionaryType, TypeDefinition vftblType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -105,7 +107,7 @@ public static void IMapViewMethods( // We're declaring an 'internal abstract class' type mapViewMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyDictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopReferences.RuntimeContext, "IMapViewMethods"), + name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopDefinitions, "IMapViewMethods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -144,6 +146,7 @@ public static void IMapViewMethods( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -151,6 +154,7 @@ public static void IMapViewMethods( public static void Methods( GenericInstanceTypeSignature readOnlyDictionaryType, TypeDefinition mapViewMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -162,7 +166,7 @@ public static void Methods( // We're declaring an 'internal static class' type readOnlyDictionaryMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyDictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -323,6 +327,7 @@ public static void Methods( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -330,6 +335,7 @@ public static void Methods( public static void NativeObject( GenericInstanceTypeSignature readOnlyDictionaryType, TypeDefinition mapViewMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -351,6 +357,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: readOnlyDictionaryType, nativeObjectBaseType: windowsRuntimeReadOnlyDictionary5Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -362,6 +369,7 @@ public static void NativeObject( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -370,6 +378,7 @@ public static void ComWrappersCallbackType( TypeSignature readOnlyDictionaryType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -380,6 +389,7 @@ public static void ComWrappersCallbackType( typeSignature: readOnlyDictionaryType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -391,6 +401,7 @@ public static void ComWrappersCallbackType( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -398,6 +409,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature readOnlyDictionaryType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -406,6 +418,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: readOnlyDictionaryType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -439,7 +452,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyDictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -641,7 +654,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(readOnlyDictionaryType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(readOnlyDictionaryType, interopDefinitions, "Impl"), vftblType: vftblType, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -657,4 +670,4 @@ public static void ImplType( emitState.TrackTypeDefinition(implType, readOnlyDictionaryType, "Impl"); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs index 8a3afa9f1f..aa7b4284d7 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs @@ -50,7 +50,7 @@ public static void Vftbl( // Otherwise, we must construct a new specialized vtable type vftblType = WellKnownTypeDefinitionFactory.IReadOnlyList1Vftbl( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyListType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopReferences.RuntimeContext, "Vftbl"), + name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopDefinitions, "Vftbl"), elementType: elementType.GetAbiType(interopReferences), interopReferences: interopReferences); @@ -62,6 +62,7 @@ public static void Vftbl( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -69,6 +70,7 @@ public static void Vftbl( public static void IVectorViewMethods( GenericInstanceTypeSignature readOnlyListType, TypeDefinition vftblType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -79,7 +81,7 @@ public static void IVectorViewMethods( // We're declaring an 'internal abstract class' type vectorViewMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyListType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopReferences.RuntimeContext, "IVectorViewMethods"), + name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopDefinitions, "IVectorViewMethods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -106,6 +108,7 @@ public static void IVectorViewMethods( /// /// The for the type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -113,6 +116,7 @@ public static void IVectorViewMethods( public static void Methods( GenericInstanceTypeSignature readOnlyListType, TypeDefinition vectorViewMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -123,7 +127,7 @@ public static void Methods( // We're declaring an 'internal static class' type readOnlyListMethodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyListType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -187,6 +191,7 @@ public static void Methods( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The interop module being built. @@ -194,6 +199,7 @@ public static void Methods( public static void NativeObject( GenericInstanceTypeSignature readOnlyListType, TypeDefinition vectorViewMethodsType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -212,6 +218,7 @@ public static void NativeObject( InteropTypeDefinitionBuilder.NativeObject( typeSignature: readOnlyListType, nativeObjectBaseType: windowsRuntimeReadOnlyList4Type, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out nativeObjectType); @@ -223,6 +230,7 @@ public static void NativeObject( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// Whether to use Windows.UI.Xaml projections. @@ -231,6 +239,7 @@ public static void ComWrappersCallbackType( TypeSignature readOnlyListType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -241,6 +250,7 @@ public static void ComWrappersCallbackType( typeSignature: readOnlyListType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out callbackType); @@ -252,6 +262,7 @@ public static void ComWrappersCallbackType( /// The for the type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -259,6 +270,7 @@ public static void ComWrappersMarshallerAttribute( GenericInstanceTypeSignature readOnlyListType, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -267,6 +279,7 @@ public static void ComWrappersMarshallerAttribute( typeSignature: readOnlyListType, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out marshallerType); @@ -298,7 +311,7 @@ public static void InterfaceImpl( // We're declaring an 'internal interface class' type interfaceImplType = new( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyListType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopReferences.RuntimeContext, "InterfaceImpl"), + name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopDefinitions, "InterfaceImpl"), attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { @@ -429,7 +442,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(readOnlyListType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(readOnlyListType, interopDefinitions, "Impl"), vftblType: vftblType, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -449,7 +462,7 @@ public static void ImplType( /// Creates the type map attributes for some IVectorView<T> interface. /// /// The for the type. - /// The instance returned by . + /// The instance returned by . /// The instance returned by . /// The instance to use. /// The module that will contain the type being created. @@ -499,4 +512,4 @@ public static void TypeMapAttributes( } } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs index b0c973bec2..d3814bdc27 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs @@ -28,10 +28,12 @@ public static class KeyValuePair /// Creates a new type definition for the KeyValuePairMethods type to contain shared accessor /// methods for types. /// + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting methods type. public static void Methods( + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition methodsType) @@ -39,7 +41,7 @@ public static void Methods( // We're declaring an 'internal static class' type methodsType = new TypeDefinition( ns: InteropUtf8NameFactory.TypeNamespace(interopReferences.KeyValuePair.ToReferenceTypeSignature(), interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(interopReferences.KeyValuePair.ToReferenceTypeSignature(), interopReferences.RuntimeContext, "Methods"), + name: InteropUtf8NameFactory.TypeName(interopReferences.KeyValuePair.ToReferenceTypeSignature(), interopDefinitions, "Methods"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -69,8 +71,8 @@ public static void Accessors( TypeSignature valueType = keyValuePairType.TypeArguments[1]; // Prepare the names of the accessor methods, to define or look them up - Utf8String get_KeyMethodName = $"get_Key({InteropUtf8NameFactory.TypeName(keyType, interopReferences.RuntimeContext)})"; - Utf8String get_ValueMethodName = $"get_Value({InteropUtf8NameFactory.TypeName(valueType, interopReferences.RuntimeContext)})"; + Utf8String get_KeyMethodName = $"get_Key({InteropUtf8NameFactory.TypeName(keyType, interopDefinitions)})"; + Utf8String get_ValueMethodName = $"get_Value({InteropUtf8NameFactory.TypeName(valueType, interopDefinitions)})"; // Get or define the 'get_Key' accessor method if (!methodsType.TryGetMethod(get_KeyMethodName, out keyAccessorMethod!)) @@ -108,6 +110,7 @@ public static void Accessors( /// The 'IID' get method for . /// The accessor method for the key. /// The accessor method for the value. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. @@ -117,6 +120,7 @@ public static void Marshaller( MethodDefinition get_IidMethod, MethodDefinition keyAccessorMethod, MethodDefinition valueAccessorMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -125,7 +129,7 @@ public static void Marshaller( // We're declaring an 'internal static class' type marshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(keyValuePairType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopReferences.RuntimeContext, "Marshaller"), + name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopDefinitions, "Marshaller"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -242,7 +246,7 @@ public static void ImplType( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(keyValuePairType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IKeyValuePairVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -272,7 +276,7 @@ public static void InterfaceEntriesImplType( { InterfaceEntriesImpl( ns: InteropUtf8NameFactory.TypeNamespace(keyValuePairType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopReferences.RuntimeContext, "InterfaceEntriesImpl"), + name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopDefinitions, "InterfaceEntriesImpl"), entriesFieldType: interopDefinitions.IKeyValuePairInterfaceEntries, interopReferences: interopReferences, module: module, @@ -311,7 +315,7 @@ public static void ComWrappersMarshallerAttribute( // We're declaring an 'internal sealed class' type marshallerAttributeType = new( ns: InteropUtf8NameFactory.TypeNamespace(keyValuePairType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopReferences.RuntimeContext, "ComWrappersMarshallerAttribute"), + name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopDefinitions, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); @@ -453,6 +457,7 @@ public static void ComWrappersMarshallerAttribute( /// /// The for the type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// Whether to use Windows.UI.Xaml projections. @@ -460,6 +465,7 @@ public static void ComWrappersMarshallerAttribute( public static void Proxy( TypeSignature keyValuePairType, TypeDefinition comWrappersMarshallerAttributeType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -470,7 +476,7 @@ public static void Proxy( // reference the mapped type, so that we can retrieve the original 'Type' instance when marshalling from native. InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(keyValuePairType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(keyValuePairType, interopDefinitions), mappedMetadata: "Windows.Foundation.FoundationContract", runtimeClassName: RuntimeClassNameGenerator.GetRuntimeClassName(keyValuePairType, interopReferences.RuntimeContext, useWindowsUIXamlProjections), metadataTypeName: null, @@ -512,4 +518,4 @@ public static void TypeMapAttributes( module: module); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs index 2eb895169e..36c8df6095 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs @@ -39,12 +39,14 @@ public static class SzArray /// Creates a new type definition for the marshaller for some SZ array type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. /// The resulting marshaller type. public static void Marshaller( SzArrayTypeSignature arrayType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -59,6 +61,7 @@ public static void Marshaller( { marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.BlittableValueType( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -67,6 +70,7 @@ public static void Marshaller( { TypeDefinition elementMarshallerType = InteropTypeDefinitionFactory.SzArrayElementMarshaller.KeyValuePair( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -75,6 +79,7 @@ public static void Marshaller( marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.KeyValuePair( arrayType: arrayType, elementMarshallerType: elementMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -83,6 +88,7 @@ public static void Marshaller( { TypeDefinition elementMarshallerType = InteropTypeDefinitionFactory.SzArrayElementMarshaller.NullableValueType( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -91,6 +97,7 @@ public static void Marshaller( marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.NullableValueType( arrayType: arrayType, elementMarshallerType: elementMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -99,6 +106,7 @@ public static void Marshaller( { TypeDefinition elementMarshallerType = InteropTypeDefinitionFactory.SzArrayElementMarshaller.ManagedValueType( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -107,6 +115,7 @@ public static void Marshaller( marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.ManagedValueType( arrayType: arrayType, elementMarshallerType: elementMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -115,6 +124,7 @@ public static void Marshaller( { TypeDefinition elementMarshallerType = InteropTypeDefinitionFactory.SzArrayElementMarshaller.UnmanagedValueType( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -123,6 +133,7 @@ public static void Marshaller( marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.UnmanagedValueType( arrayType: arrayType, elementMarshallerType: elementMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -131,6 +142,7 @@ public static void Marshaller( { marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.Object( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -139,6 +151,7 @@ public static void Marshaller( { marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.String( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -147,6 +160,7 @@ public static void Marshaller( { marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.Type( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -155,6 +169,7 @@ public static void Marshaller( { marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.Exception( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -163,6 +178,7 @@ public static void Marshaller( { TypeDefinition elementMarshallerType = InteropTypeDefinitionFactory.SzArrayElementMarshaller.ReferenceType( arrayType: arrayType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -171,6 +187,7 @@ public static void Marshaller( marshallerType = InteropTypeDefinitionFactory.SzArrayMarshaller.ReferenceType( arrayType: arrayType, elementMarshallerType: elementMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); module.TopLevelTypes.Add(marshallerType); @@ -182,12 +199,14 @@ public static void Marshaller( /// /// The for the SZ array type. /// The type returned by . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting callback type. public static void ComWrappersCallback( SzArrayTypeSignature arrayType, TypeDefinition marshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition callbackType) @@ -195,7 +214,7 @@ public static void ComWrappersCallback( // We're declaring an 'internal abstract class' type callbackType = new( ns: InteropUtf8NameFactory.TypeNamespace(arrayType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(arrayType, interopReferences.RuntimeContext, "ComWrappersCallback"), + name: InteropUtf8NameFactory.TypeName(arrayType, interopDefinitions, "ComWrappersCallback"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -334,7 +353,7 @@ public static void ArrayImpl( Impl( interfaceType: ComInterfaceType.InterfaceIsIInspectable, ns: InteropUtf8NameFactory.TypeNamespace(arrayType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(arrayType, interopReferences.RuntimeContext, "Impl"), + name: InteropUtf8NameFactory.TypeName(arrayType, interopDefinitions, "Impl"), vftblType: interopDefinitions.IReferenceArrayVftbl, interopDefinitions: interopDefinitions, interopReferences: interopReferences, @@ -402,7 +421,7 @@ public static void InterfaceEntriesImpl( InteropTypeDefinitionBuilder.InterfaceEntriesImpl( ns: InteropUtf8NameFactory.TypeNamespace(arrayType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(arrayType, interopReferences.RuntimeContext, "InterfaceEntriesImpl"), + name: InteropUtf8NameFactory.TypeName(arrayType, interopDefinitions, "InterfaceEntriesImpl"), entriesFieldType: interfaceEntriesType, interopReferences: interopReferences, module: module, @@ -418,6 +437,7 @@ public static void InterfaceEntriesImpl( /// The instance returned by . /// The instance returned by . /// The 'IID' get method for the 'IReferenceArray`1<T>' interface. + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -427,6 +447,7 @@ public static void ComWrappersMarshallerAttribute( TypeDefinition arrayInterfaceEntriesImplType, TypeDefinition arrayComWrappersCallbackType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -434,7 +455,7 @@ public static void ComWrappersMarshallerAttribute( // We're declaring an 'internal sealed class' type marshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(arrayType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(arrayType, interopReferences.RuntimeContext, "ComWrappersMarshallerAttribute"), + name: InteropUtf8NameFactory.TypeName(arrayType, interopDefinitions, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); @@ -537,6 +558,7 @@ public static void ComWrappersMarshallerAttribute( /// /// The for the SZ array type. /// The instance for the marshaller attribute type. + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// Whether to use Windows.UI.Xaml projections. @@ -544,6 +566,7 @@ public static void ComWrappersMarshallerAttribute( public static void Proxy( SzArrayTypeSignature arrayType, TypeDefinition comWrappersMarshallerAttributeType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -555,7 +578,7 @@ public static void Proxy( // type map (as they're treated the same as normal user-defined types), so this allows us to distinguish them. InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(arrayType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(arrayType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(arrayType, interopDefinitions), mappedMetadata: "Windows.Foundation.FoundationContract", runtimeClassName: RuntimeClassNameGenerator.GetRuntimeClassName(arrayType, interopReferences.RuntimeContext, useWindowsUIXamlProjections), metadataTypeName: null, @@ -597,4 +620,4 @@ public static void TypeMapAttributes( module: module); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs index 57d95bfc78..db955fe35e 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs @@ -86,7 +86,7 @@ public static void InterfaceEntriesImpl( InteropTypeDefinitionBuilder.InterfaceEntriesImpl( ns: "WindowsRuntime.Interop.UserDefinedTypes"u8, - name: InteropUtf8NameFactory.TypeName(userDefinedType, interopReferences.RuntimeContext, "InterfaceEntriesImpl"), + name: InteropUtf8NameFactory.TypeName(userDefinedType, interopDefinitions, "InterfaceEntriesImpl"), entriesFieldType: interfaceEntriesType, interopReferences: interopReferences, module: module, @@ -100,6 +100,7 @@ public static void InterfaceEntriesImpl( /// The for the user-defined type. /// The for the interface entries type returned by . /// The for the interface entries implementation type returned by . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -107,6 +108,7 @@ public static void ComWrappersMarshallerAttribute( TypeSignature userDefinedType, TypeDefinition interfaceEntriesType, TypeDefinition interfaceEntriesImplType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -114,7 +116,7 @@ public static void ComWrappersMarshallerAttribute( // We're declaring an 'internal sealed class' type marshallerType = new( ns: "WindowsRuntime.Interop.UserDefinedTypes"u8, - name: InteropUtf8NameFactory.TypeName(userDefinedType, interopReferences.RuntimeContext, "ComWrappersMarshallerAttribute"), + name: InteropUtf8NameFactory.TypeName(userDefinedType, interopDefinitions, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); @@ -180,6 +182,7 @@ public static void ComWrappersMarshallerAttribute( /// /// The for the user-defined type. /// The instance returned by . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// Whether to use Windows.UI.Xaml projections. @@ -187,6 +190,7 @@ public static void ComWrappersMarshallerAttribute( public static void Proxy( TypeSignature userDefinedType, TypeDefinition comWrappersMarshallerAttributeType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -201,7 +205,7 @@ public static void Proxy( { InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(userDefinedType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(userDefinedType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(userDefinedType, interopDefinitions), mappedMetadata: null, runtimeClassName: null, metadataTypeName: null, @@ -218,7 +222,7 @@ public static void Proxy( // For authored component types, the runtime class name is the type's own fully-qualified name. InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(userDefinedType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(userDefinedType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(userDefinedType, interopDefinitions), mappedMetadata: null, runtimeClassName: MetadataTypeNameGenerator.GetMetadataTypeName(userDefinedType, useWindowsUIXamlProjections), metadataTypeName: null, @@ -244,7 +248,7 @@ public static void Proxy( InteropTypeDefinitionBuilder.Proxy( ns: InteropUtf8NameFactory.TypeNamespace(userDefinedType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(userDefinedType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(userDefinedType, interopDefinitions), mappedMetadata: null, runtimeClassName: RuntimeClassNameGenerator.GetRuntimeClassName(interfaceType, interopReferences.RuntimeContext, useWindowsUIXamlProjections), metadataTypeName: null, @@ -285,4 +289,4 @@ public static void TypeMapAttributes( module: module); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs index 610317be80..c179c5295d 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs @@ -42,7 +42,7 @@ public static void IID( out MethodDefinition get_IidMethod) { IID( - name: InteropUtf8NameFactory.TypeName(interfaceType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(interfaceType, interopDefinitions), interopDefinitions: interopDefinitions, interopReferences: interopReferences, iid: GuidGenerator.CreateIID(interfaceType, interopDefinitions, interopReferences, useWindowsUIXamlProjections), @@ -84,12 +84,14 @@ private static void IID( /// /// The for the generic interface type. /// The for the base native object type. + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting native object type. private static void NativeObject( TypeSignature typeSignature, TypeSignature nativeObjectBaseType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition nativeObjectType) @@ -97,7 +99,7 @@ private static void NativeObject( // We're declaring an 'internal sealed class' type nativeObjectType = new( ns: InteropUtf8NameFactory.TypeNamespace(typeSignature, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(typeSignature, interopReferences.RuntimeContext, "NativeObject"), + name: InteropUtf8NameFactory.TypeName(typeSignature, interopDefinitions, "NativeObject"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: nativeObjectBaseType.ToTypeDefOrRef()); @@ -119,6 +121,7 @@ private static void NativeObject( /// The for the generic interface type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The interop module being built. /// The resulting callback type. @@ -127,6 +130,7 @@ private static void ComWrappersCallback( TypeSignature typeSignature, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition callbackType) @@ -134,7 +138,7 @@ private static void ComWrappersCallback( // We're declaring an 'internal abstract class' type callbackType = new( ns: InteropUtf8NameFactory.TypeNamespace(typeSignature, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(typeSignature, interopReferences.RuntimeContext, "ComWrappersCallback"), + name: InteropUtf8NameFactory.TypeName(typeSignature, interopDefinitions, "ComWrappersCallback"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()) { @@ -251,6 +255,7 @@ private static void ComWrappersCallback( /// The for the generic interface type. /// The type returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -258,6 +263,7 @@ private static void ComWrappersMarshallerAttribute( TypeSignature typeSignature, TypeDefinition nativeObjectType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition marshallerType) @@ -265,7 +271,7 @@ private static void ComWrappersMarshallerAttribute( // We're declaring an 'internal sealed class' type marshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(typeSignature, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(typeSignature, interopReferences.RuntimeContext, "ComWrappersMarshallerAttribute"), + name: InteropUtf8NameFactory.TypeName(typeSignature, interopDefinitions, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); @@ -312,6 +318,7 @@ private static void ComWrappersMarshallerAttribute( /// The for the generic interface type. /// The instance returned by . /// The 'IID' get method for . + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The module that will contain the type being created. @@ -320,6 +327,7 @@ public static void Marshaller( TypeSignature typeSignature, TypeDefinition interfaceComWrappersCallbackType, MethodDefinition get_IidMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState, ModuleDefinition module, @@ -328,7 +336,7 @@ public static void Marshaller( // We're declaring an 'internal static class' type marshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(typeSignature, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(typeSignature, interopReferences.RuntimeContext, "Marshaller"), + name: InteropUtf8NameFactory.TypeName(typeSignature, interopDefinitions, "Marshaller"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -704,6 +712,7 @@ private static void InterfaceEntriesImpl( /// /// The for the mapped type the proxy type is for. /// The instance for the marshaller attribute type. + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// Whether to use Windows.UI.Xaml projections. @@ -711,6 +720,7 @@ private static void InterfaceEntriesImpl( public static void Proxy( TypeSignature interfaceType, TypeDefinition comWrappersMarshallerAttributeType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, bool useWindowsUIXamlProjections, @@ -723,7 +733,7 @@ public static void Proxy( // when marshalling 'TypeName' instances. Nobody would need a runtime class name here. Proxy( ns: InteropUtf8NameFactory.TypeNamespace(interfaceType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(interfaceType, interopReferences.RuntimeContext), + name: InteropUtf8NameFactory.TypeName(interfaceType, interopDefinitions), mappedMetadata: null, runtimeClassName: null, metadataTypeName: MetadataTypeNameGenerator.GetMetadataTypeName(interfaceType, useWindowsUIXamlProjections), @@ -943,4 +953,4 @@ public static void TypeMapAttributes( interopReferences: interopReferences)); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Discovery/InteropTypeDiscovery.cs b/src/WinRT.Interop.Generator/Discovery/InteropTypeDiscovery.cs index c044ab3e13..d33fd3d69e 100644 --- a/src/WinRT.Interop.Generator/Discovery/InteropTypeDiscovery.cs +++ b/src/WinRT.Interop.Generator/Discovery/InteropTypeDiscovery.cs @@ -56,15 +56,17 @@ public static void TryTrackTypeHierarchyType( } // We need to resolve the base type to be able to look up attributes on it - if (!baseType.IsFullyResolvable(interopReferences.RuntimeContext, out _)) + if (!baseType.IsFullyResolvable(interopReferences.RuntimeContext, out TypeDefinition? baseTypeDefinition)) { WellKnownInteropExceptions.WindowsRuntimeClassTypeNotResolvedWarning(baseType, typeDefinition).LogOrThrow(args.TreatWarningsAsErrors); return; } - // If the base type is also a projected Windows Runtime type, track it - if (baseType.IsProjectedWindowsRuntimeType) + // If the base type is also a projected Windows Runtime type, track it. The base type is recognized + // either by its '[WindowsRuntimeMetadata]' attribute (implementation projections) or by being defined + // in a reference projection assembly (reference projections don't carry that per-type attribute). + if (baseTypeDefinition.IsProjectedWindowsRuntimeType || baseTypeDefinition.IsReferenceProjectionWindowsRuntimeType) { discoveryState.TrackTypeHierarchyEntry(typeDefinition.FullName, baseType.FullName); } diff --git a/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs b/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs index ce70b8a1a2..31a449b614 100644 --- a/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs +++ b/src/WinRT.Interop.Generator/Extensions/WindowsRuntimeExtensions.cs @@ -115,6 +115,17 @@ public bool IsProjectedWindowsSdkXamlType /// public bool IsComponentWindowsRuntimeType => type.Scope?.GetAssembly() is { IsWindowsRuntimeComponentAssembly: true }; + /// + /// Gets a value indicating whether the type is from a Windows Runtime reference projection assembly. + /// + /// + /// Types in a reference projection assembly (marked with [WindowsRuntimeReferenceAssembly]) are + /// projected Windows Runtime types, but they do not carry the per-type [WindowsRuntimeMetadata] + /// attribute that implementation projections use (it is stripped from reference projections). This mirrors + /// how authored component assemblies expose projected types without that attribute (the IsComponentWindowsRuntimeType extension property). + /// + public bool IsReferenceProjectionWindowsRuntimeType => type.Scope?.GetAssembly() is { IsWindowsRuntimeReferenceAssembly: true }; + /// /// Checks whether an is some type. /// @@ -725,8 +736,10 @@ public bool IsProjectedWindowsRuntimeClassType return false; } - // The type also must be a projected type - return type.IsProjectedWindowsRuntimeType; + // The type also must be a projected type (recognized either by its '[WindowsRuntimeMetadata]' + // attribute, for implementation projections, or by being defined in a reference projection + // assembly, which doesn't carry that per-type attribute). + return type.IsProjectedWindowsRuntimeType || type.IsReferenceProjectionWindowsRuntimeType; } } @@ -774,6 +787,74 @@ public bool IsWindowsRuntimeManagedOnlyType(InteropReferences interopReferences) return attribute?.Signature?.FixedArguments?[0]?.Element as Utf8String; } + + /// + /// Gets the Windows Runtime metadata name for a , recovering it from the + /// implementation projection when the type comes from a reference projection. + /// + /// The instance to use. + /// The Windows Runtime metadata name (i.e. the source .winmd module name), or if not found. + /// + /// + /// The per-type [WindowsRuntimeMetadata] attribute is present on implementation projections, the + /// authored component projection, and manually projected types in WinRT.Runtime.dll, so for those the + /// value is read directly off the type. + /// + /// + /// Reference projections shipped in Windows Runtime projection NuGet packages have that attribute stripped (it + /// is an implementation-only attribute, absent from the WinRT.Runtime.dll reference assembly they compile + /// against). For a type defined in such a reference projection, the source .winmd stem is recovered from + /// the matching type in the implementation projection (located via ), + /// which retains it. That is the authoritative value the interop type-name marker must agree with: the projection + /// writer encodes the very same stem into the [UnsafeAccessorType] references it emits into that + /// implementation projection, so falling back to the reference projection's own assembly name (which can differ + /// from the stem, e.g. when several .winmd files are merged into one projection) would produce mismatched names. + /// + /// + public Utf8String? GetWindowsRuntimeMetadataName(InteropDefinitions interopDefinitions) + { + // Fast path: the attribute is present directly on the type (implementation projections, authored + // components, and 'WinRT.Runtime.dll' types all carry '[WindowsRuntimeMetadata]'). + if (type.GetWindowsRuntimeMetadataName() is { } metadataName) + { + return metadataName; + } + + // The only remaining case we can recover is a type from a reference projection, whose per-type attribute + // was stripped. For those, the metadata name lives on the matching type in the implementation projection. + if (!type.IsReferenceProjectionWindowsRuntimeType) + { + return null; + } + + // Resolve the equivalent type in the right implementation projection (via the cached top-level types + // lookup) and read the '[WindowsRuntimeMetadata]' attribute off it, which it retains. + if (type.GetImplementationProjectionModule(interopDefinitions) is { } projectionModule && + projectionModule.GetTopLevelTypesLookup().TryGetValue((type.Namespace, type.Name), out TypeDefinition? projectionType)) + { + return projectionType.GetWindowsRuntimeMetadataName(); + } + + return null; + } + + /// + /// Gets the implementation projection module that contains the marshalling code for a projected . + /// + /// The instance to use. + /// + /// The for the implementation projection the type belongs to: the Windows SDK projection + /// (WinRT.Sdk.Projection.dll), the Windows SDK XAML projection (WinRT.Sdk.Xaml.Projection.dll), or the merged + /// third-party projection (WinRT.Projection.dll); or if that projection is not available. + /// + public ModuleDefinition? GetImplementationProjectionModule(InteropDefinitions interopDefinitions) + { + return type.IsProjectedWindowsSdkType + ? interopDefinitions.WindowsRuntimeSdkProjectionModule + : type.IsProjectedWindowsSdkXamlType + ? interopDefinitions.WindowsRuntimeSdkXamlProjectionModule + : interopDefinitions.WindowsRuntimeProjectionModule; + } } extension(TypeSignature signature) @@ -1006,8 +1087,9 @@ public bool IsWindowsRuntimeType(InteropReferences interopReferences) // For all other cases, just check that the type is projected. This will also include manually // projected types that are defined in 'WinRT.Runtime.dll' (same attributes). Public types from - // authored component assemblies are also considered Windows Runtime types. - return type.IsProjectedWindowsRuntimeType || type.IsComponentWindowsRuntimeType; + // authored component assemblies, and types from reference projection assemblies, are also + // considered Windows Runtime types (they don't carry the per-type '[WindowsRuntimeMetadata]' attribute). + return type.IsProjectedWindowsRuntimeType || type.IsComponentWindowsRuntimeType || type.IsReferenceProjectionWindowsRuntimeType; } /// @@ -1073,8 +1155,9 @@ arrayType.BaseType is not SzArrayTypeSignature && TypeDefinition type = signature.Resolve(interopReferences.RuntimeContext); // For all other cases, first check that the type is projected. Public types from authored - // component assemblies are also considered projected, even without '[WindowsRuntimeMetadata]'. - if (!type.IsProjectedWindowsRuntimeType && !type.IsComponentWindowsRuntimeType) + // component assemblies, and types from reference projection assemblies, are also considered + // projected, even without '[WindowsRuntimeMetadata]'. + if (!type.IsProjectedWindowsRuntimeType && !type.IsComponentWindowsRuntimeType && !type.IsReferenceProjectionWindowsRuntimeType) { return false; } @@ -1088,22 +1171,25 @@ arrayType.BaseType is not SzArrayTypeSignature && /// /// Gets the Windows Runtime metadata name for a , if available. /// - /// The context to assume when resolving types. - /// The Windows Runtime metadata name from the underlying type's WindowsRuntimeMetadataAttribute, or if not found. + /// The instance to use. + /// The Windows Runtime metadata name for the underlying type, or if not found. /// /// /// This method resolves the underlying type definition from the signature and retrieves its Windows Runtime metadata name. /// For generic instance types, it uses the generic type definition. For array types, it uses the base element type. - /// For other types, it resolves the type definition directly. + /// For other types, it resolves the type definition directly. The metadata name is recovered from the implementation + /// projection for types coming from reference projections (see the overload of this method). /// /// - public Utf8String? GetWindowsRuntimeMetadataName(RuntimeContext? runtimeContext) + public Utf8String? GetWindowsRuntimeMetadataName(InteropDefinitions interopDefinitions) { + RuntimeContext? runtimeContext = interopDefinitions.RuntimeContext; + return signature switch { - GenericInstanceTypeSignature generic => generic.GenericType.Resolve(runtimeContext).GetWindowsRuntimeMetadataName(), - ArrayTypeSignature array => array.BaseType.Resolve(runtimeContext).GetWindowsRuntimeMetadataName(), - _ => signature.ToTypeDefOrRef().Resolve(runtimeContext).GetWindowsRuntimeMetadataName() + GenericInstanceTypeSignature generic => generic.GenericType.Resolve(runtimeContext).GetWindowsRuntimeMetadataName(interopDefinitions), + ArrayTypeSignature array => array.BaseType.Resolve(runtimeContext).GetWindowsRuntimeMetadataName(interopDefinitions), + _ => signature.ToTypeDefOrRef().Resolve(runtimeContext).GetWindowsRuntimeMetadataName(interopDefinitions) }; } } diff --git a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.cs b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.cs index fa5a979d96..eca50d9d0a 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IEnumeratorElementMarshaller.cs @@ -28,11 +28,13 @@ public static class IEnumeratorElementMarshaller /// Creates a for the element marshaller for an unmanaged value type. /// /// The for the type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition UnmanagedValueType( GenericInstanceTypeSignature enumeratorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -49,6 +51,7 @@ public static TypeDefinition UnmanagedValueType( interfaceType: interfaceType, convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeUnmanagedValueTypeElementMarshallerConvertToUnmanaged(elementType, elementAbiType), isValueType: true, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -57,11 +60,13 @@ public static TypeDefinition UnmanagedValueType( /// Creates a for the element marshaller for a managed value type. /// /// The for the type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition ManagedValueType( GenericInstanceTypeSignature enumeratorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -79,6 +84,7 @@ public static TypeDefinition ManagedValueType( interfaceType: interfaceType, convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeManagedValueTypeElementMarshallerConvertToUnmanaged(elementType, elementAbiType), isValueType: true, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -119,11 +125,13 @@ public static TypeDefinition ManagedValueType( /// Creates a for the element marshaller for a type. /// /// The for the type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition KeyValuePair( GenericInstanceTypeSignature enumeratorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -144,6 +152,7 @@ public static TypeDefinition KeyValuePair( interfaceType: interfaceType, convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeKeyValuePairTypeElementMarshallerConvertToUnmanaged(keyType, valueType), isValueType: isValueType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -152,11 +161,13 @@ public static TypeDefinition KeyValuePair( /// Creates a for the element marshaller for a type. /// /// The for the type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition NullableValueType( GenericInstanceTypeSignature enumeratorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -173,6 +184,7 @@ public static TypeDefinition NullableValueType( interfaceType: interfaceType, convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeNullableTypeElementMarshallerConvertToUnmanaged(underlyingType), isValueType: true, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -181,11 +193,13 @@ public static TypeDefinition NullableValueType( /// Creates a for the element marshaller for a reference type. /// /// The for the type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition ReferenceType( GenericInstanceTypeSignature enumeratorType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -201,6 +215,7 @@ public static TypeDefinition ReferenceType( interfaceType: interfaceType, convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeReferenceTypeElementMarshallerConvertToUnmanaged(elementType), isValueType: false, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -212,6 +227,7 @@ public static TypeDefinition ReferenceType( /// The interface type the element marshaller type should implement. /// The ConvertToUnmanaged interface method being implemented. /// Indicates whether the element marshaller type should be emitted as a value type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. @@ -220,6 +236,7 @@ public static TypeDefinition ElementMarshaller( TypeSignature interfaceType, MemberReference convertToUnmanagedInterfaceMethod, bool isValueType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -231,7 +248,7 @@ public static TypeDefinition ElementMarshaller( // We're declaring an 'internal abstract class' type TypeDefinition elementMarshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(elementType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(elementType, interopReferences.RuntimeContext, "ElementMarshaller"), + name: InteropUtf8NameFactory.TypeName(elementType, interopDefinitions, "ElementMarshaller"), attributes: attributes, baseType: baseType) { @@ -273,4 +290,4 @@ public static TypeDefinition ElementMarshaller( return elementMarshallerType; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IReadOnlyCollectionKeyValuePair2.cs b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IReadOnlyCollectionKeyValuePair2.cs index 36fdab5649..0f7018eada 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IReadOnlyCollectionKeyValuePair2.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.IReadOnlyCollectionKeyValuePair2.cs @@ -26,6 +26,7 @@ public static class IReadOnlyCollectionKeyValuePair2 /// The for the generic interface type. /// The for the corresponding type. /// The for the corresponding type. + /// The instance to use. /// The instance to use. /// The module that will contain the type being created. /// The resulting marshaller type. @@ -36,6 +37,7 @@ public static void ForwarderAttribute( GenericInstanceTypeSignature readOnlyCollectionType, TypeSignature readOnlyDictionaryType, TypeSignature readOnlyListType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module, out TypeDefinition forwarderAttributeType) @@ -43,7 +45,7 @@ public static void ForwarderAttribute( // We're declaring an 'internal sealed class' type forwarderAttributeType = new( ns: InteropUtf8NameFactory.TypeNamespace(readOnlyCollectionType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(readOnlyCollectionType, interopReferences.RuntimeContext, "ForwarderAttribute"), + name: InteropUtf8NameFactory.TypeName(readOnlyCollectionType, interopDefinitions, "ForwarderAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, baseType: interopReferences.DynamicInterfaceCastableForwarderAttribute); @@ -99,4 +101,4 @@ public static void ForwarderAttribute( forwarderAttributeType.Methods.Add(isInterfaceImplementedMethod); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayElementMarshaller.cs b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayElementMarshaller.cs index e0f41b7e3f..31d223e3d6 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayElementMarshaller.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayElementMarshaller.cs @@ -25,11 +25,13 @@ public static class SzArrayElementMarshaller /// Creates a for the element marshaller for an unmanaged value type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition UnmanagedValueType( SzArrayTypeSignature arrayType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -47,6 +49,7 @@ public static TypeDefinition UnmanagedValueType( convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeUnmanagedValueTypeArrayElementMarshallerConvertToUnmanaged(elementType, elementAbiType), convertToManagedInterfaceMethod: interopReferences.IWindowsRuntimeUnmanagedValueTypeArrayElementMarshallerConvertToManaged(elementType, elementAbiType), isValueType: true, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -55,11 +58,13 @@ public static TypeDefinition UnmanagedValueType( /// Creates a for the element marshaller for a managed value type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition ManagedValueType( SzArrayTypeSignature arrayType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -78,6 +83,7 @@ public static TypeDefinition ManagedValueType( convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeManagedValueTypeArrayElementMarshallerConvertToUnmanaged(elementType, elementAbiType), convertToManagedInterfaceMethod: interopReferences.IWindowsRuntimeManagedValueTypeArrayElementMarshallerConvertToManaged(elementType, elementAbiType), isValueType: true, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); @@ -118,11 +124,13 @@ public static TypeDefinition ManagedValueType( /// Creates a for the element marshaller for a type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition KeyValuePair( SzArrayTypeSignature arrayType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -147,6 +155,7 @@ public static TypeDefinition KeyValuePair( convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeKeyValuePairTypeArrayElementMarshallerConvertToUnmanaged(keyType, valueType), convertToManagedInterfaceMethod: interopReferences.IWindowsRuntimeKeyValuePairTypeArrayElementMarshallerConvertToManaged(keyType, valueType), isValueType: isValueType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -155,11 +164,13 @@ public static TypeDefinition KeyValuePair( /// Creates a for the element marshaller for a type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition NullableValueType( SzArrayTypeSignature arrayType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -177,6 +188,7 @@ public static TypeDefinition NullableValueType( convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeNullableTypeArrayElementMarshallerConvertToUnmanaged(underlyingType), convertToManagedInterfaceMethod: interopReferences.IWindowsRuntimeNullableTypeArrayElementMarshallerConvertToManaged(underlyingType), isValueType: true, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -185,11 +197,13 @@ public static TypeDefinition NullableValueType( /// Creates a for the element marshaller for a reference type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. public static TypeDefinition ReferenceType( SzArrayTypeSignature arrayType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -206,6 +220,7 @@ public static TypeDefinition ReferenceType( convertToUnmanagedInterfaceMethod: interopReferences.IWindowsRuntimeReferenceTypeArrayElementMarshallerConvertToUnmanaged(elementType), convertToManagedInterfaceMethod: interopReferences.IWindowsRuntimeReferenceTypeArrayElementMarshallerConvertToManaged(elementType), isValueType: false, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState); } @@ -218,6 +233,7 @@ public static TypeDefinition ReferenceType( /// The ConvertToUnmanaged interface method being implemented. /// The ConvertToManaged interface method being implemented. /// Indicates whether the element marshaller type should be emitted as a value type. + /// The instance to use. /// The instance to use. /// The emit state for this invocation. /// The resulting element marshaller type. @@ -227,6 +243,7 @@ public static TypeDefinition ElementMarshaller( MemberReference convertToUnmanagedInterfaceMethod, MemberReference convertToManagedInterfaceMethod, bool isValueType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, InteropGeneratorEmitState emitState) { @@ -240,7 +257,7 @@ public static TypeDefinition ElementMarshaller( // We're declaring an 'internal abstract class' type TypeDefinition elementMarshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(arrayType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(arrayType, interopReferences.RuntimeContext, "ElementMarshaller"), + name: InteropUtf8NameFactory.TypeName(arrayType, interopDefinitions, "ElementMarshaller"), attributes: attributes, baseType: baseType) { @@ -312,4 +329,4 @@ public static TypeDefinition ElementMarshaller( return elementMarshallerType; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayMarshaller.cs b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayMarshaller.cs index f86c4007c9..0e6512c7c8 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayMarshaller.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropTypeDefinitionFactory.SzArrayMarshaller.cs @@ -23,10 +23,12 @@ public static class SzArrayMarshaller /// Creates a for the marshaller for a blittable value type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The resulting marshaller type. public static TypeDefinition BlittableValueType( SzArrayTypeSignature arrayType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences) { TypeSignature elementType = arrayType.BaseType; @@ -39,6 +41,7 @@ public static TypeDefinition BlittableValueType( copyToManagedMethod: interopReferences.WindowsRuntimeBlittableValueTypeArrayMarshallerCopyToManaged(elementType), disposeMethod: null, freeMethod: interopReferences.WindowsRuntimeBlittableValueTypeArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -47,11 +50,13 @@ public static TypeDefinition BlittableValueType( /// /// The for the SZ array type. /// The element marshaller type produced by . + /// The instance to use. /// The instance to use. /// The resulting marshaller type. public static TypeDefinition UnmanagedValueType( SzArrayTypeSignature arrayType, TypeDefinition elementMarshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences) { TypeSignature elementType = arrayType.BaseType; @@ -66,6 +71,7 @@ public static TypeDefinition UnmanagedValueType( copyToManagedMethod: interopReferences.WindowsRuntimeUnmanagedValueTypeArrayMarshallerCopyToManaged(elementType, elementAbiType, elementMarshallerTypeSignature), disposeMethod: null, freeMethod: interopReferences.WindowsRuntimeBlittableValueTypeArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -74,11 +80,13 @@ public static TypeDefinition UnmanagedValueType( /// /// The for the SZ array type. /// The element marshaller type produced by . + /// The instance to use. /// The instance to use. /// The resulting marshaller type. public static TypeDefinition ManagedValueType( SzArrayTypeSignature arrayType, TypeDefinition elementMarshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences) { TypeSignature elementType = arrayType.BaseType; @@ -93,6 +101,7 @@ public static TypeDefinition ManagedValueType( copyToManagedMethod: interopReferences.WindowsRuntimeManagedValueTypeArrayMarshallerCopyToManaged(elementType, elementAbiType, elementMarshallerTypeSignature), disposeMethod: interopReferences.WindowsRuntimeManagedValueTypeArrayMarshallerDispose(elementType, elementAbiType, elementMarshallerTypeSignature), freeMethod: interopReferences.WindowsRuntimeManagedValueTypeArrayMarshallerFree(elementType, elementAbiType, elementMarshallerTypeSignature), + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -101,11 +110,13 @@ public static TypeDefinition ManagedValueType( /// /// The for the SZ array type. /// The element marshaller type produced by . + /// The instance to use. /// The instance to use. /// The resulting marshaller type. public static TypeDefinition KeyValuePair( SzArrayTypeSignature arrayType, TypeDefinition elementMarshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences) { GenericInstanceTypeSignature elementType = (GenericInstanceTypeSignature)arrayType.BaseType; @@ -121,6 +132,7 @@ public static TypeDefinition KeyValuePair( copyToManagedMethod: interopReferences.WindowsRuntimeKeyValuePairTypeArrayMarshallerCopyToManaged(keyType, valueType, elementMarshallerTypeSignature), disposeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerDispose, freeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -129,11 +141,13 @@ public static TypeDefinition KeyValuePair( /// /// The for the SZ array type. /// The element marshaller type produced by . + /// The instance to use. /// The instance to use. /// The resulting marshaller type. public static TypeDefinition NullableValueType( SzArrayTypeSignature arrayType, TypeDefinition elementMarshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences) { GenericInstanceTypeSignature elementType = (GenericInstanceTypeSignature)arrayType.BaseType; @@ -148,6 +162,7 @@ public static TypeDefinition NullableValueType( copyToManagedMethod: interopReferences.WindowsRuntimeNullableTypeArrayMarshallerCopyToManaged(underlyingType, elementMarshallerTypeSignature), disposeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerDispose, freeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -156,11 +171,13 @@ public static TypeDefinition NullableValueType( /// /// The for the SZ array type. /// The element marshaller type produced by . + /// The instance to use. /// The instance to use. /// The resulting marshaller type. public static TypeDefinition ReferenceType( SzArrayTypeSignature arrayType, TypeDefinition elementMarshallerType, + InteropDefinitions interopDefinitions, InteropReferences interopReferences) { TypeSignature elementType = arrayType.BaseType; @@ -174,6 +191,7 @@ public static TypeDefinition ReferenceType( copyToManagedMethod: interopReferences.WindowsRuntimeReferenceTypeArrayMarshallerCopyToManaged(elementType, elementMarshallerTypeSignature), disposeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerDispose, freeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -181,9 +199,10 @@ public static TypeDefinition ReferenceType( /// Creates a for the marshaller for the type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The resulting marshaller type. - public static TypeDefinition Object(SzArrayTypeSignature arrayType, InteropReferences interopReferences) + public static TypeDefinition Object(SzArrayTypeSignature arrayType, InteropDefinitions interopDefinitions, InteropReferences interopReferences) { return Marshaller( arrayType: arrayType, @@ -193,6 +212,7 @@ public static TypeDefinition Object(SzArrayTypeSignature arrayType, InteropRefer copyToManagedMethod: interopReferences.WindowsRuntimeObjectArrayMarshallerCopyToManaged, disposeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerDispose, freeMethod: interopReferences.WindowsRuntimeUnknownArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -200,9 +220,10 @@ public static TypeDefinition Object(SzArrayTypeSignature arrayType, InteropRefer /// Creates a for the marshaller for the type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The resulting marshaller type. - public static TypeDefinition String(SzArrayTypeSignature arrayType, InteropReferences interopReferences) + public static TypeDefinition String(SzArrayTypeSignature arrayType, InteropDefinitions interopDefinitions, InteropReferences interopReferences) { return Marshaller( arrayType: arrayType, @@ -212,6 +233,7 @@ public static TypeDefinition String(SzArrayTypeSignature arrayType, InteropRefer copyToManagedMethod: interopReferences.HStringArrayMarshallerCopyToManaged, disposeMethod: interopReferences.HStringArrayMarshallerDispose, freeMethod: interopReferences.HStringArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -219,9 +241,10 @@ public static TypeDefinition String(SzArrayTypeSignature arrayType, InteropRefer /// Creates a for the marshaller for the type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The resulting marshaller type. - public static TypeDefinition Type(SzArrayTypeSignature arrayType, InteropReferences interopReferences) + public static TypeDefinition Type(SzArrayTypeSignature arrayType, InteropDefinitions interopDefinitions, InteropReferences interopReferences) { return Marshaller( arrayType: arrayType, @@ -231,6 +254,7 @@ public static TypeDefinition Type(SzArrayTypeSignature arrayType, InteropReferen copyToManagedMethod: interopReferences.TypeArrayMarshallerCopyToManaged, disposeMethod: interopReferences.TypeArrayMarshallerDispose, freeMethod: interopReferences.TypeArrayMarshallerFree, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -238,9 +262,10 @@ public static TypeDefinition Type(SzArrayTypeSignature arrayType, InteropReferen /// Creates a for the marshaller for the type. /// /// The for the SZ array type. + /// The instance to use. /// The instance to use. /// The resulting marshaller type. - public static TypeDefinition Exception(SzArrayTypeSignature arrayType, InteropReferences interopReferences) + public static TypeDefinition Exception(SzArrayTypeSignature arrayType, InteropDefinitions interopDefinitions, InteropReferences interopReferences) { return Marshaller( arrayType: arrayType, @@ -250,6 +275,7 @@ public static TypeDefinition Exception(SzArrayTypeSignature arrayType, InteropRe copyToManagedMethod: interopReferences.ExceptionArrayMarshallerCopyToManaged, freeMethod: interopReferences.WindowsRuntimeBlittableValueTypeArrayMarshallerFree, disposeMethod: null, + interopDefinitions: interopDefinitions, interopReferences: interopReferences); } @@ -263,6 +289,7 @@ public static TypeDefinition Exception(SzArrayTypeSignature arrayType, InteropRe /// The CopyToManaged implementation method to call. /// The Dispose implementation method to call, if applicable. /// The Free implementation method to call. + /// The instance to use. /// The instance to use. /// The resulting marshaller type. private static TypeDefinition Marshaller( @@ -273,6 +300,7 @@ private static TypeDefinition Marshaller( IMethodDescriptor copyToManagedMethod, IMethodDescriptor? disposeMethod, IMethodDescriptor freeMethod, + InteropDefinitions interopDefinitions, InteropReferences interopReferences) { TypeSignature elementType = arrayType.BaseType; @@ -281,7 +309,7 @@ private static TypeDefinition Marshaller( // We're declaring an 'internal static class' type TypeDefinition marshallerType = new( ns: InteropUtf8NameFactory.TypeNamespace(arrayType, interopReferences.RuntimeContext), - name: InteropUtf8NameFactory.TypeName(arrayType, interopReferences.RuntimeContext, "Marshaller"), + name: InteropUtf8NameFactory.TypeName(arrayType, interopDefinitions, "Marshaller"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: interopReferences.Object.ToTypeDefOrRef()); @@ -436,4 +464,4 @@ private static TypeDefinition Marshaller( return marshallerType; } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Factories/InteropUtf8NameFactory.cs b/src/WinRT.Interop.Generator/Factories/InteropUtf8NameFactory.cs index 866d3d5b87..bf6da83b2d 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropUtf8NameFactory.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropUtf8NameFactory.cs @@ -9,6 +9,7 @@ using AsmResolver.DotNet; using AsmResolver.DotNet.Signatures; using AsmResolver.PE.DotNet.Metadata.Tables; +using WindowsRuntime.InteropGenerator.References; namespace WindowsRuntime.InteropGenerator.Factories; @@ -55,10 +56,10 @@ public static Utf8String TypeNamespace(TypeSignature typeSignature, RuntimeConte /// Gets the name for a generated interop type. /// /// The source for the type to generate. - /// The context to assume when resolving types. + /// The instance to use (for resolving types and locating implementation projections). /// The optional name suffix to use. /// The name to use. - public static Utf8String TypeName(TypeSignature typeSignature, RuntimeContext? runtimeContext, string? nameSuffix = null) + public static Utf8String TypeName(TypeSignature typeSignature, InteropDefinitions interopDefinitions, string? nameSuffix = null) { DefaultInterpolatedStringHandler interpolatedStringHandler = new(literalLength: 2, formattedCount: 1); @@ -66,7 +67,7 @@ public static Utf8String TypeName(TypeSignature typeSignature, RuntimeContext? r static void AppendTypeName( ref DefaultInterpolatedStringHandler interpolatedStringHandler, TypeSignature typeSignature, - RuntimeContext? runtimeContext, + InteropDefinitions interopDefinitions, int depth) { // Special case for well known type identifiers (eg. 'string', 'int', etc.) @@ -82,7 +83,7 @@ static void AppendTypeName( { interpolatedStringHandler.AppendLiteral("<"); - AppendTypeName(ref interpolatedStringHandler, arrayTypeSignature.BaseType, runtimeContext, depth); + AppendTypeName(ref interpolatedStringHandler, arrayTypeSignature.BaseType, interopDefinitions, depth); interpolatedStringHandler.AppendLiteral(">Array"); } @@ -91,7 +92,7 @@ static void AppendTypeName( Utf8String assemblyName = AssemblyNameOrWellKnownIdentifier( assemblyName: typeSignature.Scope!.GetAssembly()!.Name!, typeSignature: typeSignature, - runtimeContext: runtimeContext); + interopDefinitions: interopDefinitions); // Each type name uses this format: 'TYPE_NAME' interpolatedStringHandler.AppendLiteral("<"); @@ -108,7 +109,7 @@ static void AppendTypeName( // type descriptor here, because we also want to detect arrays with an element type that's generic. if (typeSignature is GenericInstanceTypeSignature genericInstanceTypeSignature) { - AppendTypeArguments(ref interpolatedStringHandler, genericInstanceTypeSignature, runtimeContext, depth); + AppendTypeArguments(ref interpolatedStringHandler, genericInstanceTypeSignature, interopDefinitions, depth); } } } @@ -157,7 +158,7 @@ static void AppendRawTypeName( static void AppendTypeArguments( ref DefaultInterpolatedStringHandler interpolatedStringHandler, GenericInstanceTypeSignature type, - RuntimeContext? runtimeContext, + InteropDefinitions interopDefinitions, int depth) { interpolatedStringHandler.AppendLiteral("<"); @@ -172,14 +173,14 @@ static void AppendTypeArguments( // Append the type argument with the same format as the root type. This is // important to ensure that nested generic types will be handled correctly. - AppendTypeName(ref interpolatedStringHandler, typeArgumentSignature, runtimeContext, depth: depth + 1); + AppendTypeName(ref interpolatedStringHandler, typeArgumentSignature, interopDefinitions, depth: depth + 1); } interpolatedStringHandler.AppendLiteral(">"); } // Append the full type name first - AppendTypeName(ref interpolatedStringHandler, typeSignature, runtimeContext, depth: 0); + AppendTypeName(ref interpolatedStringHandler, typeSignature, interopDefinitions, depth: 0); // Append the suffix, if we have one interpolatedStringHandler.AppendFormatted(nameSuffix); @@ -204,13 +205,13 @@ static void AppendTypeArguments( /// /// The input assembly name to convert. /// The type signature for which to convert. - /// The context to assume when resolving the type. + /// The instance to use. /// The resulting assembly name to use. [return: NotNullIfNotNull(nameof(assemblyName))] private static Utf8String? AssemblyNameOrWellKnownIdentifier( Utf8String? assemblyName, TypeSignature typeSignature, - RuntimeContext? runtimeContext) + InteropDefinitions interopDefinitions) { // Replace some assembly names with well known constants, to make the names more compact return assemblyName switch @@ -218,7 +219,7 @@ static void AppendTypeArguments( { Value: "System.Runtime" } => "#corlib"u8, { Value: "Microsoft.Windows.SDK.NET" or "Microsoft.Windows.UI.Xaml" } => "#Windows"u8, { Value: "WinRT.Runtime" } => "#CsWinRT"u8, - _ => typeSignature.GetWindowsRuntimeMetadataName(runtimeContext) ?? assemblyName + _ => typeSignature.GetWindowsRuntimeMetadataName(interopDefinitions) ?? assemblyName }; } diff --git a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Emit.cs b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Emit.cs index 012efd323f..7c3752cf19 100644 --- a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Emit.cs +++ b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Emit.cs @@ -146,12 +146,12 @@ private static void Emit(InteropGeneratorArgs args, InteropGeneratorDiscoverySta args.Token.ThrowIfCancellationRequested(); // Emit interop types for 'IReadOnlyCollection>' types - DefineIReadOnlyCollectionKeyValuePair2Types(args, discoveryState, emitState, interopReferences, module); + DefineIReadOnlyCollectionKeyValuePair2Types(args, discoveryState, emitState, interopDefinitions, interopReferences, module); args.Token.ThrowIfCancellationRequested(); // Emit interop types for 'ICollection>' types - DefineICollectionKeyValuePair2Types(args, discoveryState, emitState, interopReferences, module); + DefineICollectionKeyValuePair2Types(args, discoveryState, emitState, interopDefinitions, interopReferences, module); args.Token.ThrowIfCancellationRequested(); @@ -329,6 +329,7 @@ private static void DefineGenericDelegateTypes( delegateType: typeSignature, nativeDelegateType: nativeDelegateType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition delegateComWrappersCallbackType); @@ -338,6 +339,7 @@ private static void DefineGenericDelegateTypes( delegateComWrappersCallbackType: delegateComWrappersCallbackType, get_IidMethod: get_IidMethod, get_ReferenceIidMethod: get_ReferenceIidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -384,6 +386,7 @@ private static void DefineGenericDelegateTypes( InteropTypeDefinitionBuilder.Delegate.Proxy( delegateType: typeSignature, comWrappersMarshallerAttributeType: delegateComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -402,6 +405,7 @@ private static void DefineGenericDelegateTypes( InteropTypeDefinitionBuilder.EventSource.EventHandler1( delegateType: typeSignature, marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, eventSourceType: out _); @@ -411,6 +415,7 @@ private static void DefineGenericDelegateTypes( InteropTypeDefinitionBuilder.EventSource.EventHandler2( delegateType: typeSignature, marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, eventSourceType: out _); @@ -420,6 +425,7 @@ private static void DefineGenericDelegateTypes( InteropTypeDefinitionBuilder.EventSource.VectorChangedEventHandler1( delegateType: typeSignature, marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -430,6 +436,7 @@ private static void DefineGenericDelegateTypes( InteropTypeDefinitionBuilder.EventSource.MapChangedEventHandler2( delegateType: typeSignature, marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -476,6 +483,7 @@ private static void DefineIEnumeratorTypes( InteropTypeDefinitionBuilder.IEnumerator1.ElementMarshaller( enumeratorType: typeSignature, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -500,6 +508,7 @@ private static void DefineIEnumeratorTypes( InteropTypeDefinitionBuilder.IEnumerator1.Methods( enumeratorType: typeSignature, iteratorMethodsType: iteratorMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, enumeratorMethodsType: out _); @@ -507,6 +516,7 @@ private static void DefineIEnumeratorTypes( InteropTypeDefinitionBuilder.IEnumerator1.NativeObject( enumeratorType: typeSignature, iteratorMethodsType: iteratorMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, nativeObjectType: out TypeDefinition nativeObjectType); @@ -515,6 +525,7 @@ private static void DefineIEnumeratorTypes( enumeratorType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -524,6 +535,7 @@ private static void DefineIEnumeratorTypes( enumeratorType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, marshallerType: out TypeDefinition enumeratorComWrappersMarshallerType); @@ -532,6 +544,7 @@ private static void DefineIEnumeratorTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: enumeratorComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -549,6 +562,7 @@ private static void DefineIEnumeratorTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: enumeratorComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -602,6 +616,7 @@ private static void DefineIEnumerableTypes( InteropTypeDefinitionBuilder.IEnumerable1.Interface( enumerableType: typeSignature, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -626,6 +641,7 @@ private static void DefineIEnumerableTypes( InteropTypeDefinitionBuilder.IEnumerable1.Methods( enumerableType: typeSignature, iterableMethodsType: iterableMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, enumerableMethodsType: out _); @@ -633,6 +649,7 @@ private static void DefineIEnumerableTypes( InteropTypeDefinitionBuilder.IEnumerable1.NativeObject( enumerableType: typeSignature, iterableMethodsType: iterableMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, nativeObjectType: out TypeDefinition nativeObjectType); @@ -641,6 +658,7 @@ private static void DefineIEnumerableTypes( enumerableType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -650,6 +668,7 @@ private static void DefineIEnumerableTypes( enumerableType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, marshallerType: out TypeDefinition enumerableComWrappersMarshallerType); @@ -658,6 +677,7 @@ private static void DefineIEnumerableTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: enumerableComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -675,6 +695,7 @@ private static void DefineIEnumerableTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: enumerableComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -744,6 +765,7 @@ private static void DefineIReadOnlyListTypes( InteropTypeDefinitionBuilder.IReadOnlyList1.IVectorViewMethods( readOnlyListType: typeSignature, vftblType: vftblType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -752,6 +774,7 @@ private static void DefineIReadOnlyListTypes( InteropTypeDefinitionBuilder.IReadOnlyList1.Methods( readOnlyListType: typeSignature, vectorViewMethodsType: vectorViewMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -760,6 +783,7 @@ private static void DefineIReadOnlyListTypes( InteropTypeDefinitionBuilder.IReadOnlyList1.NativeObject( readOnlyListType: typeSignature, vectorViewMethodsType: vectorViewMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -769,6 +793,7 @@ private static void DefineIReadOnlyListTypes( readOnlyListType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -778,6 +803,7 @@ private static void DefineIReadOnlyListTypes( readOnlyListType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition readOnlyListComWrappersMarshallerType); @@ -786,6 +812,7 @@ private static void DefineIReadOnlyListTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: readOnlyListComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -803,6 +830,7 @@ private static void DefineIReadOnlyListTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: readOnlyListComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -856,6 +884,7 @@ private static void DefineIListTypes( InteropTypeDefinitionBuilder.IList1.Interface( listType: typeSignature, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -880,6 +909,7 @@ private static void DefineIListTypes( InteropTypeDefinitionBuilder.IList1.IVectorMethods( listType: typeSignature, vftblType: vftblType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -888,6 +918,7 @@ private static void DefineIListTypes( InteropTypeDefinitionBuilder.IList1.Methods( listType: typeSignature, vectorMethodsType: vectorMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -896,6 +927,7 @@ private static void DefineIListTypes( InteropTypeDefinitionBuilder.IList1.NativeObject( listType: typeSignature, vectorMethodsType: vectorMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -905,6 +937,7 @@ private static void DefineIListTypes( listType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -914,6 +947,7 @@ private static void DefineIListTypes( listType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition listComWrappersMarshallerType); @@ -922,6 +956,7 @@ private static void DefineIListTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: listComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -939,6 +974,7 @@ private static void DefineIListTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: listComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1009,6 +1045,7 @@ private static void DefineIReadOnlyDictionaryTypes( InteropTypeDefinitionBuilder.IReadOnlyDictionary2.IMapViewMethods( readOnlyDictionaryType: typeSignature, vftblType: vftblType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1017,6 +1054,7 @@ private static void DefineIReadOnlyDictionaryTypes( InteropTypeDefinitionBuilder.IReadOnlyDictionary2.Methods( readOnlyDictionaryType: typeSignature, mapViewMethodsType: mapViewMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1025,6 +1063,7 @@ private static void DefineIReadOnlyDictionaryTypes( InteropTypeDefinitionBuilder.IReadOnlyDictionary2.NativeObject( readOnlyDictionaryType: typeSignature, mapViewMethodsType: mapViewMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1034,6 +1073,7 @@ private static void DefineIReadOnlyDictionaryTypes( readOnlyDictionaryType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1043,6 +1083,7 @@ private static void DefineIReadOnlyDictionaryTypes( readOnlyDictionaryType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition readOnlyDictionaryComWrappersMarshallerType); @@ -1051,6 +1092,7 @@ private static void DefineIReadOnlyDictionaryTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: readOnlyDictionaryComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1068,6 +1110,7 @@ private static void DefineIReadOnlyDictionaryTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: readOnlyDictionaryComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1121,6 +1164,7 @@ private static void DefineIDictionaryTypes( InteropTypeDefinitionBuilder.IDictionary2.Interface( dictionaryType: typeSignature, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1146,6 +1190,7 @@ private static void DefineIDictionaryTypes( InteropTypeDefinitionBuilder.IDictionary2.IMapMethods( dictionaryType: typeSignature, vftblType: vftblType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1154,6 +1199,7 @@ private static void DefineIDictionaryTypes( InteropTypeDefinitionBuilder.IDictionary2.Methods( dictionaryType: typeSignature, mapMethodsType: mapMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1162,6 +1208,7 @@ private static void DefineIDictionaryTypes( InteropTypeDefinitionBuilder.IDictionary2.NativeObject( dictionaryType: typeSignature, mapMethodsType: mapMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1171,6 +1218,7 @@ private static void DefineIDictionaryTypes( dictionaryType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1180,6 +1228,7 @@ private static void DefineIDictionaryTypes( dictionaryType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition dictionaryComWrappersMarshallerType); @@ -1188,6 +1237,7 @@ private static void DefineIDictionaryTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: dictionaryComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1205,6 +1255,7 @@ private static void DefineIDictionaryTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: dictionaryComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1248,6 +1299,7 @@ private static void DefineKeyValuePairTypes( try { InteropTypeDefinitionBuilder.KeyValuePair.Methods( + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, methodsType: out methodsType); @@ -1302,6 +1354,7 @@ private static void DefineKeyValuePairTypes( get_IidMethod: get_IidMethod, keyAccessorMethod: keyAccessorMethod, valueAccessorMethod: valueAccessorMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1320,6 +1373,7 @@ private static void DefineKeyValuePairTypes( InteropTypeDefinitionBuilder.KeyValuePair.Proxy( keyValuePairType: typeSignature, comWrappersMarshallerAttributeType: marshallerAttributeType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1388,6 +1442,7 @@ private static void DefineIMapChangedEventArgsTypes( InteropTypeDefinitionBuilder.IMapChangedEventArgs1.NativeObject( argsType: typeSignature, argsMethodsType: argsMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition nativeObjectType); @@ -1396,6 +1451,7 @@ private static void DefineIMapChangedEventArgsTypes( argsType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1405,6 +1461,7 @@ private static void DefineIMapChangedEventArgsTypes( argsType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition argsComWrappersMarshallerType); @@ -1413,6 +1470,7 @@ private static void DefineIMapChangedEventArgsTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: argsComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1430,6 +1488,7 @@ private static void DefineIMapChangedEventArgsTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: argsComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1490,6 +1549,7 @@ private static void DefineIObservableVectorTypes( InteropTypeDefinitionBuilder.IObservableVector1.EventSourceFactory( vectorType: typeSignature, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1497,6 +1557,7 @@ private static void DefineIObservableVectorTypes( InteropTypeDefinitionBuilder.IObservableVector1.EventSourceCallback( vectorType: typeSignature, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1505,6 +1566,7 @@ private static void DefineIObservableVectorTypes( InteropTypeDefinitionBuilder.IObservableVector1.Methods( vectorType: typeSignature, eventSourceCallbackType: callbackType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, methodsType: out TypeDefinition methodsType); @@ -1512,6 +1574,7 @@ private static void DefineIObservableVectorTypes( InteropTypeDefinitionBuilder.IObservableVector1.NativeObject( vectorType: typeSignature, factoryType: factoryType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1521,6 +1584,7 @@ private static void DefineIObservableVectorTypes( vectorType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1530,6 +1594,7 @@ private static void DefineIObservableVectorTypes( vectorType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition comWrappersMarshallerType); @@ -1538,6 +1603,7 @@ private static void DefineIObservableVectorTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: comWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1555,6 +1621,7 @@ private static void DefineIObservableVectorTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: comWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1615,6 +1682,7 @@ private static void DefineIObservableMapTypes( InteropTypeDefinitionBuilder.IObservableMap2.EventSourceFactory( mapType: typeSignature, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1622,6 +1690,7 @@ private static void DefineIObservableMapTypes( InteropTypeDefinitionBuilder.IObservableMap2.EventSourceCallback( mapType: typeSignature, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1630,6 +1699,7 @@ private static void DefineIObservableMapTypes( InteropTypeDefinitionBuilder.IObservableMap2.Methods( mapType: typeSignature, eventSourceCallbackType: callbackType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, methodsType: out TypeDefinition methodsType); @@ -1637,6 +1707,7 @@ private static void DefineIObservableMapTypes( InteropTypeDefinitionBuilder.IObservableMap2.NativeObject( mapType: typeSignature, factoryType: factoryType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1646,6 +1717,7 @@ private static void DefineIObservableMapTypes( mapType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1655,6 +1727,7 @@ private static void DefineIObservableMapTypes( mapType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition comWrappersMarshallerType); @@ -1663,6 +1736,7 @@ private static void DefineIObservableMapTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: comWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1680,6 +1754,7 @@ private static void DefineIObservableMapTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: comWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1749,6 +1824,7 @@ private static void DefineIAsyncActionWithProgressTypes( InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.NativeObject( actionType: typeSignature, actionMethodsType: actionMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition nativeObjectType); @@ -1757,6 +1833,7 @@ private static void DefineIAsyncActionWithProgressTypes( actionType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1766,6 +1843,7 @@ private static void DefineIAsyncActionWithProgressTypes( actionType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition actionComWrappersMarshallerType); @@ -1774,6 +1852,7 @@ private static void DefineIAsyncActionWithProgressTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: actionComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1791,6 +1870,7 @@ private static void DefineIAsyncActionWithProgressTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: actionComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1860,6 +1940,7 @@ private static void DefineIAsyncOperationTypes( InteropTypeDefinitionBuilder.IAsyncOperation1.NativeObject( operationType: typeSignature, operationMethodsType: operationMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition nativeObjectType); @@ -1868,6 +1949,7 @@ private static void DefineIAsyncOperationTypes( operationType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1877,6 +1959,7 @@ private static void DefineIAsyncOperationTypes( operationType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition operationComWrappersMarshallerType); @@ -1885,6 +1968,7 @@ private static void DefineIAsyncOperationTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: operationComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -1902,6 +1986,7 @@ private static void DefineIAsyncOperationTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: operationComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1971,6 +2056,7 @@ private static void DefineIAsyncOperationWithProgressTypes( InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.NativeObject( operationType: typeSignature, operationMethodsType: operationMethodsType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition nativeObjectType); @@ -1979,6 +2065,7 @@ private static void DefineIAsyncOperationWithProgressTypes( operationType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -1988,6 +2075,7 @@ private static void DefineIAsyncOperationWithProgressTypes( operationType: typeSignature, nativeObjectType: nativeObjectType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition operationComWrappersMarshallerType); @@ -1996,6 +2084,7 @@ private static void DefineIAsyncOperationWithProgressTypes( typeSignature: typeSignature, interfaceComWrappersCallbackType: operationComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -2013,6 +2102,7 @@ private static void DefineIAsyncOperationWithProgressTypes( InteropTypeDefinitionBuilder.Proxy( interfaceType: typeSignature, comWrappersMarshallerAttributeType: operationComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -2039,12 +2129,14 @@ private static void DefineIAsyncOperationWithProgressTypes( /// /// /// The emit state for this invocation. + /// The instance to use. /// The instance to use. /// The interop module being built. private static void DefineIReadOnlyCollectionKeyValuePair2Types( InteropGeneratorArgs args, InteropGeneratorDiscoveryState discoveryState, InteropGeneratorEmitState emitState, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module) { @@ -2065,6 +2157,7 @@ private static void DefineIReadOnlyCollectionKeyValuePair2Types( { InteropTypeDefinitionBuilder.IReadOnlyCollectionKeyValuePair2.ForwarderAttribute( readOnlyCollectionType: readOnlyCollectionType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, forwarderAttributeType: out TypeDefinition forwarderAttributeType); @@ -2072,6 +2165,7 @@ private static void DefineIReadOnlyCollectionKeyValuePair2Types( InteropTypeDefinitionBuilder.IReadOnlyCollectionKeyValuePair2.InterfaceImpl( readOnlyCollectionType: readOnlyCollectionType, forwarderAttributeType: forwarderAttributeType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -2096,12 +2190,14 @@ private static void DefineIReadOnlyCollectionKeyValuePair2Types( /// /// /// The emit state for this invocation. + /// The instance to use. /// The instance to use. /// The interop module being built. private static void DefineICollectionKeyValuePair2Types( InteropGeneratorArgs args, InteropGeneratorDiscoveryState discoveryState, InteropGeneratorEmitState emitState, + InteropDefinitions interopDefinitions, InteropReferences interopReferences, ModuleDefinition module) { @@ -2122,6 +2218,7 @@ private static void DefineICollectionKeyValuePair2Types( { InteropTypeDefinitionBuilder.ICollectionKeyValuePair2.ForwarderAttribute( collectionType: collectionType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, forwarderAttributeType: out TypeDefinition forwarderAttributeType); @@ -2129,6 +2226,7 @@ private static void DefineICollectionKeyValuePair2Types( InteropTypeDefinitionBuilder.ICollectionKeyValuePair2.InterfaceImpl( collectionType: collectionType, forwarderAttributeType: forwarderAttributeType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -2179,6 +2277,7 @@ private static void DefineSzArrayTypes( InteropTypeDefinitionBuilder.SzArray.Marshaller( arrayType: typeSignature, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, emitState: emitState, module: module, @@ -2187,6 +2286,7 @@ private static void DefineSzArrayTypes( InteropTypeDefinitionBuilder.SzArray.ComWrappersCallback( arrayType: typeSignature, marshallerType: marshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition arrayComWrappersCallbackType); @@ -2218,6 +2318,7 @@ private static void DefineSzArrayTypes( arrayInterfaceEntriesImplType: arrayInterfaceEntriesImplType, arrayComWrappersCallbackType: arrayComWrappersCallbackType, get_IidMethod: get_IidMethod, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition arrayComWrappersMarshallerType); @@ -2225,6 +2326,7 @@ private static void DefineSzArrayTypes( InteropTypeDefinitionBuilder.SzArray.Proxy( arrayType: typeSignature, comWrappersMarshallerAttributeType: arrayComWrappersMarshallerType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -2442,6 +2544,7 @@ private static void DefineUserDefinedTypes( userDefinedType: typeSignature, interfaceEntriesType: interfaceEntriesType, interfaceEntriesImplType: interfaceEntriesImplType, + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, out TypeDefinition comWrappersMarshallerType); @@ -2465,6 +2568,7 @@ private static void DefineUserDefinedTypes( InteropTypeDefinitionBuilder.UserDefinedType.Proxy( userDefinedType: typeSignature, comWrappersMarshallerAttributeType: marshallerAttributeMap[vtableTypes], + interopDefinitions: interopDefinitions, interopReferences: interopReferences, module: module, useWindowsUIXamlProjections: args.UseWindowsUIXamlProjections, @@ -2647,4 +2751,4 @@ private static void WriteInteropModuleToDisk(InteropGeneratorArgs args, ModuleDe WellKnownInteropExceptions.EmitDllError(e).ThrowOrAttach(e); } } -} \ No newline at end of file +} diff --git a/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.cs b/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.cs index d790a5e6ae..e01c9a9b0a 100644 --- a/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.cs +++ b/src/WinRT.Interop.Generator/Helpers/SignatureGenerator.cs @@ -163,15 +163,8 @@ private static bool TryGetIIDFromAttribute( // These are only needed to generate signatures, so we hide them from the reference assemblies, as they're not useful there. if (type.IsDelegate) { - // Determine the right implementation projection .dll to use for the lookup - ModuleDefinition? projectionModule = type.IsProjectedWindowsSdkType - ? interopDefinitions.WindowsRuntimeSdkProjectionModule - : type.IsProjectedWindowsSdkXamlType - ? interopDefinitions.WindowsRuntimeSdkXamlProjectionModule - : interopDefinitions.WindowsRuntimeProjectionModule; - // Try to get the implementation type via a fast lookup, if we did get a valid projection module - if (projectionModule?.GetTopLevelTypesLookup().TryGetValue((type.Namespace, type.Name), out TypeDefinition? projectedType) is true) + if (type.GetImplementationProjectionModule(interopDefinitions)?.GetTopLevelTypesLookup().TryGetValue((type.Namespace, type.Name), out TypeDefinition? projectedType) is true) { return projectedType.TryGetGuidAttribute(interopReferences, out iid); } @@ -205,11 +198,7 @@ private static bool TryGetDefaultInterfaceFromAttribute( [NotNullWhen(true)] out TypeSignature? defaultInterface) { // Determine the right implementation projection .dll (see notes above) - ModuleDefinition? projectionModule = type.IsProjectedWindowsSdkType - ? interopDefinitions.WindowsRuntimeSdkProjectionModule - : type.IsProjectedWindowsSdkXamlType - ? interopDefinitions.WindowsRuntimeSdkXamlProjectionModule - : interopDefinitions.WindowsRuntimeProjectionModule; + ModuleDefinition? projectionModule = type.GetImplementationProjectionModule(interopDefinitions); // Use the cached default interfaces lookup for O(1) lookups by (Namespace, Name) key if (projectionModule?.GetDefaultInterfacesLookup().TryGetValue((type.Namespace, type.Name), out TypeSignature? signature) is true) diff --git a/src/WinRT.Interop.Generator/References/InteropDefinitions.cs b/src/WinRT.Interop.Generator/References/InteropDefinitions.cs index 3fb8dd5c3c..b105b96121 100644 --- a/src/WinRT.Interop.Generator/References/InteropDefinitions.cs +++ b/src/WinRT.Interop.Generator/References/InteropDefinitions.cs @@ -53,6 +53,11 @@ public InteropDefinitions( WindowsRuntimeComponentModule = windowsRuntimeComponentModule; } + /// + /// Gets the currently in use. + /// + public RuntimeContext RuntimeContext => _interopReferences.RuntimeContext; + /// /// Gets the for the Windows Runtime projection assembly for the Windows SDK (i.e. WinRT.Sdk.Projection.dll). /// diff --git a/src/WinRT.Interop.Generator/Resolvers/InteropImplTypeResolver.cs b/src/WinRT.Interop.Generator/Resolvers/InteropImplTypeResolver.cs index 1e6dd29662..4f74e7567f 100644 --- a/src/WinRT.Interop.Generator/Resolvers/InteropImplTypeResolver.cs +++ b/src/WinRT.Interop.Generator/Resolvers/InteropImplTypeResolver.cs @@ -21,13 +21,11 @@ internal static class InteropImplTypeResolver /// /// The type to get the "Impl" method for. /// The instance to use. - /// The instance to use. /// The emit state for this invocation. /// The "Impl" methods for . public static (IMethodDefOrRef get_IID, IMethodDefOrRef get_Vtable) GetGenericInstanceTypeImpl( GenericInstanceTypeSignature type, InteropDefinitions interopDefinitions, - InteropReferences interopReferences, InteropGeneratorEmitState emitState) { // For generic types (i.e. generic interfaces), their marshalling code will be in 'WinRT.Interop.dll', @@ -36,7 +34,7 @@ public static (IMethodDefOrRef get_IID, IMethodDefOrRef get_Vtable) GetGenericIn MethodDefinition get_VtableMethod = implTypeDefinition.GetMethod("get_Vtable"u8); // The IID will be in the generated 'ABI.InterfaceIIDs' type in 'WinRT.Interop.dll' - Utf8String get_IIDMethodName = $"get_IID_{InteropUtf8NameFactory.TypeName(type, interopReferences.RuntimeContext)}"; + Utf8String get_IIDMethodName = $"get_IID_{InteropUtf8NameFactory.TypeName(type, interopDefinitions)}"; MethodDefinition get_IIDMethod = interopDefinitions.InterfaceIIDs.GetMethod(get_IIDMethodName); // Return the pair of methods from the ABI type in 'WinRT.Interop.dll' diff --git a/src/WinRT.Interop.Generator/Resolvers/InteropInterfaceEntriesResolver.cs b/src/WinRT.Interop.Generator/Resolvers/InteropInterfaceEntriesResolver.cs index 0de717e4f6..3925921064 100644 --- a/src/WinRT.Interop.Generator/Resolvers/InteropInterfaceEntriesResolver.cs +++ b/src/WinRT.Interop.Generator/Resolvers/InteropInterfaceEntriesResolver.cs @@ -60,7 +60,6 @@ public static IEnumerable EnumerateMetadataInterfaceE (IMethodDefOrRef get_IIDMethod, IMethodDefOrRef get_VtableMethod) = InteropImplTypeResolver.GetGenericInstanceTypeImpl( type: genericTypeSignature, interopDefinitions: interopDefinitions, - interopReferences: interopReferences, emitState: emitState); yield return new WindowsRuntimeInterfaceEntryInfo(get_IIDMethod, get_VtableMethod); @@ -113,7 +112,9 @@ public static IEnumerable EnumerateMetadataInterfaceE // Handle the common case for all normally projected, non-generic Windows Runtime interface types. For those, all the // interop code will just live in the 'WinRT.Projection.dll' assembly, with all projected types for the application domain. - if (interfaceType.IsProjectedWindowsRuntimeType) + // The interface is recognized either by its '[WindowsRuntimeMetadata]' attribute (implementation projections) or by being + // defined in a reference projection assembly (reference projections don't carry that per-type attribute). + if (interfaceType.IsProjectedWindowsRuntimeType || interfaceType.IsReferenceProjectionWindowsRuntimeType) { (IMethodDefOrRef get_IIDMethod, IMethodDefOrRef get_VtableMethod) = InteropImplTypeResolver.GetProjectedTypeImpl( type: interfaceType, diff --git a/src/WinRT.Projection.Writer/Builders/ProjectionFileBuilder.cs b/src/WinRT.Projection.Writer/Builders/ProjectionFileBuilder.cs index 44c4c8faa6..5bc218b1a1 100644 --- a/src/WinRT.Projection.Writer/Builders/ProjectionFileBuilder.cs +++ b/src/WinRT.Projection.Writer/Builders/ProjectionFileBuilder.cs @@ -94,7 +94,7 @@ private static void WriteEnum(IndentedTextWriter writer, ProjectionEmitContext c string enumUnderlyingType = isFlags ? "uint" : "int"; string typeName = type.GetRawName(); - IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(type, context.Cache); + IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(context, type); IndentedTextWriterCallback valueTypeAttr = MetadataAttributeFactory.WriteValueTypeWinRTClassNameAttribute(context, type); IndentedTextWriterCallback customAttrs = CustomAttributeFactory.WriteTypeCustomAttributes(context, type, true); IndentedTextWriterCallback comWrappersAttr = MetadataAttributeFactory.WriteComWrapperMarshallerAttribute(context, type); @@ -174,7 +174,7 @@ private static void WriteStruct(IndentedTextWriter writer, ProjectionEmitContext string projectionName = type.GetRawName(); // Header attributes + struct declaration as a single multiline template. - IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(type, context.Cache); + IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(context, type); IndentedTextWriterCallback valueTypeAttr = MetadataAttributeFactory.WriteValueTypeWinRTClassNameAttribute(context, type); IndentedTextWriterCallback customAttrs = CustomAttributeFactory.WriteTypeCustomAttributes(context, type, true); IndentedTextWriterCallback comWrappersAttr = MetadataAttributeFactory.WriteComWrapperMarshallerAttribute(context, type); @@ -321,7 +321,7 @@ private static void WriteDelegate(IndentedTextWriter writer, ProjectionEmitConte MethodSignatureInfo sig = new(invoke); - IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(type, context.Cache); + IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(context, type); IndentedTextWriterCallback customAttrs = CustomAttributeFactory.WriteTypeCustomAttributes(context, type, false); IndentedTextWriterCallback comWrappersAttr = MetadataAttributeFactory.WriteComWrapperMarshallerAttribute(context, type); string guidAttr = context.Settings.ReferenceProjection @@ -349,7 +349,7 @@ private static void WriteAttribute(IndentedTextWriter writer, ProjectionEmitCont { string typeName = type.GetRawName(); - IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(type, context.Cache); + IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(context, type); IndentedTextWriterCallback customAttrs = CustomAttributeFactory.WriteTypeCustomAttributes(context, type, true); writer.WriteLine(); diff --git a/src/WinRT.Projection.Writer/Extensions/ProjectionWriterExtensions.cs b/src/WinRT.Projection.Writer/Extensions/ProjectionWriterExtensions.cs index 1f04dbaf7a..860263526c 100644 --- a/src/WinRT.Projection.Writer/Extensions/ProjectionWriterExtensions.cs +++ b/src/WinRT.Projection.Writer/Extensions/ProjectionWriterExtensions.cs @@ -51,6 +51,7 @@ public void WriteFileHeader(ProjectionEmitContext context) #pragma warning disable CS0649 // "Field '...' is never assigned to" #pragma warning disable CA2207, CA1063, CA1033, CA1001, CA2213 #pragma warning disable CSWINRT3001 // "Type or member '...' is a private implementation detail" + #pragma warning disable CSWINRT3002 // "Type '...' is a private implementation detail" #pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type """); diff --git a/src/WinRT.Projection.Writer/Factories/ClassFactory.cs b/src/WinRT.Projection.Writer/Factories/ClassFactory.cs index c2b5d789c4..1aff3fdc8d 100644 --- a/src/WinRT.Projection.Writer/Factories/ClassFactory.cs +++ b/src/WinRT.Projection.Writer/Factories/ClassFactory.cs @@ -226,7 +226,7 @@ public static void WriteStaticClass(IndentedTextWriter writer, ProjectionEmitCon { using (context.EnterPlatformSuppressionScope(string.Empty)) { - IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(type, context.Cache); + IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(context, type); IndentedTextWriterCallback customAttrs = CustomAttributeFactory.WriteTypeCustomAttributes(context, type, true); IndentedTextWriterCallback name = TypedefNameWriter.WriteTypedefNameWithTypeParams(context, type, TypedefNameType.Projected, false); writer.WriteLine(isMultiline: true, $$""" @@ -453,31 +453,32 @@ public static event {{eventType}} {{evtName}} /// internal static void WriteStaticFactoryObjRef(IndentedTextWriter writer, ProjectionEmitContext context, TypeDefinition staticIface, string runtimeClassFullName, string objRefName) { - writer.WriteLine(); - + // The static factory '_objRef_*' field is a private implementation detail typed as the + // implementation-only 'WindowsRuntimeObjectReference', so it is omitted from reference + // projections (which compile against the stripped 'WinRT.Runtime' reference assembly). if (context.Settings.ReferenceProjection) { - writer.WriteLine($"private static WindowsRuntimeObjectReference {objRefName} => throw null;"); + return; } - else - { - IndentedTextWriterCallback iid = ObjRefNameGenerator.WriteIidExpression(context, staticIface); - writer.WriteLine(isMultiline: true, $$""" - private static WindowsRuntimeObjectReference {{objRefName}} + writer.WriteLine(); + + IndentedTextWriterCallback iid = ObjRefNameGenerator.WriteIidExpression(context, staticIface); + + writer.WriteLine(isMultiline: true, $$""" + private static WindowsRuntimeObjectReference {{objRefName}} + { + get { - get + var __{{objRefName}} = field; + if (__{{objRefName}} != null && __{{objRefName}}.IsInCurrentContext) { - var __{{objRefName}} = field; - if (__{{objRefName}} != null && __{{objRefName}}.IsInCurrentContext) - { - return __{{objRefName}}; - } - return field = WindowsRuntimeObjectReference.GetActivationFactory("{{runtimeClassFullName}}", {{iid}}); + return __{{objRefName}}; } + return field = WindowsRuntimeObjectReference.GetActivationFactory("{{runtimeClassFullName}}", {{iid}}); } - """); - } + } + """); } /// @@ -510,7 +511,7 @@ private static void WriteClassCore(IndentedTextWriter writer, ProjectionEmitCont int gcPressure = GetGcPressureAmount(type); // Header attributes + class declaration as a single multiline template. - IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(type, context.Cache); + IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(context, type); IndentedTextWriterCallback customAttrs = CustomAttributeFactory.WriteTypeCustomAttributes(context, type, true); IndentedTextWriterCallback comWrappersAttr = MetadataAttributeFactory.WriteComWrapperMarshallerAttribute(context, type); @@ -577,35 +578,42 @@ void WriteCtorBody(IndentedTextWriter writer) } else { - // In ref mode, if WriteAttributedTypes will not emit any public constructors, - // we need a 'private TypeName() { throw null; }' to suppress the C# compiler's - // implicit public default constructor (which would expose an unintended API). - // either: - // - factory.activatable is true (parameterless or parameterized — Activatable - // always emits at least one ctor), OR - // - factory.composable && factory.type && factory.type.MethodList().size() > 0 - // (composable factories with NO methods don't emit any ctors). - bool hasRefModeCtors = false; - foreach (KeyValuePair kv in AttributedTypes.Get(type, context.Cache)) + // In ref mode, a synthetic non-public parameterless ctor is emitted in two situations: + // + // 1. To suppress the C# compiler's implicit public default constructor (which would expose + // an unintended API) when 'WriteAttributedTypes' emits no constructors at all. + // 2. To give derived projected classes a base-chain target. A derived class's ref-mode ctor + // implicitly calls 'base()', but the real 'WindowsRuntimeObjectReference'-based base ctor + // is not emitted in ref mode, so an unsealed class must expose an accessible parameterless + // ctor unless it already emits a public one (a default '[Activatable]', or a factory / + // composable method with no user parameters). + // + // Sealed classes can never be a base, so they only need case 1; unsealed classes need a + // parameterless ctor whenever they don't already emit one (which also covers case 1). + if (type.IsSealed) { - AttributedType factory = kv.Value; - - if (factory.Activatable) + bool hasRefModeCtors = false; + foreach (KeyValuePair kv in AttributedTypes.Get(type, context.Cache)) { - hasRefModeCtors = true; - break; + AttributedType factory = kv.Value; + + // Activatable always emits at least one ctor; a composable factory only emits ctors + // when it has methods (a composable factory with no methods emits none). + if (factory.Activatable || (factory.Composable && factory.Type is not null && factory.Type.Methods.Count > 0)) + { + hasRefModeCtors = true; + break; + } } - if (factory.Composable && factory.Type is not null && factory.Type.Methods.Count > 0) + if (!hasRefModeCtors) { - hasRefModeCtors = true; - break; + RefModeStubFactory.EmitSyntheticPrivateCtor(writer, typeName, isSealed: true); } } - - if (!hasRefModeCtors) + else if (!ConstructorFactory.EmitsParameterlessConstructor(type, context.Cache)) { - RefModeStubFactory.EmitSyntheticPrivateCtor(writer, typeName); + RefModeStubFactory.EmitSyntheticPrivateCtor(writer, typeName, isSealed: false); } } diff --git a/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteClassMembers.cs b/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteClassMembers.cs index 900167fbb1..6442a5120f 100644 --- a/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteClassMembers.cs +++ b/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteClassMembers.cs @@ -40,7 +40,9 @@ public static void WriteClassMembers(IndentedTextWriter writer, ProjectionEmitCo // For generic-interface properties, emit the UnsafeAccessor static externs above the // property declaration. Note: getter and setter use the same accessor name (because // C# allows method overloading on parameter list for the static externs). - if (s.HasGetter && s.GetterIsGeneric && !string.IsNullOrEmpty(s.GetterGenericInteropType)) + // These externs are impl-only plumbing for the accessor bodies; in ref mode the bodies + // are 'throw null' so the externs (which reference 'WindowsRuntimeObjectReference') are omitted. + if (!context.Settings.ReferenceProjection && s.HasGetter && s.GetterIsGeneric && !string.IsNullOrEmpty(s.GetterGenericInteropType)) { writer.WriteLine(); UnsafeAccessorFactory.EmitStaticMethod( @@ -52,7 +54,7 @@ public static void WriteClassMembers(IndentedTextWriter writer, ProjectionEmitCo parameterList: "WindowsRuntimeObjectReference thisReference"); } - if (s.HasSetter && s.SetterIsGeneric && !string.IsNullOrEmpty(s.SetterGenericInteropType)) + if (!context.Settings.ReferenceProjection && s.HasSetter && s.SetterIsGeneric && !string.IsNullOrEmpty(s.SetterGenericInteropType)) { writer.WriteLine(); UnsafeAccessorFactory.EmitStaticMethod( diff --git a/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteInterfaceMembers.cs b/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteInterfaceMembers.cs index efd44d6aff..b4c7a0f846 100644 --- a/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteInterfaceMembers.cs +++ b/src/WinRT.Projection.Writer/Factories/ClassMembersFactory.WriteInterfaceMembers.cs @@ -19,9 +19,16 @@ namespace WindowsRuntime.ProjectionWriter.Factories; internal static partial class ClassMembersFactory { - private static void WriteInterfaceMembersRecursive(IndentedTextWriter writer, ProjectionEmitContext context, TypeDefinition classType, TypeDefinition declaringType, + private static void WriteInterfaceMembersRecursive( + IndentedTextWriter writer, + ProjectionEmitContext context, + TypeDefinition classType, + TypeDefinition declaringType, GenericInstanceTypeSignature? currentInstance, - HashSet writtenMethods, IDictionary propertyState, HashSet writtenEvents, HashSet writtenInterfaces) + HashSet writtenMethods, + IDictionary propertyState, + HashSet writtenEvents, + HashSet writtenInterfaces) { GenericContext genericContext = new(currentInstance, null); @@ -84,14 +91,14 @@ private static void WriteInterfaceMembersRecursive(IndentedTextWriter writer, Pr } // Emit GetInterface() / GetDefaultInterface() impl for this interface BEFORE its - // members. For - // overridable interfaces or non-exclusive direct interfaces, emit + // members. For overridable interfaces or non-exclusive direct interfaces, emit // IWindowsRuntimeInterface.GetInterface(). For the default interface on an // unsealed class with an exclusive default, emit "internal new GetDefaultInterface()". - // The IWindowsRuntimeInterface markers are NOT emitted in ref mode (gated by - // !context.Settings.ReferenceProjection here). The 'internal new - // GetDefaultInterface()' helper IS emitted in both modes since it's referenced by - // overrides on derived classes. + // Both helpers are implementation-only: they return 'WindowsRuntimeObjectReferenceValue' + // (which is stripped from the 'WinRT.Runtime' reference assembly), and are only ever + // called from the ABI marshallers (which are themselves implementation-only and not + // emitted in ref mode). They are therefore gated off in reference-projection mode, where + // they would otherwise be dead code that fails to compile against the reference assembly. if (IsInterfaceInInheritanceList(context.Cache, impl, includeExclusiveInterface: false) && !context.Settings.ReferenceProjection) { string giObjRefName = ObjRefNameGenerator.GetObjRefName(context, substitutedInterface); @@ -104,15 +111,15 @@ private static void WriteInterfaceMembersRecursive(IndentedTextWriter writer, Pr } """); } - else if (impl.IsDefaultInterface() && !classType.IsSealed) + else if (impl.IsDefaultInterface() && !classType.IsSealed && !context.Settings.ReferenceProjection) { // 'internal new GetDefaultInterface()' helper whenever the interface is the // default interface and the class is unsealed -- regardless of exclusive-to - // status. In ref-projection mode this is the only branch that emits the helper - // (the prior 'IWindowsRuntimeInterface.GetInterface' branch is gated off). - // In non-ref mode this branch is only reached when the prior branch's + // status. This branch is only reached when the prior branch's // IsInterfaceInInheritanceList check fails (i.e., ExclusiveTo default interfaces), - // because non-exclusive default interfaces are routed to the prior branch. + // because non-exclusive default interfaces are routed to the prior branch. Like the + // prior branch, this helper is implementation-only (see above), so it is gated off + // in reference-projection mode. string giObjRefName = ObjRefNameGenerator.GetObjRefName(context, substitutedInterface); bool hasBaseType = false; @@ -238,10 +245,10 @@ private static void WriteInterfaceMembers(IndentedTextWriter writer, ProjectionE genericInteropType = InteropTypeNameWriter.GetInteropAssemblyQualifiedName(currentInstance, TypedefNameType.StaticAbiClass); } - // Compute the platform attribute string from the interface type's [ContractVersion] + // Compute the platform attribute string from the interface type's '[ContractVersion]' // attribute. In ref mode, this is prepended to each member emission so the projected - // class members carry [SupportedOSPlatform("WindowsX.Y.Z.0")] mirroring the interface's - // contract version. Only emitted in ref mode (WritePlatformAttribute internally returns + // class members carry '[SupportedOSPlatform("WindowsX.Y.Z.0")]' mirroring the interface's + // contract version. Only emitted in ref mode ('WritePlatformAttribute' internally returns // immediately if not ref) string platformAttribute = CustomAttributeFactory.GetPlatformAttribute(context, ifaceType); @@ -251,7 +258,7 @@ private static void WriteInterfaceMembers(IndentedTextWriter writer, ProjectionE string name = method.GetRawName(); // Track by full signature (name + each param's element-type code) to avoid trivial overload duplicates. - // This prevents collapsing distinct overloads like Format(double) and Format(ulong). + // This prevents collapsing distinct overloads like 'Format(double)' and 'Format(ulong)'. MethodSignatureInfo sig = new(method, genericContext); string key = sig.GetDedupeKey(name); @@ -309,13 +316,21 @@ private static void WriteInterfaceMembers(IndentedTextWriter writer, ProjectionE string platformTrimmed = platformAttribute.TrimEnd('\r', '\n'); writer.WriteLine(); - UnsafeAccessorFactory.EmitStaticMethod( - writer, - accessName: name, - returnType: unsafeRet.Format(), - functionName: accessorName, - interopType: genericInteropType, - parameterList: $"WindowsRuntimeObjectReference thisReference{accessorParams}"); + + // The '[UnsafeAccessor]' extern is impl-only plumbing for the dispatch body; in ref mode + // the body is 'throw null' (see 'body' above), so the extern (which references the + // implementation-only 'WindowsRuntimeObjectReference') is omitted. + if (!context.Settings.ReferenceProjection) + { + UnsafeAccessorFactory.EmitStaticMethod( + writer, + accessName: name, + returnType: unsafeRet.Format(), + functionName: accessorName, + interopType: genericInteropType, + parameterList: $"WindowsRuntimeObjectReference thisReference{accessorParams}"); + } + writer.WriteLine(isMultiline: true, $$""" {{platformTrimmed}} {{access}}{{methodSpecForThis}}{{ret}} {{name}}({{parms}}) => {{body}} diff --git a/src/WinRT.Projection.Writer/Factories/ConstructorFactory.AttributedTypes.cs b/src/WinRT.Projection.Writer/Factories/ConstructorFactory.AttributedTypes.cs index 1694c6611d..72d2093c89 100644 --- a/src/WinRT.Projection.Writer/Factories/ConstructorFactory.AttributedTypes.cs +++ b/src/WinRT.Projection.Writer/Factories/ConstructorFactory.AttributedTypes.cs @@ -6,6 +6,7 @@ using AsmResolver.DotNet; using WindowsRuntime.ProjectionWriter.Generation; using WindowsRuntime.ProjectionWriter.Helpers; +using WindowsRuntime.ProjectionWriter.Metadata; using WindowsRuntime.ProjectionWriter.Models; using WindowsRuntime.ProjectionWriter.Writers; using static WindowsRuntime.ProjectionWriter.References.ProjectionNames; @@ -34,35 +35,29 @@ public static void WriteAttributedTypes(IndentedTextWriter writer, ProjectionEmi } } - if (needsClassObjRef) + // The activation factory '_objRef_*' field is a private implementation detail typed as the + // implementation-only 'WindowsRuntimeObjectReference', so it is omitted from reference projections + // (which compile against the stripped 'WinRT.Runtime' reference assembly). + if (needsClassObjRef && !context.Settings.ReferenceProjection) { string fullName = classType.FullName ?? string.Empty; string objRefName = "_objRef_" + IidExpressionGenerator.EscapeTypeNameForIdentifier(GlobalPrefix + fullName, stripGlobal: true); writer.WriteLine(); writer.Write($"private static WindowsRuntimeObjectReference {objRefName}"); - - if (context.Settings.ReferenceProjection) - { - // in ref mode the activation factory objref getter body is just 'throw null;'. - RefModeStubFactory.EmitRefModeObjRefGetterBody(writer); - } - else - { - writer.WriteLine(); - writer.WriteLine(isMultiline: true, $$""" + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $$""" + { + get { - get + var __{{objRefName}} = field; + if (__{{objRefName}} != null && __{{objRefName}}.IsInCurrentContext) { - var __{{objRefName}} = field; - if (__{{objRefName}} != null && __{{objRefName}}.IsInCurrentContext) - { - return __{{objRefName}}; - } - return field = WindowsRuntimeObjectReference.GetActivationFactory("{{fullName}}"); + return __{{objRefName}}; } + return field = WindowsRuntimeObjectReference.GetActivationFactory("{{fullName}}"); } - """); - } + } + """); } foreach (KeyValuePair kv in AttributedTypes.Get(classType, context.Cache)) @@ -122,6 +117,18 @@ public static void WriteFactoryConstructors(IndentedTextWriter writer, Projectio writer.Write($"public unsafe {typeName}("); MethodFactory.WriteParameterList(writer, context, sig); + + // In ref mode the constructor keeps its public signature but gets a 'throw null' body, + // and the args struct + factory callback class below are skipped (they are private + // implementation details referencing implementation-only 'WinRT.Runtime' types). + if (context.Settings.ReferenceProjection) + { + RefModeStubFactory.EmitRefModeConstructorBody(writer); + methodIndex++; + + continue; + } + writer.Write(isMultiline: true, """ ) :base( @@ -165,9 +172,20 @@ public static void WriteFactoryConstructors(IndentedTextWriter writer, Projectio } else { - // No factory type means [Activatable(uint version)] - emit a default ctor that calls - // the WindowsRuntimeObject base constructor with the activation factory objref. - // The default interface IID is needed too. + // No factory type means '[Activatable(uint version)]', emit a parameterless default ctor + if (context.Settings.ReferenceProjection) + { + // Ref mode keeps the public signature with a 'throw null' body (the impl-mode body + // calls the base ctor with implementation-only activation types). + writer.WriteLine(); + writer.Write($"public {typeName}("); + RefModeStubFactory.EmitRefModeConstructorBody(writer); + + return; + } + + // The impl-mode default ctor calls the 'WindowsRuntimeObject' base constructor with + // the activation factory object reference. The default interface IID is needed too. string fullName = classType.FullName ?? string.Empty; string objRefName = "_objRef_" + IidExpressionGenerator.EscapeTypeNameForIdentifier(GlobalPrefix + fullName, stripGlobal: true); @@ -188,4 +206,59 @@ public static void WriteFactoryConstructors(IndentedTextWriter writer, Projectio writer.WriteLine("}"); } } + + /// + /// Determines whether emits at least one parameterless public + /// constructor for the given runtime class (a default [Activatable] ctor, an activation-factory + /// method with no parameters, or a composable-factory method with no user parameters). + /// + /// + /// Used in reference-projection mode to decide whether an unsealed class already exposes a + /// parameterless constructor that derived projected classes can chain to, or whether a synthetic + /// non-public one must be emitted (see ). + /// + public static bool EmitsParameterlessConstructor(TypeDefinition classType, MetadataCache cache) + { + foreach (KeyValuePair kv in AttributedTypes.Get(classType, cache)) + { + AttributedType factory = kv.Value; + + // A default '[Activatable(uint version)]' (no factory interface) emits 'public TypeName()'. + if (factory.Activatable && factory.Type is null) + { + return true; + } + + if (factory.Type is null) + { + continue; + } + + // An activation- or composable-factory method emits a parameterless ctor when it has no user + // parameters. Composable factory methods carry two trailing ABI parameters (the base and inner + // interfaces) that are not surfaced on the projected constructor, so they are excluded. + if (factory.Activatable || factory.Composable) + { + foreach (MethodDefinition method in factory.Type.Methods) + { + if (method.IsSpecial) + { + continue; + } + + MethodSignatureInfo sig = new(method); + int userParamCount = factory.Composable && sig.Parameters.Count >= 2 + ? sig.Parameters.Count - 2 + : sig.Parameters.Count; + + if (userParamCount == 0) + { + return true; + } + } + } + } + + return false; + } } diff --git a/src/WinRT.Projection.Writer/Factories/ConstructorFactory.Composable.cs b/src/WinRT.Projection.Writer/Factories/ConstructorFactory.Composable.cs index 002fa51c65..20eb77b554 100644 --- a/src/WinRT.Projection.Writer/Factories/ConstructorFactory.Composable.cs +++ b/src/WinRT.Projection.Writer/Factories/ConstructorFactory.Composable.cs @@ -92,6 +92,17 @@ public static void WriteComposableConstructors(IndentedTextWriter writer, Projec writer.Write($"{(i > 0 ? ", " : "")}{p}"); } + // In ref mode the composable constructor keeps its public signature but gets a 'throw null' + // body; the base call and the args struct + factory callback class below are skipped (they + // are private implementation details referencing implementation-only 'WinRT.Runtime' types). + if (context.Settings.ReferenceProjection) + { + RefModeStubFactory.EmitRefModeConstructorBody(writer); + methodIndex++; + + continue; + } + writer.Write(isMultiline: true, """ ) :base( @@ -142,11 +153,9 @@ void WriteCtorBody(IndentedTextWriter writer) } """); - // Emit args struct + callback class for parameterized composable factories. - // skips both the args struct AND the callback class entirely in ref mode. The - // public ctor above still references these types, but reference assemblies don't - // need their bodies' references to resolve (only the public API surface matters). - if (!isParameterless && !context.Settings.ReferenceProjection) + // Emit the args struct + factory callback class for parameterized composable factories. + // (Ref mode 'continue'd above before reaching here, since it emits no factory plumbing.) + if (!isParameterless) { EmitFactoryArgsStruct(writer, context, sig, argsName, userParamCount); string factoryObjRefName = ObjRefNameGenerator.GetObjRefName(context, composableType); diff --git a/src/WinRT.Projection.Writer/Factories/InterfaceFactory.cs b/src/WinRT.Projection.Writer/Factories/InterfaceFactory.cs index 9a49411cf7..7a0448b19a 100644 --- a/src/WinRT.Projection.Writer/Factories/InterfaceFactory.cs +++ b/src/WinRT.Projection.Writer/Factories/InterfaceFactory.cs @@ -401,7 +401,7 @@ public static void WriteInterface(IndentedTextWriter writer, ProjectionEmitConte } writer.WriteLine(); - IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(type, context.Cache); + IndentedTextWriterCallback metadataAttr = MetadataAttributeFactory.WriteWinRTMetadataAttribute(context, type); IndentedTextWriterCallback guidAttr = WriteGuidAttribute(type); writer.WriteLine(isMultiline: true, $$""" {{metadataAttr}} diff --git a/src/WinRT.Projection.Writer/Factories/MappedInterfaceStubFactory.cs b/src/WinRT.Projection.Writer/Factories/MappedInterfaceStubFactory.cs index 44e4a49464..1b8c1a9364 100644 --- a/src/WinRT.Projection.Writer/Factories/MappedInterfaceStubFactory.cs +++ b/src/WinRT.Projection.Writer/Factories/MappedInterfaceStubFactory.cs @@ -69,7 +69,7 @@ public static void WriteMappedInterfaceStubs(IndentedTextWriter writer, Projecti switch (ifaceName) { case "IClosable": - EmitDisposable(writer, objRefName); + EmitDisposable(writer, context, objRefName); break; case "IIterable`1": EmitGenericEnumerable(writer, context, typeArgs, typeArgSigs, objRefName); @@ -90,40 +90,107 @@ public static void WriteMappedInterfaceStubs(IndentedTextWriter writer, Projecti EmitReadOnlyList(writer, context, typeArgs, typeArgSigs, objRefName); break; case "IBindableIterable": - writer.WriteLine(); - writer.WriteLine($"IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => global::ABI.System.Collections.IEnumerableMethods.GetEnumerator({objRefName});"); + EmitNonGenericEnumerable(writer, context, objRefName); break; case "IBindableIterator": - writer.WriteLine(); - writer.WriteLine(isMultiline: true, $$""" - public bool MoveNext() => global::ABI.System.Collections.IEnumeratorMethods.MoveNext({{objRefName}}); - public void Reset() => throw new NotSupportedException(); - public object Current => global::ABI.System.Collections.IEnumeratorMethods.Current({{objRefName}}); - """); + EmitNonGenericEnumerator(writer, context, objRefName); break; case "IBindableVector": - EmitNonGenericList(writer, objRefName); + EmitNonGenericList(writer, context, objRefName); break; case "INotifyDataErrorInfo": - writer.WriteLine(); - writer.WriteLine(isMultiline: true, $$""" - public global::System.Collections.IEnumerable GetErrors(string propertyName) => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.GetErrors({{objRefName}}, propertyName); - public bool HasErrors {get => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.HasErrors({{objRefName}}); } - public event global::System.EventHandler ErrorsChanged - { - add => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.ErrorsChanged(this, {{objRefName}}).Subscribe(value); - remove => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.ErrorsChanged(this, {{objRefName}}).Unsubscribe(value); - } - """); + EmitNotifyDataErrorInfo(writer, context, objRefName); break; } } - private static void EmitDisposable(IndentedTextWriter writer, string objRefName) + + private static void EmitDisposable(IndentedTextWriter writer, ProjectionEmitContext context, string objRefName) { + // In a reference projection the member bodies dispatch to implementation-only plumbing + // (the 'ABI.*Methods' helpers, the '[UnsafeAccessor]' externs, and the '_objRef_*' fields, + // all of which are absent from the 'WinRT.Runtime' reference assembly), so the entire body is + // emitted as a stub. The public member signatures stay identical to the implementation projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine("public void Dispose() => throw null;"); + + return; + } + writer.WriteLine(); writer.WriteLine($"public void Dispose() => global::ABI.System.IDisposableMethods.Dispose({objRefName});"); } + private static void EmitNonGenericEnumerable(IndentedTextWriter writer, ProjectionEmitContext context, string objRefName) + { + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine("IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => throw null;"); + + return; + } + + writer.WriteLine(); + writer.WriteLine($"IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => global::ABI.System.Collections.IEnumerableMethods.GetEnumerator({objRefName});"); + } + + private static void EmitNonGenericEnumerator(IndentedTextWriter writer, ProjectionEmitContext context, string objRefName) + { + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, """ + public bool MoveNext() => throw null; + public void Reset() => throw null; + public object Current => throw null; + """); + + return; + } + + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $""" + public bool MoveNext() => global::ABI.System.Collections.IEnumeratorMethods.MoveNext({objRefName}); + public void Reset() => throw new NotSupportedException(); + public object Current => global::ABI.System.Collections.IEnumeratorMethods.Current({objRefName}); + """); + } + + private static void EmitNotifyDataErrorInfo(IndentedTextWriter writer, ProjectionEmitContext context, string objRefName) + { + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, """ + public global::System.Collections.IEnumerable GetErrors(string propertyName) => throw null; + public bool HasErrors {get => throw null; } + public event global::System.EventHandler ErrorsChanged + { + add => throw null; + remove => throw null; + } + """); + + return; + } + + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $$""" + public global::System.Collections.IEnumerable GetErrors(string propertyName) => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.GetErrors({{objRefName}}, propertyName); + public bool HasErrors {get => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.HasErrors({{objRefName}}); } + public event global::System.EventHandler ErrorsChanged + { + add => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.ErrorsChanged(this, {{objRefName}}).Subscribe(value); + remove => global::ABI.System.ComponentModel.INotifyDataErrorInfoMethods.ErrorsChanged(this, {{objRefName}}).Unsubscribe(value); + } + """); + } + private static void EmitGenericEnumerable(IndentedTextWriter writer, ProjectionEmitContext context, List args, List argSigs, string objRefName) { if (args.Count != 1) @@ -132,13 +199,28 @@ private static void EmitGenericEnumerable(IndentedTextWriter writer, ProjectionE } string t = WriteTypeNameToString(context, args[0], TypedefNameType.Projected, true); + + // See 'EmitDisposable' for why the body is stubbed in a reference projection. Only the + // projected type name is needed for the signatures; the implementation-only interop plumbing + // (interop type, '[UnsafeAccessor]' externs) is not computed or emitted. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $""" + public IEnumerator<{t}> GetEnumerator() => throw null; + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => throw null; + """); + + return; + } + string elementId = EncodeArgIdentifier(context, args[0]); string interopTypeArgs = InteropTypeNameWriter.EncodeInteropTypeName(argSigs[0], TypedefNameType.Projected); string interopType = "ABI.System.Collections.Generic.<#corlib>IEnumerable'1<" + interopTypeArgs + ">Methods, WinRT.Interop"; string prefix = "IEnumerableMethods_" + elementId + "_"; writer.WriteLine(); - EmitUnsafeAccessor(writer, "GetEnumerator", $"IEnumerator<{t}>", $"{prefix}GetEnumerator", interopType, ""); + EmitUnsafeAccessor(writer, context, "GetEnumerator", $"IEnumerator<{t}>", $"{prefix}GetEnumerator", interopType, ""); writer.WriteLine(); writer.WriteLine($"public IEnumerator<{t}> GetEnumerator() => {prefix}GetEnumerator(null, {objRefName});"); @@ -153,13 +235,29 @@ private static void EmitGenericEnumerator(IndentedTextWriter writer, ProjectionE } string t = WriteTypeNameToString(context, args[0], TypedefNameType.Projected, true); + + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $""" + public bool MoveNext() => throw null; + public void Reset() => throw null; + public void Dispose() => throw null; + public {t} Current => throw null; + object global::System.Collections.IEnumerator.Current => throw null; + """); + + return; + } + string elementId = EncodeArgIdentifier(context, args[0]); string interopTypeArgs = InteropTypeNameWriter.EncodeInteropTypeName(argSigs[0], TypedefNameType.Projected); string interopType = "ABI.System.Collections.Generic.<#corlib>IEnumerator'1<" + interopTypeArgs + ">Methods, WinRT.Interop"; string prefix = "IEnumeratorMethods_" + elementId + "_"; writer.WriteLine(); - EmitUnsafeAccessors(writer, interopType, [ + EmitUnsafeAccessors(writer, context, interopType, [ new("Current", t, $"{prefix}Current", ""), new("MoveNext", "bool", $"{prefix}MoveNext", "")]); @@ -189,6 +287,36 @@ private static void EmitDictionary(IndentedTextWriter writer, ProjectionEmitCont string kv = $"KeyValuePair<{k}, {v}>"; string kvNested = $"global::System.Collections.Generic.KeyValuePair<{k}, {v}>"; + // See 'EmitDisposable' for why the body is stubbed in a reference projection. Only the projected + // type names are needed for the signatures; the implementation-only interop plumbing (interop + // type, '[UnsafeAccessor]' externs, '_objRef_*' fields) is not computed or emitted. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $$""" + public ICollection<{{k}}> Keys => throw null; + public ICollection<{{v}}> Values => throw null; + public int Count => throw null; + public bool IsReadOnly => false; + public {{v}} this[{{k}} key] + { + get => throw null; + set => throw null; + } + public void Add({{k}} key, {{v}} value) => throw null; + public bool ContainsKey({{k}} key) => throw null; + public bool Remove({{k}} key) => throw null; + public bool TryGetValue({{k}} key, out {{v}} value) => throw null; + public void Add({{kv}} item) => throw null; + public void Clear() => throw null; + public bool Contains({{kv}} item) => throw null; + public void CopyTo({{kv}}[] array, int arrayIndex) => throw null; + bool ICollection<{{kv}}>.Remove({{kv}} item) => throw null; + """); + + return; + } + // Long form (always fully qualified) used for objref field-name computation // (matches the form WriteClassObjRefDefinitions emits transitively). string kvLong = kvNested; @@ -207,9 +335,9 @@ private static void EmitDictionary(IndentedTextWriter writer, ProjectionEmitCont // 'Keys'/'Values' take the projected runtime class directly (passed as 'this'), rather than the // interface object reference like the other accessors. This lets the returned collection be cached // in the public property's backing 'field' so it preserves reference identity across accesses. - EmitUnsafeAccessor(writer, "Keys", $"ICollection<{k}>", $"{prefix}Keys", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); - EmitUnsafeAccessor(writer, "Values", $"ICollection<{v}>", $"{prefix}Values", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); - EmitUnsafeAccessors(writer, interopType, [ + EmitUnsafeAccessor(writer, context, "Keys", $"ICollection<{k}>", $"{prefix}Keys", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); + EmitUnsafeAccessor(writer, context, "Values", $"ICollection<{v}>", $"{prefix}Values", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); + EmitUnsafeAccessors(writer, context, interopType, [ new("Count", "int", $"{prefix}Count", ""), new("Item", v, $"{prefix}Item", $", {k} key"), new("Item", "void", $"{prefix}Item", $", {k} key, {v} value"), @@ -257,6 +385,23 @@ private static void EmitReadOnlyDictionary(IndentedTextWriter writer, Projection string k = WriteTypeNameToString(context, args[0], TypedefNameType.Projected, true); string v = WriteTypeNameToString(context, args[1], TypedefNameType.Projected, true); + + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $""" + public {v} this[{k} key] => throw null; + public IEnumerable<{k}> Keys => throw null; + public IEnumerable<{v}> Values => throw null; + public int Count => throw null; + public bool ContainsKey({k} key) => throw null; + public bool TryGetValue({k} key, out {v} value) => throw null; + """); + + return; + } + string keyId = EncodeArgIdentifier(context, args[0]); string valId = EncodeArgIdentifier(context, args[1]); string keyInteropArg = InteropTypeNameWriter.EncodeInteropTypeName(argSigs[0], TypedefNameType.Projected); @@ -269,9 +414,9 @@ private static void EmitReadOnlyDictionary(IndentedTextWriter writer, Projection // 'Keys'/'Values' take the projected runtime class directly (passed as 'this'), rather than the // interface object reference like the other accessors. This lets the returned collection be cached // in the public property's backing 'field' so it preserves reference identity across accesses. - EmitUnsafeAccessor(writer, "Keys", $"IEnumerable<{k}>", $"{prefix}Keys", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); - EmitUnsafeAccessor(writer, "Values", $"IEnumerable<{v}>", $"{prefix}Values", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); - EmitUnsafeAccessors(writer, interopType, [ + EmitUnsafeAccessor(writer, context, "Keys", $"IEnumerable<{k}>", $"{prefix}Keys", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); + EmitUnsafeAccessor(writer, context, "Values", $"IEnumerable<{v}>", $"{prefix}Values", interopType, "", receiver: "WindowsRuntimeObject windowsRuntimeObject"); + EmitUnsafeAccessors(writer, context, interopType, [ new("Count", "int", $"{prefix}Count", ""), new("Item", v, $"{prefix}Item", $", {k} key"), new("ContainsKey", "bool", $"{prefix}ContainsKey", $", {k} key"), @@ -296,23 +441,37 @@ private static void EmitReadOnlyList(IndentedTextWriter writer, ProjectionEmitCo } string t = WriteTypeNameToString(context, args[0], TypedefNameType.Projected, true); + + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $""" + [global::System.Runtime.CompilerServices.IndexerName("ReadOnlyListItem")] + public {t} this[int index] => throw null; + public int Count => throw null; + """); + + return; + } + string elementId = EncodeArgIdentifier(context, args[0]); string interopTypeArgs = InteropTypeNameWriter.EncodeInteropTypeName(argSigs[0], TypedefNameType.Projected); string interopType = "ABI.System.Collections.Generic.<#corlib>IReadOnlyList'1<" + interopTypeArgs + ">Methods, WinRT.Interop"; string prefix = "IReadOnlyListMethods_" + elementId + "_"; writer.WriteLine(); - EmitUnsafeAccessors(writer, interopType, [ + EmitUnsafeAccessors(writer, context, interopType, [ new("Count", "int", $"{prefix}Count", ""), new("Item", t, $"{prefix}Item", ", int index")]); // GetEnumerator is NOT emitted here -- it's handled separately by IIterable's // EmitGenericEnumerable invocation. writer.WriteLine(); - writer.WriteLine(isMultiline: true, $$""" + writer.WriteLine(isMultiline: true, $""" [global::System.Runtime.CompilerServices.IndexerName("ReadOnlyListItem")] - public {{t}} this[int index] => {{prefix}}Item(null, {{objRefName}}, index); - public int Count => {{prefix}}Count(null, {{objRefName}}); + public {t} this[int index] => {prefix}Item(null, {objRefName}, index); + public int Count => {prefix}Count(null, {objRefName}); """); } @@ -343,13 +502,41 @@ private static void EmitList(IndentedTextWriter writer, ProjectionEmitContext co } string t = WriteTypeNameToString(context, args[0], TypedefNameType.Projected, true); + + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, $$""" + public int Count => throw null; + public bool IsReadOnly => false; + + [global::System.Runtime.CompilerServices.IndexerName("ListItem")] + public {{t}} this[int index] + { + get => throw null; + set => throw null; + } + public int IndexOf({{t}} item) => throw null; + public void Insert(int index, {{t}} item) => throw null; + public void RemoveAt(int index) => throw null; + public void Add({{t}} item) => throw null; + public void Clear() => throw null; + public bool Contains({{t}} item) => throw null; + public void CopyTo({{t}}[] array, int arrayIndex) => throw null; + public bool Remove({{t}} item) => throw null; + """); + + return; + } + string elementId = EncodeArgIdentifier(context, args[0]); string interopTypeArgs = InteropTypeNameWriter.EncodeInteropTypeName(argSigs[0], TypedefNameType.Projected); string interopType = "ABI.System.Collections.Generic.<#corlib>IList'1<" + interopTypeArgs + ">Methods, WinRT.Interop"; string prefix = "IListMethods_" + elementId + "_"; writer.WriteLine(); - EmitUnsafeAccessors(writer, interopType, [ + EmitUnsafeAccessors(writer, context, interopType, [ new("Count", "int", $"{prefix}Count", ""), new("Item", t, $"{prefix}Item", ", int index"), new("Item", "void", $"{prefix}Item", $", int index, {t} value"), @@ -393,8 +580,25 @@ private static void EmitList(IndentedTextWriter writer, ProjectionEmitContext co /// (WindowsRuntimeObjectReference objRef); a few accessors (e.g. dictionary /// Keys/Values) instead take the projected runtime class (WindowsRuntimeObject). /// - private static void EmitUnsafeAccessor(IndentedTextWriter writer, string accessName, string returnType, string functionName, string interopType, string extraParams, string receiver = "WindowsRuntimeObjectReference objRef") + private static void EmitUnsafeAccessor( + IndentedTextWriter writer, + ProjectionEmitContext context, + string accessName, + string returnType, + string functionName, + string interopType, + string extraParams, + string receiver = "WindowsRuntimeObjectReference objRef") { + // The '[UnsafeAccessor]' extern is impl-only plumbing for the stub member bodies; in a reference + // projection those bodies are not bound (the reference assembly only needs the public member + // signatures), so the extern (which typically references the implementation-only + // 'WindowsRuntimeObjectReference') is omitted. + if (context.Settings.ReferenceProjection) + { + return; + } + UnsafeAccessorFactory.EmitStaticMethod( writer, accessName: accessName, @@ -408,22 +612,54 @@ private static void EmitUnsafeAccessor(IndentedTextWriter writer, string accessN /// /// Emits a sequence of [UnsafeAccessor] static extern declarations sharing the same /// . Each row of is forwarded to - /// . + /// . /// Used by the collection-stub emitters which emit table-shaped sets of accessors. /// private static void EmitUnsafeAccessors( IndentedTextWriter writer, + ProjectionEmitContext context, string interopType, params ReadOnlySpan<(string AccessName, string ReturnType, string FunctionName, string ExtraParams)> accessors) { foreach ((string accessName, string returnType, string functionName, string extraParams) in accessors) { - EmitUnsafeAccessor(writer, accessName, returnType, functionName, interopType, extraParams); + EmitUnsafeAccessor(writer, context, accessName, returnType, functionName, interopType, extraParams); } } - private static void EmitNonGenericList(IndentedTextWriter writer, string objRefName) + private static void EmitNonGenericList(IndentedTextWriter writer, ProjectionEmitContext context, string objRefName) { + // See 'EmitDisposable' for why the body is stubbed in a reference projection. + if (context.Settings.ReferenceProjection) + { + writer.WriteLine(); + writer.WriteLine(isMultiline: true, """ + [global::System.Runtime.CompilerServices.IndexerName("NonGenericListItem")] + public object this[int index] + { + get => throw null; + set => throw null; + } + public int Count => throw null; + public bool IsReadOnly => false; + public bool IsFixedSize => false; + public bool IsSynchronized => false; + public object SyncRoot => this; + public int Add(object value) => throw null; + public void Clear() => throw null; + public bool Contains(object value) => throw null; + public int IndexOf(object value) => throw null; + public void Insert(int index, object value) => throw null; + public void Remove(object value) => throw null; + public void RemoveAt(int index) => throw null; + public void CopyTo(Array array, int index) => throw null; + """); + + // GetEnumerator is NOT emitted here -- it's handled separately by IBindableIterable's + // EmitNonGenericEnumerable invocation. + return; + } + writer.WriteLine(); writer.WriteLine(isMultiline: true, $$""" [global::System.Runtime.CompilerServices.IndexerName("NonGenericListItem")] diff --git a/src/WinRT.Projection.Writer/Factories/MetadataAttributeFactory.cs b/src/WinRT.Projection.Writer/Factories/MetadataAttributeFactory.cs index 97b167173d..cc3ba08608 100644 --- a/src/WinRT.Projection.Writer/Factories/MetadataAttributeFactory.cs +++ b/src/WinRT.Projection.Writer/Factories/MetadataAttributeFactory.cs @@ -80,30 +80,45 @@ public static string GetFileHeader() /// /// Writes a [WindowsRuntimeMetadata("<stem>")] attribute decorating with its source .winmd module name. + /// Skipped entirely in reference-projection mode. /// /// The writer to emit to. + /// The active emit context. /// The type definition. - /// The metadata cache used to resolve the source module path. - public static void WriteWinRTMetadataAttribute(IndentedTextWriter writer, TypeDefinition type, MetadataCache cache) + public static void WriteWinRTMetadataAttribute(IndentedTextWriter writer, ProjectionEmitContext context, TypeDefinition type) { - WriteWinRTMetadataAttributeBody(writer, type, cache); + if (context.Settings.ReferenceProjection) + { + return; + } + + WriteWinRTMetadataAttributeBody(writer, context, type); + writer.WriteLine(); } - /// - /// A callback emitting the attribute body (no trailing newline) so it can be interpolated into a multiline template. - public static IndentedTextWriterCallback WriteWinRTMetadataAttribute(TypeDefinition type, MetadataCache cache) + /// + /// A callback emitting the attribute body (no trailing newline) so it can be interpolated into a multiline template. Emits nothing in reference-projection mode. + public static IndentedTextWriterCallback WriteWinRTMetadataAttribute(ProjectionEmitContext context, TypeDefinition type) { - return writer => WriteWinRTMetadataAttributeBody(writer, type, cache); + return writer => WriteWinRTMetadataAttributeBody(writer, context, type); } /// - /// Writes just the attribute body (no trailing newline) for . - /// Used by the callback variant to allow the attribute to be inlined inside a multiline raw-string template line. + /// Writes just the attribute body (no trailing newline) for . + /// In reference-projection mode this emits nothing: [WindowsRuntimeMetadata] is an implementation-only + /// type, stripped from the WinRT.Runtime reference assembly that a reference projection compiles against. + /// It is only consumed (by the interop generator) from implementation projections, never from the reference + /// projections shipped in Windows Runtime projection NuGet packages. /// - internal static void WriteWinRTMetadataAttributeBody(IndentedTextWriter writer, TypeDefinition type, MetadataCache cache) + internal static void WriteWinRTMetadataAttributeBody(IndentedTextWriter writer, ProjectionEmitContext context, TypeDefinition type) { - string path = cache.GetSourcePath(type); + if (context.Settings.ReferenceProjection) + { + return; + } + + string path = context.Cache.GetSourcePath(type); string stem = string.IsNullOrEmpty(path) ? string.Empty : Path.GetFileNameWithoutExtension(path); writer.Write($"[WindowsRuntimeMetadata(\"{stem}\")]"); } diff --git a/src/WinRT.Projection.Writer/Factories/RefModeStubFactory.cs b/src/WinRT.Projection.Writer/Factories/RefModeStubFactory.cs index 19f6b68f30..16b4a2c003 100644 --- a/src/WinRT.Projection.Writer/Factories/RefModeStubFactory.cs +++ b/src/WinRT.Projection.Writer/Factories/RefModeStubFactory.cs @@ -14,33 +14,50 @@ namespace WindowsRuntime.ProjectionWriter.Factories; internal static class RefModeStubFactory { /// - /// Emits the body of an _objRef_* property getter in reference projection mode. + /// Emits the synthetic private TypeName() { throw null; } ctor used in reference + /// projection mode to suppress the C# compiler's implicit public default constructor when + /// no explicit ctors are emitted by WriteAttributedTypes. /// + /// + /// For an unsealed class the ctor is emitted as private protected rather than private: + /// a projected class can derive from another projected class (e.g. UriActionEntity : ActionEntity), + /// and the derived class's own synthetic ctor implicitly chains to the base's parameterless ctor. The + /// real WindowsRuntimeObjectReference-based ctor that derived classes chain to in the + /// implementation projection is not emitted in a reference projection, so the synthetic ctor must be + /// accessible to derived classes in the same projection. It stays non-public, so it still suppresses the + /// implicit public default constructor. + /// /// The writer to emit to. - public static void EmitRefModeObjRefGetterBody(IndentedTextWriter writer) + /// The type name to emit the synthetic constructor for. + /// Whether the type is sealed (and so can never be a base class). + public static void EmitSyntheticPrivateCtor(IndentedTextWriter writer, string typeName, bool isSealed) { + string accessibility = isSealed ? "private" : "private protected"; + writer.WriteLine(); - writer.WriteLine(isMultiline: true, """ - { - get - { - throw null; - } - } - """); + writer.WriteLine($"{accessibility} {typeName}() {{ throw null; }}"); } /// - /// Emits the synthetic private TypeName() { throw null; } ctor used in reference - /// projection mode to suppress the C# compiler's implicit public default constructor when - /// no explicit ctors are emitted by WriteAttributedTypes. + /// Emits the closing ) of a constructor parameter list followed by a throw null body, + /// for constructors emitted in reference projection mode. The caller must already have written the + /// constructor signature up to (but not including) the closing ) of the parameter list. /// + /// + /// Reference projections only need the public constructor signatures (their bodies are never run and + /// are stripped from the produced reference assembly), so the body is emitted as throw null + /// rather than the real activation logic, which would reference implementation-only 'WinRT.Runtime' + /// types (object references, activation factory callbacks, ABI IID accessors). + /// /// The writer to emit to. - /// The type name to emit the synthetic constructor for. - public static void EmitSyntheticPrivateCtor(IndentedTextWriter writer, string typeName) + public static void EmitRefModeConstructorBody(IndentedTextWriter writer) { - writer.WriteLine(); - writer.WriteLine($"private {typeName}() {{ throw null; }}"); + writer.WriteLine(isMultiline: true, """ + ) + { + throw null; + } + """); } /// diff --git a/src/WinRT.Projection.Writer/Factories/ReferenceImplFactory.cs b/src/WinRT.Projection.Writer/Factories/ReferenceImplFactory.cs index 62aedfa1a9..31294fea09 100644 --- a/src/WinRT.Projection.Writer/Factories/ReferenceImplFactory.cs +++ b/src/WinRT.Projection.Writer/Factories/ReferenceImplFactory.cs @@ -134,7 +134,7 @@ public static int get_Value(void* thisPtr, void* result) {{visibility}} static unsafe class {{nameStripped}}ReferenceImpl { [FixedAddressValueType] - private static readonly ReferenceVftbl Vftbl; + private static readonly IReferenceVftbl Vftbl; static {{nameStripped}}ReferenceImpl() { diff --git a/src/WinRT.Projection.Writer/Helpers/ObjRefNameGenerator.cs b/src/WinRT.Projection.Writer/Helpers/ObjRefNameGenerator.cs index 8e971f9dcf..bc0d0bf121 100644 --- a/src/WinRT.Projection.Writer/Helpers/ObjRefNameGenerator.cs +++ b/src/WinRT.Projection.Writer/Helpers/ObjRefNameGenerator.cs @@ -245,9 +245,14 @@ public static IndentedTextWriterCallback WriteIidReferenceExpression(TypeDefinit /// public static void WriteClassObjRefDefinitions(IndentedTextWriter writer, ProjectionEmitContext context, TypeDefinition type) { - // Per-interface _objRef_* getters are emitted in BOTH impl and ref modes with full - // bodies. (Only the static factory _objRef_* getters become `throw null;` in ref mode -- - // see WriteStaticFactoryObjRef and WriteAttributedTypes.) + // The per-interface '_objRef_*' fields are private implementation details that reference + // implementation-only 'WinRT.Runtime' types ('WindowsRuntimeObjectReference', 'NativeObjectReference', + // the ABI IID accessors, etc.). A reference projection compiles against the stripped 'WinRT.Runtime' + // reference assembly and only needs the public API surface, so none of these are emitted. + if (context.Settings.ReferenceProjection) + { + return; + } // Track names emitted so we don't emit duplicates (e.g. when both IFoo and IFoo2 // produce the same _objRef_). diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Dispatching/Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Dispatching/Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.cs index d09b751561..eb925d5a72 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Dispatching/Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Dispatching/Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.cs @@ -8,10 +8,12 @@ namespace Microsoft.UI.Dispatching /// public sealed class DispatcherQueueSynchronizationContext : global::System.Threading.SynchronizationContext { +#if !CSWINRT_REFERENCE_PROJECTION /// /// The instance to use. /// private readonly WindowsRuntime.InteropServices.DispatcherQueueSynchronizationContext _innerContext; +#endif /// /// Creates a new instance with the specified parameters. @@ -20,9 +22,14 @@ public sealed class DispatcherQueueSynchronizationContext : global::System.Threa /// Thrown if is . public DispatcherQueueSynchronizationContext(global::Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else _innerContext = new WindowsRuntime.InteropServices.DispatcherQueueSynchronizationContext(dispatcherQueue); +#endif } +#if !CSWINRT_REFERENCE_PROJECTION /// /// Creates a new instance with the specified parameters. /// @@ -31,23 +38,36 @@ private DispatcherQueueSynchronizationContext(WindowsRuntime.InteropServices.Dis { _innerContext = innerContext; } +#endif /// public override void Post(global::System.Threading.SendOrPostCallback d, object? state) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else _innerContext.Post(d, state); +#endif } /// public override void Send(global::System.Threading.SendOrPostCallback d, object? state) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else _innerContext.Send(d, state); +#endif } /// public override global::System.Threading.SynchronizationContext CreateCopy() { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else return new DispatcherQueueSynchronizationContext(_innerContext); +#endif } } } diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.KeyTime.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.KeyTime.cs index 61e8f3509a..3d646f27e6 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.KeyTime.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.KeyTime.cs @@ -3,8 +3,8 @@ namespace Microsoft.UI.Xaml.Media.Animation { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Microsoft.UI")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Microsoft.UI")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Microsoft.UI.Xaml.Media.Animation.KeyTimeComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.RepeatBehavior.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.RepeatBehavior.cs index 972909273e..c768ea8449 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.RepeatBehavior.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.RepeatBehavior.cs @@ -3,8 +3,8 @@ namespace Microsoft.UI.Xaml.Media.Animation { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Microsoft.UI")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Microsoft.UI")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Microsoft.UI.Xaml.Media.Animation.RepeatBehaviorComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.Matrix3D.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.Matrix3D.cs index 873cc52c02..0fa0e83f5c 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.Matrix3D.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.Matrix3D.cs @@ -3,8 +3,8 @@ namespace Microsoft.UI.Xaml.Media.Media3D { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Microsoft.UI")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Microsoft.UI")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Microsoft.UI.Xaml.Media.Media3D.Matrix3DComWrappersMarshaller] #endif @@ -406,6 +406,9 @@ readonly string IFormattable.ToString(string format, IFormatProvider provider) private readonly string ConvertToString(string format, IFormatProvider provider) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else if (IsIdentity) { return "Identity"; @@ -446,6 +449,7 @@ private readonly string ConvertToString(string format, IFormatProvider provider) handler.AppendFormatted(separator); handler.AppendFormatted(_m44, format); return handler.ToStringAndClear(); +#endif } public readonly override int GetHashCode() diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.Matrix.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.Matrix.cs index 85c7a3ae72..e57974e62c 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.Matrix.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.Matrix.cs @@ -44,6 +44,9 @@ readonly string IFormattable.ToString(string format, IFormatProvider provider) private readonly string ConvertToString(string format, IFormatProvider provider) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else if (IsIdentity) { return "Identity"; @@ -64,6 +67,7 @@ private readonly string ConvertToString(string format, IFormatProvider provider) handler.AppendFormatted(separator); handler.AppendFormatted(OffsetY, format); return handler.ToStringAndClear(); +#endif } public readonly Point Transform(Point point) diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.CornerRadius.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.CornerRadius.cs index 539d6ac177..275ac52d6d 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.CornerRadius.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.CornerRadius.cs @@ -3,8 +3,8 @@ namespace Microsoft.UI.Xaml { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Microsoft.UI")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Microsoft.UI")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Microsoft.UI.Xaml.CornerRadiusComWrappersMarshaller] #endif @@ -53,6 +53,9 @@ public readonly override string ToString() private readonly string ToString(global::System.Globalization.CultureInfo cultureInfo) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else char listSeparator = global::WindowsRuntime.InteropServices.TokenizerHelper.GetNumericListSeparator(cultureInfo); // Initial capacity [64] is an estimate based on a sum of: @@ -67,6 +70,7 @@ private readonly string ToString(global::System.Globalization.CultureInfo cultur handler.AppendFormatted(listSeparator); InternalAddToHandler(_BottomLeft, ref handler); return handler.ToStringAndClear(); +#endif } private static void InternalAddToHandler(double l, ref DefaultInterpolatedStringHandler handler) diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Duration.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Duration.cs index 524df87d27..c36ab0e3c8 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Duration.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Duration.cs @@ -3,8 +3,8 @@ namespace Microsoft.UI.Xaml { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Microsoft.UI")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Microsoft.UI")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Microsoft.UI.Xaml.DurationComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.GridLength.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.GridLength.cs index 78a1fabadb..ae79055125 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.GridLength.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.GridLength.cs @@ -3,8 +3,8 @@ namespace Microsoft.UI.Xaml { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Microsoft.UI")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Microsoft.UI")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Microsoft.UI.Xaml.GridLengthComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Thickness.cs b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Thickness.cs index d902878b13..579ab5ca78 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Thickness.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.Thickness.cs @@ -17,6 +17,9 @@ public readonly override string ToString() private readonly string ToString(global::System.Globalization.CultureInfo cultureInfo) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else char listSeparator = global::WindowsRuntime.InteropServices.TokenizerHelper.GetNumericListSeparator(cultureInfo); // Initial capacity [64] is an estimate based on a sum of: @@ -31,6 +34,7 @@ private readonly string ToString(global::System.Globalization.CultureInfo cultur handler.AppendFormatted(listSeparator); InternalAddToHandler(Bottom, ref handler); return handler.ToStringAndClear(); +#endif } private static void InternalAddToHandler(double l, ref DefaultInterpolatedStringHandler handler) diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs index a48ffa4ec6..6f876ac5ae 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs @@ -29,6 +29,9 @@ public static class WindowsRuntimeStorageExtensions [SupportedOSPlatform("windows10.0.10240.0")] public static Task OpenStreamForReadAsync(this IStorageFile windowsRuntimeFile) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else ArgumentNullException.ThrowIfNull(windowsRuntimeFile); // Helper with the actual read logic @@ -53,6 +56,7 @@ static async Task OpenStreamForReadCoreAsync(IStorageFile windowsRuntime } return OpenStreamForReadCoreAsync(windowsRuntimeFile); +#endif } /// @@ -82,6 +86,9 @@ public static Task OpenStreamForWriteAsync(this IStorageFile windowsRunt [SupportedOSPlatform("windows10.0.10240.0")] public static Task OpenStreamForReadAsync(this IStorageFolder rootDirectory, string relativePath) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else ArgumentNullException.ThrowIfNull(rootDirectory); ArgumentException.ThrowIfNullOrWhiteSpace(relativePath); @@ -110,6 +117,7 @@ static async Task OpenStreamForReadCoreAsync(IStorageFolder rootDirector } return OpenStreamForReadCoreAsync(rootDirectory, relativePath); +#endif } /// @@ -128,6 +136,9 @@ public static Task OpenStreamForWriteAsync( string relativePath, CreationCollisionOption creationCollisionOption) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else ArgumentNullException.ThrowIfNull(rootDirectory); ArgumentException.ThrowIfNullOrWhiteSpace(relativePath); @@ -187,6 +198,7 @@ CreationCollisionOption.OpenIfExists or } return OpenStreamForWriteCoreAsync(rootDirectory, relativePath, creationCollisionOption); +#endif } /// @@ -204,6 +216,9 @@ CreationCollisionOption.OpenIfExists or FileShare share = FileShare.Read, FileOptions options = FileOptions.None) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else ArgumentNullException.ThrowIfNull(windowsRuntimeFile); return global::WindowsRuntime.InteropServices.IStorageItemHandleAccessMethods.Create( @@ -211,6 +226,7 @@ CreationCollisionOption.OpenIfExists or access, share, options); +#endif } /// @@ -247,6 +263,9 @@ CreationCollisionOption.OpenIfExists or FileShare share = FileShare.Read, FileOptions options = FileOptions.None) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else ArgumentNullException.ThrowIfNull(rootDirectory); ArgumentNullException.ThrowIfNull(relativePath); @@ -257,6 +276,7 @@ CreationCollisionOption.OpenIfExists or access, share, options); +#endif } /// @@ -264,6 +284,9 @@ CreationCollisionOption.OpenIfExists or [SupportedOSPlatform("windows10.0.10240.0")] private static async Task OpenStreamForWriteWithOffsetAsync(IStorageFile windowsRuntimeFile, long offset) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else Debug.Assert(windowsRuntimeFile is not null); Debug.Assert(offset >= 0); @@ -287,6 +310,7 @@ private static async Task OpenStreamForWriteWithOffsetAsync(IStorageFile return null; } +#endif } } #nullable restore diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.KeyTime.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.KeyTime.cs index 0b5d196c20..f5ac263652 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.KeyTime.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.KeyTime.cs @@ -3,8 +3,8 @@ namespace Windows.UI.Xaml.Media.Animation { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Windows.UI.Xaml.Media.Animation.KeyTimeComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.RepeatBehavior.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.RepeatBehavior.cs index c19f73bc48..5cc7ef1abf 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.RepeatBehavior.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Animation/Windows.UI.Xaml.Media.Animation.RepeatBehavior.cs @@ -3,8 +3,8 @@ namespace Windows.UI.Xaml.Media.Animation { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Windows.UI.Xaml.Media.Animation.RepeatBehaviorComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Media3D/Windows.UI.Xaml.Media.Media3D.Matrix3D.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Media3D/Windows.UI.Xaml.Media.Media3D.Matrix3D.cs index f11fe74cbb..ed17ff3efc 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Media3D/Windows.UI.Xaml.Media.Media3D.Matrix3D.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media.Media3D/Windows.UI.Xaml.Media.Media3D.Matrix3D.cs @@ -3,8 +3,8 @@ namespace Windows.UI.Xaml.Media.Media3D { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Windows.UI.Xaml.Media.Media3D.Matrix3DComWrappersMarshaller] #endif @@ -406,6 +406,9 @@ readonly string IFormattable.ToString(string format, IFormatProvider provider) private readonly string ConvertToString(string format, IFormatProvider provider) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else if (IsIdentity) { return "Identity"; @@ -446,6 +449,7 @@ private readonly string ConvertToString(string format, IFormatProvider provider) handler.AppendFormatted(separator); handler.AppendFormatted(_m44, format); return handler.ToStringAndClear(); +#endif } public readonly override int GetHashCode() diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media/Windows.UI.Xaml.Media.Matrix.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media/Windows.UI.Xaml.Media.Matrix.cs index 3ffce829f5..a643aa0a03 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media/Windows.UI.Xaml.Media.Matrix.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml.Media/Windows.UI.Xaml.Media.Matrix.cs @@ -44,6 +44,9 @@ readonly string IFormattable.ToString(string format, IFormatProvider provider) private readonly string ConvertToString(string format, IFormatProvider provider) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else if (IsIdentity) { return "Identity"; @@ -64,6 +67,7 @@ private readonly string ConvertToString(string format, IFormatProvider provider) handler.AppendFormatted(separator); handler.AppendFormatted(OffsetY, format); return handler.ToStringAndClear(); +#endif } public readonly Point Transform(Point point) diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.System.DispatcherQueueSynchronizationContext.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.System.DispatcherQueueSynchronizationContext.cs index 59c3dac908..a61f9424f3 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.System.DispatcherQueueSynchronizationContext.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.System.DispatcherQueueSynchronizationContext.cs @@ -8,10 +8,12 @@ namespace Windows.System /// public sealed class DispatcherQueueSynchronizationContext : global::System.Threading.SynchronizationContext { +#if !CSWINRT_REFERENCE_PROJECTION /// /// The instance to use. /// private readonly WindowsRuntime.InteropServices.DispatcherQueueSynchronizationContext _innerContext; +#endif /// /// Creates a new instance with the specified parameters. @@ -20,9 +22,14 @@ public sealed class DispatcherQueueSynchronizationContext : global::System.Threa /// Thrown if is . public DispatcherQueueSynchronizationContext(global::Windows.System.DispatcherQueue dispatcherQueue) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else _innerContext = new WindowsRuntime.InteropServices.DispatcherQueueSynchronizationContext(dispatcherQueue); +#endif } +#if !CSWINRT_REFERENCE_PROJECTION /// /// Creates a new instance with the specified parameters. /// @@ -31,23 +38,36 @@ private DispatcherQueueSynchronizationContext(WindowsRuntime.InteropServices.Dis { _innerContext = innerContext; } +#endif /// public override void Post(global::System.Threading.SendOrPostCallback d, object? state) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else _innerContext.Post(d, state); +#endif } /// public override void Send(global::System.Threading.SendOrPostCallback d, object? state) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else _innerContext.Send(d, state); +#endif } /// public override global::System.Threading.SynchronizationContext CreateCopy() { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else return new DispatcherQueueSynchronizationContext(_innerContext); +#endif } } } diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.CornerRadius.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.CornerRadius.cs index 0e51a5163c..74c03e0be0 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.CornerRadius.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.CornerRadius.cs @@ -3,8 +3,8 @@ namespace Windows.UI.Xaml { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Windows.UI.Xaml.CornerRadiusComWrappersMarshaller] #endif @@ -53,6 +53,9 @@ public readonly override string ToString() private readonly string ToString(global::System.Globalization.CultureInfo cultureInfo) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else char listSeparator = global::WindowsRuntime.InteropServices.TokenizerHelper.GetNumericListSeparator(cultureInfo); // Initial capacity [64] is an estimate based on a sum of: @@ -67,6 +70,7 @@ private readonly string ToString(global::System.Globalization.CultureInfo cultur handler.AppendFormatted(listSeparator); InternalAddToHandler(_BottomLeft, ref handler); return handler.ToStringAndClear(); +#endif } private static void InternalAddToHandler(double l, ref DefaultInterpolatedStringHandler handler) diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Duration.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Duration.cs index d8dd051cb9..00e6de2077 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Duration.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Duration.cs @@ -3,8 +3,8 @@ namespace Windows.UI.Xaml { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Windows.UI.Xaml.DurationComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.GridLength.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.GridLength.cs index 15be3b17a7..cd6db72037 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.GridLength.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.GridLength.cs @@ -3,8 +3,8 @@ namespace Windows.UI.Xaml { using global::Windows.Foundation; - [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] #if !CSWINRT_REFERENCE_PROJECTION + [WindowsRuntimeMetadata("Windows.Foundation.UniversalApiContract")] [WindowsRuntimeClassName("Windows.Foundation.IReference`1")] [ABI.Windows.UI.Xaml.GridLengthComWrappersMarshaller] #endif diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Thickness.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Thickness.cs index cc67420d37..46673ef80a 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Thickness.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI.Xaml/Windows.UI.Xaml.Thickness.cs @@ -17,6 +17,9 @@ public readonly override string ToString() private readonly string ToString(global::System.Globalization.CultureInfo cultureInfo) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else char listSeparator = global::WindowsRuntime.InteropServices.TokenizerHelper.GetNumericListSeparator(cultureInfo); // Initial capacity [64] is an estimate based on a sum of: @@ -31,6 +34,7 @@ private readonly string ToString(global::System.Globalization.CultureInfo cultur handler.AppendFormatted(listSeparator); InternalAddToHandler(Bottom, ref handler); return handler.ToStringAndClear(); +#endif } private static void InternalAddToHandler(double l, ref DefaultInterpolatedStringHandler handler) diff --git a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI/Windows.UI.Color.cs b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI/Windows.UI.Color.cs index f66ad04b79..aef6921859 100644 --- a/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI/Windows.UI.Color.cs +++ b/src/WinRT.Projection.Writer/Resources/Additions/Windows.UI/Windows.UI.Color.cs @@ -31,6 +31,9 @@ readonly string IFormattable.ToString(string format, IFormatProvider provider) private readonly string ConvertToString(string format, IFormatProvider provider) { +#if CSWINRT_REFERENCE_PROJECTION + throw null; +#else if (format == null) { DefaultInterpolatedStringHandler handler = new(1, 4, provider, stackalloc char[32]); @@ -60,6 +63,7 @@ private readonly string ConvertToString(string format, IFormatProvider provider) handler.AppendFormatted(B, format); return handler.ToStringAndClear(); } +#endif } } } \ No newline at end of file diff --git a/src/WinRT.Projection.Writer/Resources/Base/AssemblyAttributes.cs b/src/WinRT.Projection.Writer/Resources/Base/AssemblyAttributes.cs new file mode 100644 index 0000000000..4df31b8f82 --- /dev/null +++ b/src/WinRT.Projection.Writer/Resources/Base/AssemblyAttributes.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#if CSWINRT_REFERENCE_PROJECTION +#pragma warning disable CSWINRT3004 // "Type or member '...' is a private implementation detail" +[assembly: WindowsRuntime.InteropServices.WindowsRuntimeReferenceAssembly] +#else +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: DisableRuntimeMarshallingAttribute] +[assembly: AssemblyMetadata("IsTrimmable", "True")] +[assembly: AssemblyMetadata("IsAotCompatible", "True")] +#endif \ No newline at end of file diff --git a/src/WinRT.Projection.Writer/Resources/Base/InspectableVftbl.cs b/src/WinRT.Projection.Writer/Resources/Base/InspectableVftbl.cs deleted file mode 100644 index d11da42786..0000000000 --- a/src/WinRT.Projection.Writer/Resources/Base/InspectableVftbl.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#if CSWINRT_REFERENCE_PROJECTION -[assembly: WindowsRuntime.InteropServices.WindowsRuntimeReferenceAssembly] -#else -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using Windows.Foundation; - -[assembly: DisableRuntimeMarshallingAttribute] -[assembly: AssemblyMetadata("IsTrimmable", "True")] -[assembly: AssemblyMetadata("IsAotCompatible", "True")] - -namespace WindowsRuntime.InteropServices; - -[StructLayout(LayoutKind.Sequential)] -internal unsafe struct IInspectableVftbl -{ - public delegate* unmanaged[MemberFunction] QueryInterface; - public delegate* unmanaged[MemberFunction] AddRef; - public delegate* unmanaged[MemberFunction] Release; - public delegate* unmanaged[MemberFunction] GetIids; - public delegate* unmanaged[MemberFunction] GetRuntimeClassName; - public delegate* unmanaged[MemberFunction] GetTrustLevel; -} - -[StructLayout(LayoutKind.Sequential)] -internal unsafe struct ReferenceVftbl -{ - public delegate* unmanaged[MemberFunction] QueryInterface; - public delegate* unmanaged[MemberFunction] AddRef; - public delegate* unmanaged[MemberFunction] Release; - public delegate* unmanaged[MemberFunction] GetIids; - public delegate* unmanaged[MemberFunction] GetRuntimeClassName; - public delegate* unmanaged[MemberFunction] GetTrustLevel; - public delegate* unmanaged[MemberFunction] get_Value; -} - -[StructLayout(LayoutKind.Sequential)] -internal unsafe struct IUnknownVftbl -{ - public delegate* unmanaged[MemberFunction] QueryInterface; - public delegate* unmanaged[MemberFunction] AddRef; - public delegate* unmanaged[MemberFunction] Release; -} -#endif \ No newline at end of file diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs index bc1c1b1492..79da463700 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyAttribute.cs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE - using System; +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +using System.ComponentModel; +#endif namespace WindowsRuntime.InteropServices; @@ -17,7 +18,13 @@ namespace WindowsRuntime.InteropServices; /// /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] -[WindowsRuntimeImplementationOnlyMember] +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +[Obsolete( + WindowsRuntimeConstants.WindowsRuntimeComponentAssemblyObsoleteMessage, + DiagnosticId = WindowsRuntimeConstants.WindowsRuntimeComponentAssemblyObsoleteDiagnosticId, + UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] +[EditorBrowsable(EditorBrowsableState.Never)] +#endif public sealed class WindowsRuntimeComponentAssemblyAttribute : Attribute { /// diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs index 484d3322d3..5c14c13308 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeComponentAssemblyExportsTypeAttribute.cs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE - using System; +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +using System.ComponentModel; +#endif namespace WindowsRuntime.InteropServices; @@ -16,7 +17,13 @@ namespace WindowsRuntime.InteropServices; /// /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] -[WindowsRuntimeImplementationOnlyMember] +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +[Obsolete( + WindowsRuntimeConstants.WindowsRuntimeComponentAssemblyObsoleteMessage, + DiagnosticId = WindowsRuntimeConstants.WindowsRuntimeComponentAssemblyObsoleteDiagnosticId, + UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] +[EditorBrowsable(EditorBrowsableState.Never)] +#endif public sealed class WindowsRuntimeComponentAssemblyExportsTypeAttribute : Attribute { /// diff --git a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs index a7d2d0a06c..d13a59f423 100644 --- a/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs +++ b/src/WinRT.Runtime2/InteropServices/Attributes/WindowsRuntimeReferenceAssemblyAttribute.cs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#define WINDOWS_RUNTIME_IMPLEMENTATION_ONLY_FILE - using System; +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +using System.ComponentModel; +#endif namespace WindowsRuntime.InteropServices; @@ -14,11 +15,20 @@ namespace WindowsRuntime.InteropServices; /// for Windows Runtime projections consumed directly from a local project reference. /// /// -/// This attribute is emitted by the CsWinRT generator, and it is not meant to be used directly. +/// This attribute is emitted by the CsWinRT generator, and it is not meant to be used directly. Unlike most other CsWinRT +/// implementation details, it is not stripped from the WinRT.Runtime.dll reference assembly: it is applied (via +/// [assembly: WindowsRuntimeReferenceAssembly]) to the reference projection assemblies that ship in Windows Runtime +/// projection NuGet packages, so it must remain resolvable when those assemblies are consumed. /// /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] -[WindowsRuntimeImplementationOnlyMember] +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +[Obsolete( + WindowsRuntimeConstants.WindowsRuntimeReferenceAssemblyObsoleteMessage, + DiagnosticId = WindowsRuntimeConstants.WindowsRuntimeReferenceAssemblyObsoleteDiagnosticId, + UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] +[EditorBrowsable(EditorBrowsableState.Never)] +#endif public sealed class WindowsRuntimeReferenceAssemblyAttribute : Attribute { /// diff --git a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs index dfddd5369b..f5d212dc26 100644 --- a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs +++ b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/DynamicInterfaceCastableImplementationTypeMapGroup.cs @@ -1,6 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +using System; +using System.ComponentModel; +#endif + namespace WindowsRuntime.InteropServices; /// @@ -10,7 +15,13 @@ namespace WindowsRuntime.InteropServices; /// /// This type is only meant to be used as type map group for APIs. /// -[WindowsRuntimeImplementationOnlyMember] +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +[Obsolete( + WindowsRuntimeConstants.WindowsRuntimeTypeMapGroupObsoleteMessage, + DiagnosticId = WindowsRuntimeConstants.WindowsRuntimeTypeMapGroupObsoleteDiagnosticId, + UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] +[EditorBrowsable(EditorBrowsableState.Never)] +#endif public abstract class DynamicInterfaceCastableImplementationTypeMapGroup { /// diff --git a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs index b124e507a5..80aab02a3b 100644 --- a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs +++ b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeComWrappersTypeMapGroup.cs @@ -1,6 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +using System; +using System.ComponentModel; +#endif + namespace WindowsRuntime.InteropServices; /// @@ -9,7 +14,13 @@ namespace WindowsRuntime.InteropServices; /// /// This type is only meant to be used as type map group for APIs. /// -[WindowsRuntimeImplementationOnlyMember] +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +[Obsolete( + WindowsRuntimeConstants.WindowsRuntimeTypeMapGroupObsoleteMessage, + DiagnosticId = WindowsRuntimeConstants.WindowsRuntimeTypeMapGroupObsoleteDiagnosticId, + UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] +[EditorBrowsable(EditorBrowsableState.Never)] +#endif public abstract class WindowsRuntimeComWrappersTypeMapGroup { /// diff --git a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs index 31b2121757..1916754edc 100644 --- a/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs +++ b/src/WinRT.Runtime2/InteropServices/TypeMapGroups/WindowsRuntimeMetadataTypeMapGroup.cs @@ -1,17 +1,26 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY using System; +using System.ComponentModel; +#endif namespace WindowsRuntime.InteropServices; /// -/// The type map group placeholder for all Windows Runtime types that need to support marshalling. +/// The type map group placeholder for all Windows Runtime types that need to support marshalling. /// /// /// This type is only meant to be used as type map group for APIs. /// -[WindowsRuntimeImplementationOnlyMember] +#if WINDOWS_RUNTIME_REFERENCE_ASSEMBLY +[Obsolete( + WindowsRuntimeConstants.WindowsRuntimeTypeMapGroupObsoleteMessage, + DiagnosticId = WindowsRuntimeConstants.WindowsRuntimeTypeMapGroupObsoleteDiagnosticId, + UrlFormat = WindowsRuntimeConstants.CsWinRTDiagnosticsUrlFormat)] +[EditorBrowsable(EditorBrowsableState.Never)] +#endif public abstract class WindowsRuntimeMetadataTypeMapGroup { /// diff --git a/src/WinRT.Runtime2/InteropServices/Vtables/IInspectableVftbl.cs b/src/WinRT.Runtime2/InteropServices/Vtables/IInspectableVftbl.cs index 9db00a22d7..2a4bb7361a 100644 --- a/src/WinRT.Runtime2/InteropServices/Vtables/IInspectableVftbl.cs +++ b/src/WinRT.Runtime2/InteropServices/Vtables/IInspectableVftbl.cs @@ -6,14 +6,17 @@ using System.Runtime.InteropServices; using Windows.Foundation; +#pragma warning disable CS1591 + namespace WindowsRuntime.InteropServices; /// /// Binding type for the IInspectable interface vtable. /// /// +[WindowsRuntimeImplementationOnlyMember] [StructLayout(LayoutKind.Sequential)] -internal unsafe struct IInspectableVftbl +public unsafe struct IInspectableVftbl { public delegate* unmanaged[MemberFunction] QueryInterface; public delegate* unmanaged[MemberFunction] AddRef; @@ -36,7 +39,7 @@ internal unsafe struct IInspectableVftbl /// /// The HRESULT for the operation. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static HRESULT GetIidsUnsafe(void* thisPtr, uint* iidCount, Guid** iids) + internal static HRESULT GetIidsUnsafe(void* thisPtr, uint* iidCount, Guid** iids) { return ((IInspectableVftbl*)*(void***)thisPtr)->GetIids(thisPtr, iidCount, iids); } @@ -48,7 +51,7 @@ public static HRESULT GetIidsUnsafe(void* thisPtr, uint* iidCount, Guid** iids) /// The fully qualified name of the current Windows Runtime object. /// The HRESULT for the operation. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static HRESULT GetRuntimeClassNameUnsafe(void* thisPtr, HSTRING* className) + internal static HRESULT GetRuntimeClassNameUnsafe(void* thisPtr, HSTRING* className) { return ((IInspectableVftbl*)*(void***)thisPtr)->GetRuntimeClassName(thisPtr, className); } @@ -60,7 +63,7 @@ public static HRESULT GetRuntimeClassNameUnsafe(void* thisPtr, HSTRING* classNam /// The trust level of the current Windows Runtime object. The default is . /// This method always returns S_OK. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static HRESULT GetTrustLevelUnsafe(void* thisPtr, TrustLevel* trustLevel) + internal static HRESULT GetTrustLevelUnsafe(void* thisPtr, TrustLevel* trustLevel) { return ((IInspectableVftbl*)*(void***)thisPtr)->GetTrustLevel(thisPtr, trustLevel); } diff --git a/src/WinRT.Runtime2/InteropServices/Vtables/IReferenceVftbl.cs b/src/WinRT.Runtime2/InteropServices/Vtables/IReferenceVftbl.cs index 8f1c892b85..44ae96a4e3 100644 --- a/src/WinRT.Runtime2/InteropServices/Vtables/IReferenceVftbl.cs +++ b/src/WinRT.Runtime2/InteropServices/Vtables/IReferenceVftbl.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; using Windows.Foundation; -#pragma warning disable IDE1006 +#pragma warning disable CS1591, IDE1006 namespace WindowsRuntime.InteropServices; @@ -14,8 +14,9 @@ namespace WindowsRuntime.InteropServices; /// Binding type for the IReference`1 interface vtable. /// /// +[WindowsRuntimeImplementationOnlyMember] [StructLayout(LayoutKind.Sequential)] -internal unsafe struct IReferenceVftbl +public unsafe struct IReferenceVftbl { public delegate* unmanaged[MemberFunction] QueryInterface; public delegate* unmanaged[MemberFunction] AddRef; @@ -32,7 +33,7 @@ internal unsafe struct IReferenceVftbl /// The resulting value. /// The HRESULT for the operation. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static HRESULT get_ValueUnsafe(void* thisPtr, void* value) + internal static HRESULT get_ValueUnsafe(void* thisPtr, void* value) { return ((IReferenceVftbl*)*(void***)thisPtr)->get_Value(thisPtr, value); } diff --git a/src/WinRT.Runtime2/InteropServices/Vtables/IUnknownVftbl.cs b/src/WinRT.Runtime2/InteropServices/Vtables/IUnknownVftbl.cs index 1ef471420d..36cdc3cbb5 100644 --- a/src/WinRT.Runtime2/InteropServices/Vtables/IUnknownVftbl.cs +++ b/src/WinRT.Runtime2/InteropServices/Vtables/IUnknownVftbl.cs @@ -5,14 +5,17 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +#pragma warning disable CS1591 + namespace WindowsRuntime.InteropServices; /// /// Binding type for the IUnknown interface vtable. /// /// +[WindowsRuntimeImplementationOnlyMember] [StructLayout(LayoutKind.Sequential)] -internal unsafe struct IUnknownVftbl +public unsafe struct IUnknownVftbl { public delegate* unmanaged[MemberFunction] QueryInterface; public delegate* unmanaged[MemberFunction] AddRef; @@ -26,7 +29,7 @@ internal unsafe struct IUnknownVftbl /// The address of a pointer to an interface with the IID specified in the parameter. /// This method returns S_OK if the interface is supported, and E_NOINTERFACE otherwise. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static HRESULT QueryInterfaceUnsafe(void* thisPtr, Guid* riid, void** ppvObject) + internal static HRESULT QueryInterfaceUnsafe(void* thisPtr, Guid* riid, void** ppvObject) { return ((IUnknownVftbl*)*(void***)thisPtr)->QueryInterface(thisPtr, riid, ppvObject); } @@ -36,7 +39,7 @@ public static HRESULT QueryInterfaceUnsafe(void* thisPtr, Guid* riid, void** ppv /// The pointer to an interface with the IID specified in the parameter. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static HRESULT QueryInterfaceUnsafe(void* thisPtr, in Guid iid, out void* pvObject) + internal static HRESULT QueryInterfaceUnsafe(void* thisPtr, in Guid iid, out void* pvObject) { fixed (Guid* riid = &iid) fixed (void** ppvObject = &pvObject) @@ -51,7 +54,7 @@ public static HRESULT QueryInterfaceUnsafe(void* thisPtr, in Guid iid, out void* /// The target COM object. /// The method returns the new reference count. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint AddRefUnsafe(void* thisPtr) + internal static uint AddRefUnsafe(void* thisPtr) { return ((IUnknownVftbl*)*(void***)thisPtr)->AddRef(thisPtr); } @@ -62,7 +65,7 @@ public static uint AddRefUnsafe(void* thisPtr) /// The target COM object. /// The method returns the new reference count. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint ReleaseUnsafe(void* thisPtr) + internal static uint ReleaseUnsafe(void* thisPtr) { return ((IUnknownVftbl*)*(void***)thisPtr)->Release(thisPtr); } diff --git a/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs b/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs index befb33eb05..b6609a3f28 100644 --- a/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs +++ b/src/WinRT.Runtime2/Properties/WindowsRuntimeConstants.cs @@ -22,6 +22,51 @@ internal static class WindowsRuntimeConstants /// public const string WindowsRuntimeObjectConstructorObsoleteDiagnosticId = "CSWINRT3001"; + /// + /// A message for the type map group types (see the WindowsRuntime.InteropServices type map group placeholders). + /// + public const string WindowsRuntimeTypeMapGroupObsoleteMessage = + "This type is a private implementation detail, and it must never be used directly. It is only meant to be used as a type map " + + "group type argument for the 'System.Runtime.InteropServices.TypeMapping' APIs, in marshalling code generated by CsWinRT " + + "(produced by 'cswinrtinteropgen.exe' and by the CsWinRT source generator). It is not considered part of the versioned API " + + "surface, and it may be modified or removed across any version change for 'WinRT.Runtime.dll'. Using it in user code is " + + "undefined behavior and not supported."; + + /// + /// The diagnostic id for the type map group types. + /// + public const string WindowsRuntimeTypeMapGroupObsoleteDiagnosticId = "CSWINRT3002"; + + /// + /// A message for the Windows Runtime component assembly attributes (see WindowsRuntimeComponentAssemblyAttribute and WindowsRuntimeComponentAssemblyExportsTypeAttribute). + /// + public const string WindowsRuntimeComponentAssemblyObsoleteMessage = + "This attribute is a private implementation detail, and it must never be used directly. It is only meant to be applied to " + + "authored Windows Runtime component assemblies by CsWinRT (produced by the CsWinRT source generator), to mark them and " + + "identify their generated activation factory entry point. It is not considered part of the versioned API surface, and it " + + "may be modified or removed across any version change for 'WinRT.Runtime.dll'. Using it in user code is undefined behavior " + + "and not supported."; + + /// + /// The diagnostic id for the Windows Runtime component assembly attributes. + /// + public const string WindowsRuntimeComponentAssemblyObsoleteDiagnosticId = "CSWINRT3003"; + + /// + /// A message for the WindowsRuntimeReferenceAssemblyAttribute type. + /// + public const string WindowsRuntimeReferenceAssemblyObsoleteMessage = + "This attribute is a private implementation detail, and it must never be used directly. It is only meant to be applied to " + + "generated Windows Runtime projection assemblies by CsWinRT (produced by 'cswinrtprojectiongen.exe' and " + + "'cswinrtprojectionrefgen.exe'), to identify them as containing projected Windows Runtime APIs. It is not considered part " + + "of the versioned API surface, and it may be modified or removed across any version change for 'WinRT.Runtime.dll'. Using " + + "it in user code is undefined behavior and not supported."; + + /// + /// The diagnostic id for the WindowsRuntimeReferenceAssemblyAttribute type. + /// + public const string WindowsRuntimeReferenceAssemblyObsoleteDiagnosticId = "CSWINRT3004"; + /// /// The URL format for all custom diagnostics for CsWinRT. /// diff --git a/src/WinRT.Runtime2/WinRT.Runtime.csproj b/src/WinRT.Runtime2/WinRT.Runtime.csproj index 74e4743a30..70c3ae673d 100644 --- a/src/WinRT.Runtime2/WinRT.Runtime.csproj +++ b/src/WinRT.Runtime2/WinRT.Runtime.csproj @@ -168,12 +168,29 @@ + + + + + - + + diff --git a/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs b/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs index 727f34a9f0..a7d652be2a 100644 --- a/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs +++ b/src/WinRT.Runtime2/Windows.Foundation/TrustLevel.cs @@ -10,9 +10,6 @@ namespace Windows.Foundation; /// /// Represents the trust level of an activatable class. /// -/// -/// This type is required for ABI projection of Windows Runtime types, but marshalling it is not supported. -/// /// [WindowsRuntimeImplementationOnlyMember] public enum TrustLevel diff --git a/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs b/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs index f97858b6ce..8c4a1d3c8b 100644 --- a/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs +++ b/src/WinRT.Runtime2/Windows.UI.Xaml.Interop/TypeKind.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using WindowsRuntime; namespace Windows.UI.Xaml.Interop; @@ -9,9 +8,6 @@ namespace Windows.UI.Xaml.Interop; /// /// Provides basic guidance about the origin of a type. /// -/// -/// This type is required for ABI projection of the class, but marshalling it is not supported. -/// /// [WindowsRuntimeImplementationOnlyMember] public enum TypeKind diff --git a/src/build.cmd b/src/build.cmd index ab4c18a5eb..e7342f9756 100644 --- a/src/build.cmd +++ b/src/build.cmd @@ -314,6 +314,23 @@ set run_cswinrt_generator_task=%this_dir%WinRT.Generator.Tasks\bin\%cswinrt_conf rem Now call pack echo Creating nuget package call :exec %nuget_dir%\nuget pack %this_dir%..\nuget\Microsoft.Windows.CsWinRT.nuspec -Properties interop_winmd=%interop_winmd%;net10_runtime=%net10_runtime%;net10_runtime_ref=%net10_runtime_ref%;net10_runtime_ref_xml=%net10_runtime_ref_xml%;source_generator=%source_generator%;cswinrt_nuget_version=%cswinrt_version_string%;winrt_host_x86=%winrt_host_x86%;winrt_host_x64=%winrt_host_x64%;winrt_host_arm=%winrt_host_arm%;winrt_host_arm64=%winrt_host_arm64%;winrt_host_resource_x86=%winrt_host_resource_x86%;winrt_host_resource_x64=%winrt_host_resource_x64%;winrt_host_resource_arm=%winrt_host_resource_arm%;winrt_host_resource_arm64=%winrt_host_resource_arm64%;winrt_shim=%winrt_shim%;cswinrtinteropgen_x64=%cswinrtinteropgen_x64%;cswinrtinteropgen_arm64=%cswinrtinteropgen_arm64%;cswinrtimplgen_x64=%cswinrtimplgen_x64%;cswinrtimplgen_arm64=%cswinrtimplgen_arm64%;cswinrtprojectiongen_x64=%cswinrtprojectiongen_x64%;cswinrtprojectiongen_arm64=%cswinrtprojectiongen_arm64%;cswinrtprojectionrefgen_x64=%cswinrtprojectionrefgen_x64%;cswinrtprojectionrefgen_arm64=%cswinrtprojectionrefgen_arm64%;cswinrtwinmdgen_x64=%cswinrtwinmdgen_x64%;cswinrtwinmdgen_arm64=%cswinrtwinmdgen_arm64%;run_cswinrt_generator_task=%run_cswinrt_generator_task%; -OutputDirectory %cswinrt_bin_dir% -NonInteractive -Verbosity Detailed -NoPackageAnalysis + +:smoketest +rem Build and run the end-to-end smoke tests against the just-built NuGet package. These +rem verify that the real package (ref/lib assemblies, generators, and build targets) works +rem for a consuming app, a component author, and a projection author, fully isolated from the +rem repo build infrastructure. They run only on x64 (matching the native build tools packaged +rem for the host architecture) and can be skipped by setting 'cswinrt_run_smoke_tests=false'. +if /I not "%cswinrt_platform%"=="x64" goto :eof +if /I "%cswinrt_run_smoke_tests%"=="false" goto :eof + +echo Running smoke tests for %cswinrt_platform% %cswinrt_configuration% +call :exec powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%this_dir%Tests\SmokeTests\run-smoke-tests.ps1" -PackageSource "%cswinrt_bin_dir%" -PackageVersion %cswinrt_version_string% -Configuration %cswinrt_configuration% +if ErrorLevel 1 ( + echo. + echo ERROR: Smoke tests failed + exit /b !ErrorLevel! +) goto :eof :exec