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
-#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()
{