From a0b8c3782584183aa0a49b69c63062a6456b11d7 Mon Sep 17 00:00:00 2001 From: Joshua Larkin <70237359+j0shuams@users.noreply.github.com> Date: Fri, 29 Oct 2021 12:48:13 -0700 Subject: [PATCH] Embedded sources: cswinrt (#1009) --- src/WinRT.Runtime/TypeNameSupport.cs | 3 + src/cswinrt/code_writers.h | 60 +++++--- src/cswinrt/main.cpp | 3 + src/cswinrt/settings.h | 1 + src/cswinrt/strings/ComInteropHelpers.cs | 131 ++++++++++++++---- src/cswinrt/strings/WinRT.cs | 4 +- .../Microsoft.UI.Xaml.Controls.Primitives.cs | 14 +- .../Microsoft.UI.Xaml.Media.Animation.cs | 42 +++++- .../Microsoft.UI.Xaml.Media.Media3D.cs | 14 +- .../Microsoft.UI.Xaml.Media.cs | 14 +- .../Microsoft.UI.Xaml/Microsoft.UI.Xaml.cs | 84 +++++++++-- .../additions/Windows.Foundation/AsyncInfo.cs | 11 +- .../TaskToAsyncActionAdapter.cs | 2 +- .../TaskToAsyncActionWithProgressAdapter.cs | 2 +- .../TaskToAsyncInfoAdapter.cs | 2 +- .../TaskToAsyncOperationAdapter.cs | 2 +- ...TaskToAsyncOperationWithProgressAdapter.cs | 2 +- .../Windows.Foundation/Windows.Foundation.cs | 7 +- .../IBufferByteAccess.cs | 2 +- .../Windows.Storage.Streams/IMarshal.cs | 16 +-- .../NetFxToWinRtStreamAdapter.cs | 6 +- .../StreamOperationsImplementation.cs | 2 +- .../WinRtToNetFxStreamAdapter.cs | 14 +- .../WindowsRuntimeBuffer.cs | 7 +- .../WindowsRuntimeBufferExtensions.cs | 43 +++--- .../WindowsRuntimeStreamExtensions.cs | 9 +- .../IStorageFolderHandleAccess.cs | 2 +- .../IStorageItemHandleAccess.cs | 2 +- .../WindowsRuntimeStorageExtensions.cs | 11 +- .../additions/Windows.UI/Windows.UI.cs | 14 +- 30 files changed, 397 insertions(+), 129 deletions(-) diff --git a/src/WinRT.Runtime/TypeNameSupport.cs b/src/WinRT.Runtime/TypeNameSupport.cs index d7a55d57c..4bc0b025c 100644 --- a/src/WinRT.Runtime/TypeNameSupport.cs +++ b/src/WinRT.Runtime/TypeNameSupport.cs @@ -26,6 +26,9 @@ enum TypeNameGenerationFlags NoCustomTypeName = 0x2 } +#if EMBED + internal +#endif static class TypeNameSupport { private static List projectionAssemblies = new List(); diff --git a/src/cswinrt/code_writers.h b/src/cswinrt/code_writers.h index 88068cc3f..23cf6b6e4 100644 --- a/src/cswinrt/code_writers.h +++ b/src/cswinrt/code_writers.h @@ -64,6 +64,11 @@ namespace cswinrt return w.write_temp("%_%", method.Name(), get_vmethod_index(type, method)); } + std::string internal_if_embedded() + { + return (settings.embedded) ? "internal" : "public"; + } + bool is_type_blittable(type_semantics const& semantics, bool for_array = false) { return call(semantics, @@ -2813,11 +2818,12 @@ db_path.stem().string()); void write_static_class(writer& w, TypeDef const& type) { - w.write(R"(%%public static class % + w.write(R"(%%% static class % { %})", bind(type), bind(type, true), + internal_if_embedded(), bind(type, typedef_name_type::Projected, false), bind(type) ); @@ -5412,12 +5418,13 @@ IInspectableVftbl = global::WinRT.IInspectable.Vftbl.AbiToProjectionVftable, { auto type_name = write_type_name_temp(w, type); - w.write(R"(%%public sealed class %: Attribute + w.write(R"(%%% sealed class %: Attribute { %} )", bind(type), bind(type, true), + internal_if_embedded(), type_name, [&](writer& w) { @@ -5453,7 +5460,7 @@ IInspectableVftbl = global::WinRT.IInspectable.Vftbl.AbiToProjectionVftable, bind(type), bind(type), bind(type, false), - is_exclusive_to(type) || is_projection_internal(type) ? "internal" : "public", + is_exclusive_to(type) || (is_projection_internal(type) || settings.embedded) ? "internal" : "public", type_name, bind(type, object_type{}, false, false), bind(type) @@ -5473,7 +5480,7 @@ IInspectableVftbl = global::WinRT.IInspectable.Vftbl.AbiToProjectionVftable, w.write(R"([global::WinRT.ObjectReferenceWrapper(nameof(_obj))] % -public unsafe class % : % +% unsafe class % : % { % internal static ObjectReference FromAbi(IntPtr thisPtr)% @@ -5492,6 +5499,7 @@ _obj = obj;% )", // Interface abi implementation bind(type), + internal_if_embedded(), type_name, bind(type, typedef_name_type::CCW, false), // Vftbl @@ -5560,10 +5568,11 @@ public static Guid PIID = Vftbl.PIID; if (!nongeneric_delegates.empty()) { w.write(R"([global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] -public static class % +% static class % { %} )", + internal_if_embedded(), nongenerics_class, bind_each(nongeneric_delegates)); } @@ -5578,7 +5587,10 @@ public static class % { % } -)", is_exclusive_to(iface) ? "internal" : "public", bind(iface, typedef_name_type::StaticAbiClass, false), bind(iface)); +)", + is_exclusive_to(iface) ? "internal" : internal_if_embedded(), + bind(iface, typedef_name_type::StaticAbiClass, false), + bind(iface)); } bool write_abi_interface(writer& w, TypeDef const& type) @@ -5659,10 +5671,11 @@ AbiToProjectionVftablePtr = ComWrappersSupport.AllocateVtableMemory(typeof(@), s if (!nongeneric_delegates.empty()) { w.write(R"([global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] -public static class % +% static class % { %} )", +internal_if_embedded(), nongenerics_class, bind_each(nongeneric_delegates)); } @@ -5821,7 +5834,7 @@ private readonly % _comp; } w.write(R"(%[global::WinRT.ProjectedRuntimeClass(nameof(_default))] -%public %class %%, IEquatable<%> +%% %class %%, IEquatable<%> { public %IntPtr ThisPtr => _default.ThisPtr; @@ -5859,6 +5872,7 @@ private % AsInternal(InterfaceTag<%> _) => _default; )", bind(type), bind(type, false), + internal_if_embedded(), bind(type), type_name, bind(type, base_semantics, true, false), @@ -5970,7 +5984,7 @@ _defaultLazy = new Lazy<%>(() => GetDefaultReference<%.Vftbl>()); w.write(R"(% [global::WinRT.ProjectedRuntimeClass(nameof(_default))] [global::WinRT.ObjectReferenceWrapper(nameof(_inner))] -%public %class %%, IWinRTObject, IEquatable<%> +%% %class %%, IWinRTObject, IEquatable<%> { private IntPtr ThisPtr => _inner == null ? (((IWinRTObject)this).NativeObject).ThisPtr : _inner.ThisPtr; @@ -6008,6 +6022,7 @@ private struct InterfaceTag{}; )", bind(type), bind(type, true), + internal_if_embedded(), bind(type), type_name, bind(type, base_semantics, true, false), @@ -6125,7 +6140,7 @@ global::System.Collections.Concurrent.ConcurrentDictionary value is null ? IntPtr.Zero : MarshalInterfaceHelper.GetAbi(value); @@ -6141,6 +6156,7 @@ public static void DisposeAbi(IntPtr abi) => MarshalInspectable.DisposeA public static unsafe void DisposeAbiArray(object box) => MarshalInspectable.DisposeAbiArray(box); } )", + internal_if_embedded(), abi_type_name, bind([&](writer& w) { @@ -6201,10 +6217,11 @@ public static unsafe void DisposeAbiArray(object box) => MarshalInspectable(type), bind(type, false), + internal_if_embedded(), bind(signature), bind(type, typedef_name_type::Projected, false), bind_list(", ", signature.params())); @@ -6223,7 +6240,7 @@ public static unsafe void DisposeAbiArray(object box) => MarshalInspectable _nativeDelegate; bool IWinRTObject.HasUnwrappableNativeObject => true; private volatile global::System.Collections.Concurrent.ConcurrentDictionary _queryInterfaceCache; @@ -6306,6 +6323,7 @@ private static unsafe int Do_Abi_Invoke% )", bind(type), + internal_if_embedded(), type.TypeName(), type_params, [&](writer& w) { @@ -6515,11 +6533,12 @@ public static Guid PIID = GuidGenerator.CreateIID(typeof(%));)", auto enum_underlying_type = is_flags_enum(type) ? "uint" : "int"; - w.write(R"(%%public enum % : % + w.write(R"(%%% enum % : % { )", bind(type), bind(type, true), + internal_if_embedded(), bind(type, typedef_name_type::Projected, false), enum_underlying_type); { for (auto&& field : type.FieldList()) @@ -6569,7 +6588,7 @@ public static Guid PIID = GuidGenerator.CreateIID(typeof(%));)", fields.emplace_back(field_info); } - w.write(R"(%%public struct %: IEquatable<%> + w.write(R"(%%% struct %: IEquatable<%> { % public %(%) @@ -6587,6 +6606,7 @@ public override int GetHashCode() => %; // struct bind(type), bind(type, true), + internal_if_embedded(), name, name, bind_each([](writer& w, auto&& field) @@ -6631,7 +6651,10 @@ public override int GetHashCode() => %; return; } - w.write("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]\npublic struct %\n{\n", bind(type, typedef_name_type::ABI, false)); + w.write("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]\n% struct %\n{\n", + internal_if_embedded(), + bind(type, typedef_name_type::ABI, false)); + for (auto&& field : type.FieldList()) { w.write("public "); @@ -6983,7 +7006,7 @@ bind(type) using System; namespace WinRT { -public static class Module +% static class Module { public static unsafe IntPtr GetActivationFactory(String runtimeClassId) {% @@ -6992,6 +7015,7 @@ return IntPtr.Zero; } } )", + internal_if_embedded(), bind_each([](writer& w, TypeDef const& type) { w.write(R"( diff --git a/src/cswinrt/main.cpp b/src/cswinrt/main.cpp index c3231a057..4488e5b0b 100644 --- a/src/cswinrt/main.cpp +++ b/src/cswinrt/main.cpp @@ -35,6 +35,7 @@ namespace cswinrt { "target", 0, 1, "", "Target TFM for projection. Omit for compatibility with newest TFM (net5.0)." }, { "component", 0, 0, {}, "Generate component projection." }, { "verbose", 0, 0, {}, "Show detailed progress information" }, + { "embedded", 0, 0, {}, "Generate the projection as internal."}, { "help", 0, option::no_max, {}, "Show detailed help" }, { "?", 0, option::no_max, {}, {} }, }; @@ -84,6 +85,7 @@ Where is one or more of: throw usage_exception{}; } + settings.verbose = args.exists("verbose"); auto target = args.value("target"); if (!target.empty() && target != "netstandard2.0" && !starts_with(target, "net5.0") && !starts_with(target, "net6.0")) @@ -92,6 +94,7 @@ Where is one or more of: } settings.netstandard_compat = target == "netstandard2.0"; settings.component = args.exists("component"); + settings.embedded = args.exists("embedded"); settings.input = args.files("input", database::is_database); for (auto && include : args.values("include")) diff --git a/src/cswinrt/settings.h b/src/cswinrt/settings.h index f943e98bb..5b497a37d 100644 --- a/src/cswinrt/settings.h +++ b/src/cswinrt/settings.h @@ -12,6 +12,7 @@ namespace cswinrt winmd::reader::filter filter; bool netstandard_compat{}; bool component{}; + bool embedded{}; }; extern settings_type settings; diff --git a/src/cswinrt/strings/ComInteropHelpers.cs b/src/cswinrt/strings/ComInteropHelpers.cs index 1e9319c22..9ddf2e75e 100644 --- a/src/cswinrt/strings/ComInteropHelpers.cs +++ b/src/cswinrt/strings/ComInteropHelpers.cs @@ -55,7 +55,12 @@ internal interface IWindowNative IntPtr WindowHandle { get; } } - public static class WindowNative +#if EMBED + internal +#else + public +#endif + static class WindowNative { public static IntPtr GetWindowHandle(object target) => target.As().WindowHandle; } @@ -68,7 +73,12 @@ internal interface IInitializeWithWindow void Initialize(IntPtr hwnd); } - public static class InitializeWithWindow +#if EMBED + internal +#else + public +#endif + static class InitializeWithWindow { public static void Initialize(object target, IntPtr hwnd) => target.As().Initialize(hwnd); } @@ -77,10 +87,15 @@ public static class InitializeWithWindow namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class DragDropManagerInterop +#if EMBED + internal +#else + public +#endif + static class DragDropManagerInterop { private static IDragDropManagerInterop dragDropManagerInterop = CoreDragDropManager.As(); @@ -96,10 +111,15 @@ public static CoreDragDropManager GetForWindow(IntPtr appWindow) namespace Windows.Graphics.Printing { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class PrintManagerInterop +#if EMBED + internal +#else + public +#endif + static class PrintManagerInterop { private static IPrintManagerInterop printManagerInterop = PrintManager.As(); @@ -121,10 +141,15 @@ public static IAsyncOperation ShowPrintUIForWindowAsync(IntPtr appWindow) namespace Windows.Media { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class SystemMediaTransportControlsInterop +#if EMBED + internal +#else + public +#endif + static class SystemMediaTransportControlsInterop { private static ISystemMediaTransportControlsInterop systemMediaTransportControlsInterop = SystemMediaTransportControls.As(); @@ -140,10 +165,15 @@ public static SystemMediaTransportControls GetForWindow(IntPtr appWindow) namespace Windows.Media.PlayTo { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class PlayToManagerInterop +#if EMBED + internal +#else + public +#endif + static class PlayToManagerInterop { private static IPlayToManagerInterop playToManagerInterop = PlayToManager.As(); @@ -164,10 +194,15 @@ public static void ShowPlayToUIForWindow(IntPtr appWindow) namespace Windows.Security.Credentials.UI { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class UserConsentVerifierInterop +#if EMBED + internal +#else + public +#endif + static class UserConsentVerifierInterop { private static IUserConsentVerifierInterop userConsentVerifierInterop = UserConsentVerifier.As(); @@ -183,10 +218,15 @@ public static IAsyncOperation RequestVerification namespace Windows.Security.Authentication.Web.Core { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class WebAuthenticationCoreManagerInterop +#if EMBED + internal +#else + public +#endif + static class WebAuthenticationCoreManagerInterop { private static IWebAuthenticationCoreManagerInterop webAuthenticationCoreManagerInterop = WebAuthenticationCoreManager.As(); @@ -208,10 +248,15 @@ public static IAsyncOperation RequestTokenWithWebAccountF namespace Windows.UI.ApplicationSettings { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class AccountsSettingsPaneInterop +#if EMBED + internal +#else + public +#endif + static class AccountsSettingsPaneInterop { private static IAccountsSettingsPaneInterop accountsSettingsPaneInterop = AccountsSettingsPane.As(); @@ -239,10 +284,15 @@ public static IAsyncAction ShowAddAccountForWindowAsync(IntPtr appWindow) namespace Windows.UI.Input { #if UAC_VERSION_3 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.14393.0")] #endif - public static class RadialControllerConfigurationInterop +#if EMBED + internal +#else + public +#endif + static class RadialControllerConfigurationInterop { private static IRadialControllerConfigurationInterop radialControllerConfigurationInterop = RadialControllerConfiguration.As(); @@ -254,10 +304,15 @@ public static RadialControllerConfiguration GetForWindow(IntPtr hwnd) } } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.14393.0")] #endif - public static class RadialControllerInterop +#if EMBED + internal +#else + public +#endif + static class RadialControllerInterop { private static IRadialControllerInterop radialControllerInterop = RadialController.As(); @@ -273,10 +328,15 @@ public static RadialController CreateForWindow(IntPtr hwnd) namespace Windows.UI.Input.Core { #if UAC_VERSION_4 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.15063.0")] #endif - public static class RadialControllerIndependentInputSourceInterop +#if EMBED + internal +#else + public +#endif + static class RadialControllerIndependentInputSourceInterop { private static IRadialControllerIndependentInputSourceInterop radialControllerIndependentInputSourceInterop = RadialControllerIndependentInputSource.As(); @@ -293,10 +353,15 @@ public static RadialControllerIndependentInputSource CreateForWindow(IntPtr hwnd namespace Windows.UI.Input.Spatial { #if UAC_VERSION_2 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10586.0")] #endif - public static class SpatialInteractionManagerInterop +#if EMBED + internal +#else + public +#endif + static class SpatialInteractionManagerInterop { private static ISpatialInteractionManagerInterop spatialInteractionManagerInterop = SpatialInteractionManager.As(); @@ -312,10 +377,15 @@ public static SpatialInteractionManager GetForWindow(IntPtr window) namespace Windows.UI.ViewManagement { #if UAC_VERSION_1 -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class InputPaneInterop +#if EMBED + internal +#else + public +#endif + static class InputPaneInterop { private static IInputPaneInterop inputPaneInterop = InputPane.As(); @@ -326,10 +396,15 @@ public static InputPane GetForWindow(IntPtr appWindow) } } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("Windows10.0.10240.0")] #endif - public static class UIViewSettingsInterop +#if EMBED + internal +#else + public +#endif + static class UIViewSettingsInterop { private static IUIViewSettingsInterop uIViewSettingsInterop = UIViewSettings.As(); diff --git a/src/cswinrt/strings/WinRT.cs b/src/cswinrt/strings/WinRT.cs index 02ed2092d..9bc7da49e 100644 --- a/src/cswinrt/strings/WinRT.cs +++ b/src/cswinrt/strings/WinRT.cs @@ -1,12 +1,14 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; +using System.Linq.Expressions; using System.Diagnostics; using WinRT.Interop; +using System.Runtime.CompilerServices; #pragma warning disable 0169 // The field 'xxx' is never used #pragma warning disable 0649 // Field 'xxx' is never assigned to, and will always have its default value diff --git a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Controls.Primitives/Microsoft.UI.Xaml.Controls.Primitives.cs b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Controls.Primitives/Microsoft.UI.Xaml.Controls.Primitives.cs index ff5bdd70b..3a39fd93e 100644 --- a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Controls.Primitives/Microsoft.UI.Xaml.Controls.Primitives.cs +++ b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Controls.Primitives/Microsoft.UI.Xaml.Controls.Primitives.cs @@ -5,7 +5,12 @@ namespace Microsoft.UI.Xaml.Controls.Primitives [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct GeneratorPosition +#if EMBED + internal +#else + public +#endif + struct GeneratorPosition { private int _index; private int _offset; @@ -55,7 +60,12 @@ public override bool Equals(object o) namespace ABI.Microsoft.UI.Xaml.Controls.Primitives { - public static class GeneratorPosition +#if EMBED + internal +#else + public +#endif + static class GeneratorPosition { public static string GetGuidSignature() => $"struct(Microsoft.UI.Xaml.Controls.Primitives.GeneratorPosition;i4;i4)"; } diff --git a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.cs b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.cs index 8eaf77eef..8eeb51f6a 100644 --- a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.cs +++ b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Animation/Microsoft.UI.Xaml.Media.Animation.cs @@ -5,7 +5,12 @@ namespace Microsoft.UI.Xaml.Media.Animation [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct KeyTime +#if EMBED + internal +#else + public +#endif + struct KeyTime { private TimeSpan _timeSpan; @@ -73,7 +78,12 @@ public TimeSpan TimeSpan } [global::WinRT.WindowsRuntimeType("Microsoft.UI")] - public enum RepeatBehaviorType +#if EMBED + internal +#else + public +#endif + enum RepeatBehaviorType { Count, Duration, @@ -82,7 +92,12 @@ public enum RepeatBehaviorType [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct RepeatBehavior : IFormattable +#if EMBED + internal +#else + public +#endif + struct RepeatBehavior : IFormattable { private double _Count; private TimeSpan _Duration; @@ -269,7 +284,12 @@ public override int GetHashCode() namespace ABI.Microsoft.UI.Xaml.Media.Animation { - public static class KeyTime +#if EMBED + internal +#else + public +#endif + static class KeyTime { public static string GetGuidSignature() { @@ -278,7 +298,12 @@ public static string GetGuidSignature() } } - public static class RepeatBehavior +#if EMBED + internal +#else + public +#endif + static class RepeatBehavior { public static string GetGuidSignature() { @@ -287,7 +312,12 @@ public static string GetGuidSignature() } } - public static class RepeatBehaviorType +#if EMBED + internal +#else + public +#endif + static class RepeatBehaviorType { public static string GetGuidSignature() => "enum(Microsoft.UI.Xaml.Media.Animation.RepeatBehaviorType;i4)"; } diff --git a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.cs b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.cs index d1d32c78f..8d1ca129e 100644 --- a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.cs +++ b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media.Media3D/Microsoft.UI.Xaml.Media.Media3D.cs @@ -5,7 +5,12 @@ namespace Microsoft.UI.Xaml.Media.Media3D [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct Matrix3D : IFormattable +#if EMBED + internal +#else + public +#endif + struct Matrix3D : IFormattable { // Assuming this matrix has fourth column of 0,0,0,1 and isn't identity this function: // Returns false if HasInverse is false, otherwise inverts the matrix. @@ -692,7 +697,12 @@ private static bool IsZero(double value) namespace ABI.Microsoft.UI.Xaml.Media.Media3D { - public static class Matrix3D +#if EMBED + internal +#else + public +#endif + static class Matrix3D { public static string GetGuidSignature() => $"struct(Microsoft.UI.Xaml.Media.Media3D.Matrix3D;f8;f8;f8;f8;f8;f8;f8;f8;f8;f8;f8;f8;f8;f8;f8;f8)"; diff --git a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.cs b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.cs index da2c6ace3..14a7436b5 100644 --- a/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.cs +++ b/src/cswinrt/strings/additions/Microsoft.UI.Xaml.Media/Microsoft.UI.Xaml.Media.cs @@ -5,7 +5,12 @@ namespace Microsoft.UI.Xaml.Media [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct Matrix : IFormattable +#if EMBED + internal +#else + public +#endif + struct Matrix : IFormattable { public Matrix(double m11, double m12, double m21, double m22, @@ -245,7 +250,12 @@ private static bool Equals(Matrix matrix1, Matrix matrix2) namespace ABI.Microsoft.UI.Xaml.Media { - public static class Matrix +#if EMBED + internal +#else + public +#endif + static class Matrix { public static string GetGuidSignature() => $"struct(Microsoft.UI.Xaml.Media.Matrix;f8;f8;f8;f8;f8;f8)"; } diff --git a/src/cswinrt/strings/additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.cs b/src/cswinrt/strings/additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.cs index f4b9fefeb..c96e1ff61 100644 --- a/src/cswinrt/strings/additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.cs +++ b/src/cswinrt/strings/additions/Microsoft.UI.Xaml/Microsoft.UI.Xaml.cs @@ -5,7 +5,12 @@ namespace Microsoft.UI.Xaml [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct CornerRadius +#if EMBED + internal +#else + public +#endif + struct CornerRadius { private double _TopLeft; private double _TopRight; @@ -146,7 +151,12 @@ public double BottomLeft } [global::WinRT.WindowsRuntimeType("Microsoft.UI")] - public enum GridUnitType +#if EMBED + internal +#else + public +#endif + enum GridUnitType { Auto = 0, Pixel, @@ -155,7 +165,12 @@ public enum GridUnitType [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct GridLength +#if EMBED + internal +#else + public +#endif + struct GridLength { private readonly double _unitValue; private readonly GridUnitType _unitType; @@ -267,7 +282,12 @@ internal string ToString(global::System.Globalization.CultureInfo cultureInfo) [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct Thickness +#if EMBED + internal +#else + public +#endif + struct Thickness { private double _Left; private double _Top; @@ -374,7 +394,12 @@ public override int GetHashCode() } [global::WinRT.WindowsRuntimeType("Microsoft.UI")] - public enum DurationType +#if EMBED + internal +#else + public +#endif + enum DurationType { Automatic, TimeSpan, @@ -383,7 +408,12 @@ public enum DurationType [global::WinRT.WindowsRuntimeType("Microsoft.UI")] [StructLayout(LayoutKind.Sequential)] - public struct Duration +#if EMBED + internal +#else + public +#endif + struct Duration { private readonly TimeSpan _timeSpan; private DurationType _durationType; @@ -669,12 +699,22 @@ public override string ToString() namespace ABI.Microsoft.UI.Xaml { - public static class CornerRadius +#if EMBED + internal +#else + public +#endif + static class CornerRadius { public static string GetGuidSignature() => $"struct(Microsoft.UI.Xaml.CornerRadius;f8;f8;f8;f8)"; } - public static class Duration +#if EMBED + internal +#else + public +#endif + static class Duration { public static string GetGuidSignature() { @@ -684,12 +724,22 @@ public static string GetGuidSignature() } } - public static class DurationType +#if EMBED + internal +#else + public +#endif + static class DurationType { public static string GetGuidSignature() => "enum(Microsoft.UI.Xaml.DurationType;i4)"; } - public static class GridLength +#if EMBED + internal +#else + public +#endif + static class GridLength { public static string GetGuidSignature() { @@ -698,12 +748,22 @@ public static string GetGuidSignature() } } - public static class GridUnitType +#if EMBED + internal +#else + public +#endif + static class GridUnitType { public static string GetGuidSignature() => "enum(Microsoft.UI.Xaml.GridUnitType;i4)"; } - public static class Thickness +#if EMBED + internal +#else + public +#endif + static class Thickness { public static string GetGuidSignature() => $"struct(Microsoft.UI.Xaml.Thickness;f8;f8;f8;f8)"; } diff --git a/src/cswinrt/strings/additions/Windows.Foundation/AsyncInfo.cs b/src/cswinrt/strings/additions/Windows.Foundation/AsyncInfo.cs index 25bff28ce..c43aaac31 100644 --- a/src/cswinrt/strings/additions/Windows.Foundation/AsyncInfo.cs +++ b/src/cswinrt/strings/additions/Windows.Foundation/AsyncInfo.cs @@ -15,10 +15,15 @@ namespace System.Runtime.InteropServices.WindowsRuntime /// When an asynchronous operation created by this factory is actually started (by calling Start()), /// the specified Task-provider delegate will be invoked to create the Task that will /// be wrapped by the to-WinRT adapter.

-#if !NETSTANDARD2_0 - [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] +#if NET + [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif - public static class AsyncInfo +#if EMBED + internal +#else + public +#endif + static class AsyncInfo { #region Factory methods for creating "normal" IAsyncInfo instances backed by a Task created by a pastProvider delegate diff --git a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionAdapter.cs b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionAdapter.cs index 9fd47c158..9a3b96781 100644 --- a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionAdapter.cs +++ b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionAdapter.cs @@ -11,7 +11,7 @@ namespace System.Threading.Tasks using System.Threading.Tasks; using global::Windows.Foundation; -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif internal class TaskToAsyncActionAdapter diff --git a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionWithProgressAdapter.cs b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionWithProgressAdapter.cs index b4eff2cd4..85971aedd 100644 --- a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionWithProgressAdapter.cs +++ b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncActionWithProgressAdapter.cs @@ -11,7 +11,7 @@ namespace System.Threading.Tasks using System.Threading.Tasks; using global::Windows.Foundation; -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif internal class TaskToAsyncActionWithProgressAdapter diff --git a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncInfoAdapter.cs b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncInfoAdapter.cs index 75a71ac7c..47774514c 100644 --- a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncInfoAdapter.cs +++ b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncInfoAdapter.cs @@ -18,7 +18,7 @@ namespace System.Threading.Tasks /// Implements a wrapper that allows to expose managed System.Threading.Tasks.Task objects as /// through the WinRT Windows.Foundation.IAsyncInfo interface. /// -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif internal class TaskToAsyncInfoAdapter diff --git a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationAdapter.cs b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationAdapter.cs index eee822ecb..23c216c1d 100644 --- a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationAdapter.cs +++ b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationAdapter.cs @@ -12,7 +12,7 @@ namespace System.Threading.Tasks using System.Threading.Tasks; using global::Windows.Foundation; -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif internal class TaskToAsyncOperationAdapter diff --git a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationWithProgressAdapter.cs b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationWithProgressAdapter.cs index a5b582854..450497719 100644 --- a/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationWithProgressAdapter.cs +++ b/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncOperationWithProgressAdapter.cs @@ -12,7 +12,7 @@ namespace System.Threading.Tasks using System.Threading.Tasks; using global::Windows.Foundation; -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif internal class TaskToAsyncOperationWithProgressAdapter diff --git a/src/cswinrt/strings/additions/Windows.Foundation/Windows.Foundation.cs b/src/cswinrt/strings/additions/Windows.Foundation/Windows.Foundation.cs index 6ff035b8d..8a1fa8ede 100644 --- a/src/cswinrt/strings/additions/Windows.Foundation/Windows.Foundation.cs +++ b/src/cswinrt/strings/additions/Windows.Foundation/Windows.Foundation.cs @@ -11,7 +11,12 @@ namespace System #if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif - public static class WindowsRuntimeSystemExtensions +#if EMBED + internal +#else + public +#endif + static class WindowsRuntimeSystemExtensions { public static Task AsTask(this IAsyncAction source, CancellationToken cancellationToken) { diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/IBufferByteAccess.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/IBufferByteAccess.cs index a25cad1eb..2b86bac62 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/IBufferByteAccess.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/IBufferByteAccess.cs @@ -17,7 +17,7 @@ namespace ABI.Windows.Storage.Streams using global::System.Runtime.InteropServices; using global::System.ComponentModel; -#if NETSTANDARD2_0 +#if !NET [global::WinRT.ObjectReferenceWrapper(nameof(_obj)), EditorBrowsable(EditorBrowsableState.Never)] [Guid("905a0fef-bc53-11df-8c49-001e4fc686da")] internal unsafe class IBufferByteAccess : global::Windows.Storage.Streams.IBufferByteAccess diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/IMarshal.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/IMarshal.cs index bca5115ad..d56dc3d2e 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/IMarshal.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/IMarshal.cs @@ -37,7 +37,7 @@ public unsafe struct Vftbl { internal global::WinRT.Interop.IUnknownVftbl IUnknownVftbl; -#if NETSTANDARD2_0 +#if !NET private void* _GetUnmarshalClass_0; public delegate* unmanaged[Stdcall] GetUnmarshalClass_0 { get => (delegate* unmanaged[Stdcall])_GetUnmarshalClass_0; set => _GetUnmarshalClass_0 = value; } private void* _GetMarshalSizeMax_1; @@ -66,7 +66,7 @@ public unsafe struct Vftbl static Vftbl() { -#if NETSTANDARD2_0 +#if !NET AbiToProjectionVftable = new Vftbl { IUnknownVftbl = global::WinRT.Interop.IUnknownVftbl.AbiToProjectionVftbl, @@ -94,7 +94,7 @@ static Vftbl() #endif } -#if !NETSTANDARD2_0 +#if NET [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] #endif private static int Do_Abi_GetUnmarshalClass_0(IntPtr thisPtr, Guid* riid, IntPtr pv, global::Com.MSHCTX dwDestContext, IntPtr pvDestContext, global::Com.MSHLFLAGS mshlFlags, Guid* pCid) @@ -111,7 +111,7 @@ private static int Do_Abi_GetUnmarshalClass_0(IntPtr thisPtr, Guid* riid, IntPtr return 0; } -#if !NETSTANDARD2_0 +#if NET [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] #endif private static int Do_Abi_GetMarshalSizeMax_1(IntPtr thisPtr, Guid* riid, IntPtr pv, global::Com.MSHCTX dwDestContext, IntPtr pvDestContext, global::Com.MSHLFLAGS mshlflags, uint* pSize) @@ -128,7 +128,7 @@ private static int Do_Abi_GetMarshalSizeMax_1(IntPtr thisPtr, Guid* riid, IntPtr return 0; } -#if !NETSTANDARD2_0 +#if NET [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] #endif private static int Do_Abi_MarshalInterface_2(IntPtr thisPtr, IntPtr pStm, Guid* riid, IntPtr pv, global::Com.MSHCTX dwDestContext, IntPtr pvDestContext, global::Com.MSHLFLAGS mshlflags) @@ -144,7 +144,7 @@ private static int Do_Abi_MarshalInterface_2(IntPtr thisPtr, IntPtr pStm, Guid* return 0; } -#if !NETSTANDARD2_0 +#if NET [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] #endif private static int Do_Abi_UnmarshalInterface_3(IntPtr thisPtr, IntPtr pStm, Guid* riid, IntPtr* ppv) @@ -161,7 +161,7 @@ private static int Do_Abi_UnmarshalInterface_3(IntPtr thisPtr, IntPtr pStm, Guid return 0; } -#if !NETSTANDARD2_0 +#if NET [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] #endif private static int Do_Abi_ReleaseMarshalData_4(IntPtr thisPtr, IntPtr pStm) @@ -177,7 +177,7 @@ private static int Do_Abi_ReleaseMarshalData_4(IntPtr thisPtr, IntPtr pStm) return 0; } -#if !NETSTANDARD2_0 +#if NET [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] #endif private static int Do_Abi_DisconnectObject_5(IntPtr thisPtr, uint dwReserved) diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/NetFxToWinRtStreamAdapter.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/NetFxToWinRtStreamAdapter.cs index 6336e178f..90fe7be96 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/NetFxToWinRtStreamAdapter.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/NetFxToWinRtStreamAdapter.cs @@ -224,7 +224,7 @@ void IDisposable.Dispose() #region IInputStream public interface -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public IAsyncOperationWithProgress ReadAsync(IBuffer buffer, uint count, InputStreamOptions options) @@ -289,7 +289,7 @@ public IAsyncOperationWithProgress ReadAsync(IBuffer buffer, uint #region IOutputStream public interface -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public IAsyncOperationWithProgress WriteAsync(IBuffer buffer) @@ -311,7 +311,7 @@ public IAsyncOperationWithProgress WriteAsync(IBuffer buffer) return StreamOperationsImplementation.WriteAsync_AbstractStream(str, buffer); } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public IAsyncOperation FlushAsync() diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/StreamOperationsImplementation.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/StreamOperationsImplementation.cs index cffe81635..b14a652a5 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/StreamOperationsImplementation.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/StreamOperationsImplementation.cs @@ -21,7 +21,7 @@ namespace Windows.Storage.Streams /// Moreover, knowledge about the actual runtime type of the IBuffer can also help choosing the optimal /// implementation. This type provides static methods that encapsulate the performance logic and can be used /// by NetFxToWinRtStreamAdapter. -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif internal static class StreamOperationsImplementation diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/WinRtToNetFxStreamAdapter.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/WinRtToNetFxStreamAdapter.cs index 6137e5553..fe410f4a6 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/WinRtToNetFxStreamAdapter.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/WinRtToNetFxStreamAdapter.cs @@ -392,7 +392,7 @@ public override void SetLength(long value) #region Reading -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif private IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state, bool usedByBlockingWrapper) @@ -498,7 +498,7 @@ public override int EndRead(IAsyncResult asyncResult) } } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) @@ -525,7 +525,7 @@ public override Task ReadAsync(byte[] buffer, int offset, int count, Cancel return ReadAsyncInternal(buffer, offset, count, cancellationToken); } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public override int Read(byte[] buffer, int offset, int count) @@ -537,7 +537,7 @@ public override int Read(byte[] buffer, int offset, int count) return bytesread; } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public override int ReadByte() @@ -639,7 +639,7 @@ public override void EndWrite(IAsyncResult asyncResult) } } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) @@ -738,7 +738,7 @@ public override void Flush() } } -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif public override Task FlushAsync(CancellationToken cancellationToken) @@ -765,7 +765,7 @@ public override Task FlushAsync(CancellationToken cancellationToken) // Moved it to the end while using Dev10 VS because it does not understand async and everything that follows looses intellisense. // Should move this code into the Reading regios once using Dev11 VS becomes the norm. -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] #endif private async Task ReadAsyncInternal(byte[] buffer, int offset, int count, CancellationToken cancellationToken) diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBuffer.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBuffer.cs index fc881a400..fb448ca70 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBuffer.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBuffer.cs @@ -18,7 +18,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime /// Contains an implementation of the WinRT IBuffer interface that conforms to all requirements on classes that implement that interface, /// such as implementing additional interfaces. /// - public sealed class WindowsRuntimeBuffer : IBuffer, IBufferByteAccess, IMarshal +#if EMBED + internal +#else + public +#endif + sealed class WindowsRuntimeBuffer : IBuffer, IBufferByteAccess, IMarshal { [DllImport("api-ms-win-core-winrt-robuffer-l1-1-0.dll")] private static extern int RoGetBufferMarshaler(out IntPtr bufferMarshalerPtr); diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBufferExtensions.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBufferExtensions.cs index 783ecc665..b069cd3e9 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBufferExtensions.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeBufferExtensions.cs @@ -13,9 +13,14 @@ namespace System.Runtime.InteropServices.WindowsRuntime /// /// Contains extension methods that expose operations on WinRT Windows.Foundation.IBuffer. /// - public static class WindowsRuntimeBufferExtensions +#if EMBED + internal +#else + public +#endif + static class WindowsRuntimeBufferExtensions { - #region (Byte []).AsBuffer extensions +#region (Byte []).AsBuffer extensions public static IBuffer AsBuffer(this byte[] source) { @@ -49,10 +54,10 @@ public static IBuffer AsBuffer(this byte[] source, int offset, int length, int c return new WindowsRuntimeBuffer(source, offset, length, capacity); } - #endregion (Byte []).AsBuffer extensions +#endregion (Byte []).AsBuffer extensions - #region (Byte []).CopyTo extensions for copying to an (IBuffer) +#region (Byte []).CopyTo extensions for copying to an (IBuffer) /// /// Copies the contents of source to destination starting at offset 0. @@ -104,10 +109,10 @@ public static void CopyTo(this byte[] source, int sourceIndex, IBuffer destinati Marshal.Copy(source, sourceIndex, destPtr, count); } - #endregion (Byte []).CopyTo extensions for copying to an (IBuffer) +#endregion (Byte []).CopyTo extensions for copying to an (IBuffer) - #region (IBuffer).ToArray extensions for copying to a new (Byte []) +#region (IBuffer).ToArray extensions for copying to a new (Byte []) public static byte[] ToArray(this IBuffer source) { @@ -132,10 +137,10 @@ public static byte[] ToArray(this IBuffer source, uint sourceIndex, int count) return destination; } - #endregion (IBuffer).ToArray extensions for copying to a new (Byte []) +#endregion (IBuffer).ToArray extensions for copying to a new (Byte []) - #region (IBuffer).CopyTo extensions for copying to a (Byte []) +#region (IBuffer).CopyTo extensions for copying to a (Byte []) public static void CopyTo(this IBuffer source, byte[] destination) { @@ -171,10 +176,10 @@ public static void CopyTo(this IBuffer source, uint sourceIndex, byte[] destinat Marshal.Copy(srcPtr, destination, destinationIndex, count); } - #endregion (IBuffer).CopyTo extensions for copying to a (Byte []) +#endregion (IBuffer).CopyTo extensions for copying to a (Byte []) - #region (IBuffer).CopyTo extensions for copying to an (IBuffer) +#region (IBuffer).CopyTo extensions for copying to an (IBuffer) public static void CopyTo(this IBuffer source, IBuffer destination) { @@ -239,10 +244,10 @@ public static void CopyTo(this IBuffer source, uint sourceIndex, IBuffer destina MemCopy(srcPtr, destPtr, count); } - #endregion (IBuffer).CopyTo extensions for copying to an (IBuffer) +#endregion (IBuffer).CopyTo extensions for copying to an (IBuffer) - #region Access to underlying array optimised for IBuffers backed by managed arrays (to avoid pinning) +#region Access to underlying array optimised for IBuffers backed by managed arrays (to avoid pinning) /// /// If the specified IBuffer is backed by a managed array, this method will return true and @@ -317,10 +322,10 @@ public static bool IsSameData(this IBuffer buffer, IBuffer otherBuffer) } } - #endregion Access to underlying array optimised for IBuffers backed by managed arrays (to avoid pinning) +#endregion Access to underlying array optimised for IBuffers backed by managed arrays (to avoid pinning) - #region Extensions for co-operation with memory streams (share mem stream data; expose data as managed/unmanaged mem stream) +#region Extensions for co-operation with memory streams (share mem stream data; expose data as managed/unmanaged mem stream) /// /// Creates a new IBuffer instance backed by the same memory as is backing the specified MemoryStream. /// The MemoryStream may re-sized in future, as a result the stream will be backed by a different memory region. @@ -416,10 +421,10 @@ public static Stream AsStream(this IBuffer source) } } - #endregion Extensions for co-operation with memory streams (share mem stream data; expose data as managed/unmanaged mem stream) +#endregion Extensions for co-operation with memory streams (share mem stream data; expose data as managed/unmanaged mem stream) - #region Extensions for direct by-offset access to buffer data elements +#region Extensions for direct by-offset access to buffer data elements public static byte GetByte(this IBuffer source, uint byteOffset) { @@ -442,10 +447,10 @@ public static byte GetByte(this IBuffer source, uint byteOffset) } } - #endregion Extensions for direct by-offset access to buffer data elements +#endregion Extensions for direct by-offset access to buffer data elements - #region Private plumbing +#region Private plumbing private class WindowsRuntimeBufferUnmanagedMemoryStream : UnmanagedMemoryStream { @@ -496,7 +501,7 @@ private static unsafe void MemCopy(IntPtr src, IntPtr dst, uint count) Marshal.Copy(tmp, 0, dst, bCount); return; } - #endregion Private plumbing +#endregion Private plumbing } // class WindowsRuntimeBufferExtensions } // namespace diff --git a/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeStreamExtensions.cs b/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeStreamExtensions.cs index 278da7b2b..e13d067d1 100644 --- a/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeStreamExtensions.cs +++ b/src/cswinrt/strings/additions/Windows.Storage.Streams/WindowsRuntimeStreamExtensions.cs @@ -17,7 +17,12 @@ namespace System.IO /// Contains extension methods for conversion between WinRT streams and managed streams. /// This class is the public facade for the stream adapters library. /// - public static class WindowsRuntimeStreamExtensions +#if EMBED + internal +#else + public +#endif + static class WindowsRuntimeStreamExtensions { #region Constants and static Fields @@ -32,7 +37,7 @@ private static readonly ConditionalWeakTable #endregion Constants and static Fields -#if !NETSTANDARD2_0 +#if NET #region Helpers diff --git a/src/cswinrt/strings/additions/Windows.Storage/IStorageFolderHandleAccess.cs b/src/cswinrt/strings/additions/Windows.Storage/IStorageFolderHandleAccess.cs index 084fb726b..6d53313de 100644 --- a/src/cswinrt/strings/additions/Windows.Storage/IStorageFolderHandleAccess.cs +++ b/src/cswinrt/strings/additions/Windows.Storage/IStorageFolderHandleAccess.cs @@ -26,7 +26,7 @@ namespace ABI.Windows.Storage using global::System; using global::System.ComponentModel; -#if NETSTANDARD2_0 +#if !NET [global::WinRT.ObjectReferenceWrapper(nameof(_obj)), EditorBrowsable(EditorBrowsableState.Never)] [Guid("DF19938F-5462-48A0-BE65-D2A3271A08D6")] internal unsafe class IStorageFolderHandleAccess : global::Windows.Storage.IStorageFolderHandleAccess diff --git a/src/cswinrt/strings/additions/Windows.Storage/IStorageItemHandleAccess.cs b/src/cswinrt/strings/additions/Windows.Storage/IStorageItemHandleAccess.cs index 468a08141..a797f91f2 100644 --- a/src/cswinrt/strings/additions/Windows.Storage/IStorageItemHandleAccess.cs +++ b/src/cswinrt/strings/additions/Windows.Storage/IStorageItemHandleAccess.cs @@ -22,7 +22,7 @@ namespace ABI.Windows.Storage using global::Microsoft.Win32.SafeHandles; using global::System.ComponentModel; -#if NETSTANDARD2_0 +#if !NET [global::WinRT.ObjectReferenceWrapper(nameof(_obj)), EditorBrowsable(EditorBrowsableState.Never)] [Guid("5CA296B2-2C25-4D22-B785-B885C8201E6A")] internal unsafe class IStorageItemHandleAccess : global::Windows.Storage.IStorageItemHandleAccess diff --git a/src/cswinrt/strings/additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs b/src/cswinrt/strings/additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs index 855d2b9b9..eb6837849 100644 --- a/src/cswinrt/strings/additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs +++ b/src/cswinrt/strings/additions/Windows.Storage/WindowsRuntimeStorageExtensions.cs @@ -11,14 +11,19 @@ namespace System.IO using global::Windows.Storage.FileProperties; using global::Windows.Storage.Streams; using System.Runtime.InteropServices; - + /// /// Contains extension methods that provide convenience helpers for WinRT IO. /// - public static class WindowsRuntimeStorageExtensions +#if EMBED + internal +#else + public +#endif + static class WindowsRuntimeStorageExtensions { // Net5-specific extension methods -#if !NETSTANDARD2_0 +#if NET [global::System.Runtime.Versioning.SupportedOSPlatform("windows10.0.10240.0")] public static Task OpenStreamForReadAsync(this IStorageFile windowsRuntimeFile) { diff --git a/src/cswinrt/strings/additions/Windows.UI/Windows.UI.cs b/src/cswinrt/strings/additions/Windows.UI/Windows.UI.cs index e3de81955..913b030a4 100644 --- a/src/cswinrt/strings/additions/Windows.UI/Windows.UI.cs +++ b/src/cswinrt/strings/additions/Windows.UI/Windows.UI.cs @@ -6,7 +6,12 @@ namespace Windows.UI [global::WinRT.WindowsRuntimeType("Windows.Foundation.UniversalApiContract")] [StructLayout(LayoutKind.Sequential)] - public struct Color : IFormattable +#if EMBED + internal +#else + public +#endif + struct Color : IFormattable { private byte _A; private byte _R; @@ -124,7 +129,12 @@ public bool Equals(Color color) namespace ABI.Windows.UI { - public static class Color +#if EMBED + internal +#else + public +#endif + static class Color { public static string GetGuidSignature() {