Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added MonoMod.Backports.snk
Binary file not shown.
32 changes: 26 additions & 6 deletions src/MonoMod.Backports.Shims/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@
DependsOnTargets="$(CoreCompileDependsOn);_PrepareRawTfmList;_GetShimmedPackages;ResolveProjectReferences"
Inputs="$(MSBuildAllProjects);@(MMShimGen)"
Outputs="$(_OutputTfmsTxt)"
Condition="'$(dotnet-nugetize)' == ''"
>
Condition="'$(dotnet-nugetize)' == ''">

<ItemGroup>
<_ExistingShimFiles Include="$(_ShimsDir)**/*" />
Expand All @@ -140,16 +139,37 @@
<_ShimGenExe>%(MMShimGen.RelativeDir)%(FileName)$(_NativeExecutableExtension)</_ShimGenExe>
<_SnkDir>$(MMRootPath)snk/</_SnkDir>
</PropertyGroup>

<ItemGroup>
<_BackportsProps Remove="@(_BackportsProps)"/>
</ItemGroup>

<MSBuild Projects="$(MMSourcePath)MonoMod.Backports/MonoMod.Backports.csproj"
Targets="GetAssemblyVersion;GetProperties"
Properties="TargetFramework=net8.0;PropertyNames=AssemblyVersion,AssemblyOriginatorKeyFile;BuildProjectReferences=false">
<Output ItemName="_BackportsProps" TaskParameter="TargetOutputs" />
</MSBuild>

<PropertyGroup>
<_BackportsAsmVersion></_BackportsAsmVersion>
<_BackportsKeyFile></_BackportsKeyFile>
<_BackportsAsmVersion Condition="'%(_BackportsProps.Identity)' == 'AssemblyVersion'">%(_BackportsProps.Value)</_BackportsAsmVersion>
<_BackportsKeyFile Condition="'%(_BackportsProps.Identity)' == 'AssemblyOriginatorKeyFile'">%(_BackportsProps.Value)</_BackportsKeyFile>
</PropertyGroup>

<ItemGroup>
<_PPArguments Remove="@(_PPArguments)" />
<!-- 1: the output directory -->
<!-- 1: Backports version -->
<_PPArguments Include="$(_BackportsAsmVersion)" />
<!-- 2: Backports keyfile -->
<_PPArguments Include="$(_BackportsKeyFile)" />
<!-- 3: the output directory -->
<_PPArguments Include="$(_ShimsDir)" />
<!-- 2: snk directory -->
<!-- 4: snk directory -->
<_PPArguments Include="$(_SnkDir)" />
<!-- 3: tfms file -->
<!-- 5: tfms file -->
<_PPArguments Include="$(_BackportsTfmsTxt)" />
<!-- 4: the paths to the packages to process -->
<!-- 6: the paths to the packages to process -->
<_PPArguments Include="@(_ShimmedPackagePaths)" />
</ItemGroup>

Expand Down
12 changes: 7 additions & 5 deletions src/MonoMod.Backports/MonoMod.Backports.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- target frameworks are defined in Common.props -->

<!-- We're not going to be having any of the logic that would use the shared sources, so we'll just not include them -->
<RootNamespace><![CDATA[ ]]></RootNamespace>
<NoWarn>$(NoWarn);CA1200;CA1716</NoWarn>
<MMReferenceSourcePkgs>false</MMReferenceSourcePkgs>
</PropertyGroup>

<PropertyGroup>
<Description>A set of backports of new BCL features to all frameworks which MonoMod supports.</Description>
</PropertyGroup>

<PropertyGroup>
<AssemblyOriginatorKeyFile>$(MMRootPath)MonoMod.Backports.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>

<PropertyGroup>
<MMTFKind>$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)'))</MMTFKind>
<MMTFVersion>$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)'))</MMTFVersion>
Expand All @@ -24,9 +28,7 @@
<PackageReference Include="js6pak.InlineIL.Fody" Version="1.10.0-js6pak.1" PrivateAssets="all" ExcludeAssets="runtime" Pack="false" />
</ItemGroup>

<Target Name="RemoveImplicitOutOfBandAssemblies"
BeforeTargets="BeforeCompile"
AfterTargets="FindReferenceAssembliesForReferences">
<Target Name="RemoveImplicitOutOfBandAssemblies" BeforeTargets="BeforeCompile" AfterTargets="FindReferenceAssembliesForReferences">
<ItemGroup>
<ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)" Condition="%(Filename) == 'System.Runtime.CompilerServices.Unsafe'" />
</ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions src/MonoMod.Backports/NuGet.targets
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project>

<Target Name="Backports_AddShimsDependency">
<ItemGroup>
<PackageReference Include="MonoMod.Backports.Shims" Version="$(Version)" />
</ItemGroup>
</Target>

<ItemGroup>
<PackageFile Include="MonoMod.Backports.Shims" Version="$(Version)">
<Source>Explicit</Source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>

<MMReferenceSourcePkgs>false</MMReferenceSourcePkgs>

<Nullable>disable</Nullable>

<IsPackable>false</IsPackable>
Expand All @@ -13,7 +11,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MSBuildRequiredVersion)" />
<!--<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />-->
</ItemGroup>

</Project>
15 changes: 10 additions & 5 deletions src/build/ShimGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
using System.Diagnostics.CodeAnalysis;

if (args is not [
var backportsVersion,
var backportsSnkFile,
var outputRefDir,
var snkPath,
var tfmsFilePath,
.. var dotnetOobPackagePaths
])
{
Console.Error.WriteLine("Assemblies not provided.");
Console.Error.WriteLine("Syntax: <output ref dir> <snk directory> <tfms file> <...oob package paths...>");
Console.Error.WriteLine("Syntax: <backports version> <backports snk file> <output ref dir> <snk directory> <tfms file> <...oob package paths...>");
Console.Error.WriteLine("Arguments provided: ");
foreach (var arg in args)
{
Expand Down Expand Up @@ -160,6 +161,12 @@ .. var dotnetOobPackagePaths
.OrderBy(t => t.fwk, precSorter)
.ToArray();

var backportsReferenceBase = new AssemblyReference(
"MonoMod.Backports",
new Version(backportsVersion),
publicKey: true,
StrongNamePrivateKey.FromFile(backportsSnkFile).CreatePublicKeyBlob(AssemblyHashAlgorithm.Sha1));

// Now, we have some work to do for shims. We want to check if there is an equivalent type to the shims
// defined or exported from Backports, and rewrite a new shim forwarding to Backports as appropriate.
var importedSet = new Dictionary<string, ExportedType>();
Expand Down Expand Up @@ -195,9 +202,7 @@ .. var dotnetOobPackagePaths
HasPublicKey = bclShim.Assembly!.HasPublicKey,
};

backportsReference =
new AssemblyReference("MonoMod.Backports", new(1, 0, 0, 0))
.ImportWith(backportsShim.DefaultImporter);
backportsReference = backportsReferenceBase.ImportWith(backportsShim.DefaultImporter);

foreach (var file in dllsByDllName[dllName].Values.SelectMany(x => x))
{
Expand Down
13 changes: 0 additions & 13 deletions tools/Common.CS.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
<AnalysisMode>All</AnalysisMode>
<AnalysisLevel>8.0</AnalysisLevel>

<MMReferenceSourcePkgs>true</MMReferenceSourcePkgs>

<NoWarn>$(NoWarn);CS1591</NoWarn> <!-- XML documentation warning. TODO: We should probably remove this at some point and ensure that MM is fully documented. -->
<NoWarn>$(NoWarn);CA1716</NoWarn> <!-- Members have name shared with primitive type. -->
<NoWarn>$(NoWarn);CA1003</NoWarn> <!-- Change event to use EventHandler<EventArgs> -->
Expand All @@ -37,16 +35,5 @@
<!-- We want to remove JSImportGenerator by default, becuase it takes a good deal of compilation time -->
<RemoveAnalyzer Include="Microsoft.Interop.JavaScript.JSImportGenerator" />
</ItemGroup>

<ItemGroup Condition="'$(MMReferenceSourcePkgs)' == 'true'">
<PackageReference Include="Nullable" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="IsExternalInit" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions tools/Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
</ItemGroup>

<ItemGroup>
<_PropertiesToGet Include="$(PropertyNames)" />
<_PropertiesToGet Include="$([System.String]::Copy($(PropertyNames)).Split(','))" />
</ItemGroup>

<ItemGroup>
<Properties Include="%(_PropertiesToGet.Identity)" Value="$(%(Identity))" />
<Properties Include="%(_PropertiesToGet.Identity)" Value="$(%(_PropertiesToGet.Identity))" />
</ItemGroup>
</Target>

Expand Down