Skip to content

Commit

Permalink
Drop support for NetStandard 2.0, also means NetFx isn't supported fo…
Browse files Browse the repository at this point in the history
…r server anymore (clients can still be)
  • Loading branch information
shmuelie committed Aug 16, 2024
1 parent b805a17 commit 8c6b4e6
Show file tree
Hide file tree
Showing 9 changed files with 297 additions and 573 deletions.
319 changes: 154 additions & 165 deletions Shmuelie.WinRTServer.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,7 @@ public static HRESULT ActivateInstance(BaseActivationFactoryProxy* @this, IInspe
object managedInstance = factory.ActivateInstance();

using ComPtr<IUnknown> unkwnPtr = default;
unkwnPtr.Attach((IUnknown*)
#if NETSTANDARD
Marshal.GetIUnknownForObject(managedInstance)
#else
WinRT.ComWrappersSupport.CreateCCWForObject(managedInstance).GetRef()
#endif
);
unkwnPtr.Attach((IUnknown*)WinRT.ComWrappersSupport.CreateCCWForObject(managedInstance).GetRef());
HRESULT result = unkwnPtr.CopyTo(instance);
if (result != HRESULT.S_OK)
{
Expand Down
10 changes: 1 addition & 9 deletions src/Shmuelie.WinRTServer/Internal/BaseClassFactoryProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ public static HRESULT CreateInstance(BaseClassFactoryProxy* @this, IUnknown* pUn

if (riid->Equals(IUnknown.IID_Guid))
{
#if NETSTANDARD
*ppvObject = (void*)Marshal.GetIUnknownForObject(instance);
#else
*ppvObject = (void*)WinRT.ComWrappersSupport.CreateCCWForObject(instance).GetRef();
#endif
}
else
{
Expand All @@ -178,11 +174,7 @@ public static HRESULT CreateInstance(BaseClassFactoryProxy* @this, IUnknown* pUn
{
return HRESULT.E_UNEXPECTED;
}
#if NETSTANDARD
*ppvObject = (void*)Marshal.GetComInterfaceForObject(instance, t);
#else
* ppvObject = (void*)(nint)typeof(WinRT.MarshalInterface<>).MakeGenericType(t).GetMethod("FromManaged")!.Invoke(null, [instance])!;
#endif
*ppvObject = (void*)(nint)typeof(WinRT.MarshalInterface<>).MakeGenericType(t).GetMethod("FromManaged")!.Invoke(null, [instance])!;
}

factory.OnInstanceCreated(instance);
Expand Down
67 changes: 0 additions & 67 deletions src/Shmuelie.WinRTServer/Internal/UIntPtrExtensions.cs

This file was deleted.

13 changes: 2 additions & 11 deletions src/Shmuelie.WinRTServer/Shmuelie.WinRTServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@
<PropertyGroup>
<TargetPlatformVersion>10.0.22000.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<TargetFrameworks>netstandard2.0;net8.0-windows$(TargetPlatformVersion)</TargetFrameworks>
<TargetFramework>net8.0-windows$(TargetPlatformVersion)</TargetFramework>
<IsPackable>true</IsPackable>
<PackageReleaseNotes>Added support for modern .NET servers.</PackageReleaseNotes>
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
</PropertyGroup>
<!-- .NET Standard 2.0 polyfill packages -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
</ItemGroup>
<ItemGroup>
Expand Down
125 changes: 0 additions & 125 deletions src/Shmuelie.WinRTServer/Windows/shared/uuids/__uuidof.cs

This file was deleted.

18 changes: 2 additions & 16 deletions src/Shmuelie.WinRTServer/Windows/winrt/wrl/client/ComPtr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,10 @@ public readonly HRESULT CopyTo(ref T* ptr)
/// <param name="ptr">The target raw pointer to copy the address of the current COM object to.</param>
/// <returns>The result of <see cref="IUnknown.QueryInterface(Guid*, void**)"/> for the target type <typeparamref name="U"/>.</returns>
public readonly HRESULT CopyTo<U>(U** ptr)
where U : unmanaged
#if !NETSTANDARD
, IComIID
#endif
where U : unmanaged, IComIID
{
#if NETSTANDARD
return ((IUnknown*)ptr_)->QueryInterface(Windows.__uuidof<U>(), (void**)ptr);
#else
Guid iid = U.Guid;
return ((IUnknown*)ptr_)->QueryInterface(&iid, (void**)ptr);
#endif
}

/// <summary>
Expand All @@ -140,19 +133,12 @@ public readonly HRESULT CopyTo<U>(U** ptr)
/// <param name="ptr">The target raw pointer to copy the address of the current COM object to.</param>
/// <returns>The result of <see cref="IUnknown.QueryInterface(Guid*, void**)"/> for the target type <typeparamref name="U"/>.</returns>
public readonly HRESULT CopyTo<U>(ref U* ptr)
where U : unmanaged
#if !NETSTANDARD
, IComIID
#endif
where U : unmanaged, IComIID
{
void** tmp = null;

#if NETSTANDARD
HRESULT @ref = ((IUnknown*)ptr_)->QueryInterface(Windows.__uuidof<U>(), tmp);
#else
Guid iid = U.Guid;
HRESULT @ref = ((IUnknown*)ptr_)->QueryInterface(&iid, tmp);
#endif

ptr = (U*)tmp;

Expand Down
31 changes: 0 additions & 31 deletions tests/Shmuelie.WinRTServer.Sample.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -96,37 +96,6 @@
Square310x310Logo="Images\LargeTile.png"/>
</uap3:VisualElements>
</Application>
<Application Id="Shmuelie.WinRTServer.Sample.Server"
Executable="Shmuelie.WinRTServer.Sample.Server\Shmuelie.WinRTServer.Sample.Server.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Local .NET Framework Server"
Description="Local .NET Framework Server"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png"
AppListEntry="none">
<uap:DefaultTile
Wide310x150Logo="Images\Wide310x150Logo.png"
Square71x71Logo="Images\SmallTile.png"
Square310x310Logo="Images\LargeTile.png"/>
</uap:VisualElements>
<Extensions>
<!-- Only needed for COM activation -->
<com2:Extension Category="windows.comServer">
<com2:ComServer>
<com3:ExeServer Executable="Shmuelie.WinRTServer.Sample.Server\Shmuelie.WinRTServer.Sample.Server.exe"
DisplayName="Local .NET Framework Server"
LaunchAndActivationPermission="O:SYG:SYD:(A;;11;;;WD)(A;;11;;;RC)(A;;11;;;AC)(A;;11;;;AN)S:P(ML;;NX;;;S-1-16-0)"
Arguments="-COM">
<com:Class Id="4F59AF92-A98D-4A20-8C8D-1C076647A6AE" DisplayName=".NET Framework RemoteThing Class" />
<com:Class Id="4F59AF92-A98D-4A20-8C8D-1C076647A6AF" DisplayName=".NET Framework Times Class" />
<com:Class Id="4F59AF92-A98D-4A20-8C8D-1C076647A6B0" DisplayName=".NET Framework Input Class" />
</com3:ExeServer>
</com2:ComServer>
</com2:Extension>
</Extensions>
</Application>
<Application Id="Shmuelie.WinRTServer.Sample.ServerNet6"
Executable="Shmuelie.WinRTServer.Sample.ServerNet6\Shmuelie.WinRTServer.Sample.ServerNet6.exe"
EntryPoint="Windows.FullTrustApplication">
Expand Down
Loading

0 comments on commit 8c6b4e6

Please sign in to comment.