Skip to content

Commit

Permalink
Central Package Management
Browse files Browse the repository at this point in the history
  • Loading branch information
Perksey committed Dec 16, 2024
1 parent b247b91 commit 771b619
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 83 deletions.
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<SignAssembly>true</SignAssembly>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand Down
13 changes: 3 additions & 10 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>
</PropertyGroup>

<!-- Package versions for package references across all projects -->
<ItemGroup>
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Update="NUnit" Version="4.2.2" />
<PackageReference Update="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>

<!-- Nuget Icon - done as a target so it doesn't appear in the IDE -->
<Target Name="SilkAddIcon" Condition="'$(SilkIconExempt)' == ''">
<ItemGroup>
Expand Down Expand Up @@ -151,11 +144,11 @@
<SilkTrackPublicAPI>false</SilkTrackPublicAPI>
</PropertyGroup>
<ItemGroup Condition="'$(SilkTrackPublicAPI)' == 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(SilkSourceLinkExempt)' == ''">
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="DotNet.ReproducibleBuilds.Isolated" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="DotNet.ReproducibleBuilds" PrivateAssets="All"/>
<PackageReference Include="DotNet.ReproducibleBuilds.Isolated" PrivateAssets="All"/>
</ItemGroup>
<ItemGroup>
<SilkNewPublicAPILines Include="#nullable enable" />
Expand Down
49 changes: 49 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Project>
<ItemGroup>
<!-- Common -->
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.1.1" />
<PackageVersion Include="DotNet.ReproducibleBuilds.Isolated" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.4.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="NUnit" Version="4.2.2" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />

<!-- eng/benchmarks -->
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />

<!-- Silk.NET.Core -->
<PackageVersion Include="Fody" Version="6.8.2" PrivateAssets="all" />
<PackageVersion Include="InlineIL.Fody" Version="1.9.0" PrivateAssets="all" />

<!-- SilkTouch -->
<PackageVersion Include="ClangSharp.PInvokeGenerator" Version="18.1.0.2" />
<PackageVersion Include="CSharpier.Core" Version="0.30.2" />
<PackageVersion Include="Humanizer.Core" Version="2.14.1" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.12.2149" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.IO.Hashing" Version="9.0.0" />

<!-- This is not used but it is used transitively and the version pulled in has a vulnerability -->
<PackageVersion Include="System.Formats.Asn1" Version="9.0.0" />

<!-- SilkTouch Unit Tests -->
<PackageVersion Include="Silk.NET.BuildTools" Version="2.22.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.NUnit" Version="28.3.2" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions docs/for-contributors/build-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ The `ItemGroup` is an unfortunate deficiency with `Directory.Build.targets`. Whi
sufficient for build, it does not make for a pleasant development experience as IDEs do not pick it up from those files.
The empty public API files are automatically generated on first resolve.

### Central Package Management

We manage all the versions for our dependencies in Directory.Packages.props. Learn more about Central Package Management
[here](https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management).

## NUKE

NUKE is used to provide an easy interface into both MSBuild and our other non-C# or otherwise auxiliary build tasks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions sources/Core/Core/Silk.NET.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all" />
<PackageReference Include="InlineIL.Fody" Version="1.9.0" PrivateAssets="all" />
<PackageReference Include="Fody" PrivateAssets="all" />
<PackageReference Include="InlineIL.Fody" PrivateAssets="all" />
</ItemGroup>

<!-- Public API Tracking -->
Expand Down
2 changes: 1 addition & 1 deletion sources/Maths/Maths/Silk.NET.Maths.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
26 changes: 20 additions & 6 deletions sources/SilkTouch/SilkTouch/Mods/Metadata/MetadataUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,33 @@ out int outerCount
{
if (cType[idx] == '[')
{
outerCount = 1;
do
{
var num = cType[(idx + 1)..];
if (cType[(idx + 1)..].IndexOf(']') is not -1 and var j)
if (num.IndexOf(']') is not -1 and var j)
{
idx++;
num = num[..j];
idx += num.Length + 2; // + 1 for [, + 1 again for ]
}
else
{
idx += num.Length;
}

if (num.Length == 0)
{
break;
}

// MD array bounds will be complete, so once we've encountered one array bound with a number we'll
// have a number for all of them.
if (outerCount == 0)
{
outerCount = 1;
}

idx += num.Length;
outerCount *= num.Length == 0 ? 0 : int.Parse(num);
} while (cType[idx] == '[');
outerCount *= int.Parse(num);
} while (idx < cType.Length && cType[idx] == '[');
idx = cType.LastIndexOf(']');
}

Expand Down
34 changes: 17 additions & 17 deletions sources/SilkTouch/SilkTouch/Silk.NET.SilkTouch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClangSharp.PInvokeGenerator" Version="18.1.0.2" />
<PackageReference Include="CSharpier.Core" Version="0.30.2" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.7.8" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.12.2149" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.IO.Hashing" Version="9.0.0" />
<PackageReference Include="ClangSharp.PInvokeGenerator" />
<PackageReference Include="CSharpier.Core" />
<PackageReference Include="Humanizer.Core" />
<PackageReference Include="Microsoft.Build.Locator" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" />
<PackageReference Include="System.CommandLine" />
<PackageReference Include="System.IO.Hashing" />

<!-- This is not used but it is used transitively and the version pulled in has a vulnerability -->
<PackageReference Include="System.Formats.Asn1" Version="9.0.0" />
<PackageReference Include="System.Formats.Asn1" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 0 additions & 14 deletions tests/Core/Core/Silk.NET.Core.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Update="NUnit" Version="4.2.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\sources\Core\Core\Silk.NET.Core.csproj" />
</ItemGroup>
Expand Down
13 changes: 9 additions & 4 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@

<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" IsImplicitlyDefined="true" />
<PackageReference Include="NUnit" IsImplicitlyDefined="true" />
<PackageReference Include="NUnit3TestAdapter" IsImplicitlyDefined="true" />
<ItemGroup Condition="'$(SilkNUnitExempt)' != 'true'">
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" />
</ItemGroup>

</Project>
11 changes: 6 additions & 5 deletions tests/Maths/Maths/Silk.NET.Maths.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<SilkNUnitExempt>true</SilkNUnitExempt>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\sources\Maths\Maths\Silk.NET.Maths.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="NUnit" Version="4.2.2" />
</ItemGroup>

</Project>
14 changes: 0 additions & 14 deletions tests/SDL/SDL/Silk.NET.SDL.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Update="NUnit" Version="4.2.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\sources\SDL\SDL\Silk.NET.SDL.csproj" />
</ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions tests/SilkTouch/SilkTouch/MetadataUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void GetIndirectionLevels(string type, int expectedIndirection) =>
TestCase("int**", 2, new[] { true, true, true }, 0),
TestCase("int** const*", 3, new[] { true, false, true, true }, 0),
TestCase("int** const*[16]", 4, new[] { true, true, false, true, true }, 16),
TestCase("int** const* a[16]", 4, new[] { true, true, false, true, true }, 0),
TestCase("int** const* a[2][8]", 4, new[] { true, true, false, true, true }, 0),
TestCase("int** const* a[16]", 4, new[] { true, true, false, true, true }, 16),
TestCase("int** const* a[2][8]", 4, new[] { true, true, false, true, true }, 16),
TestCase("int a", 0, new[] { true }, 0)
]
public void GetMutability(
Expand All @@ -65,7 +65,10 @@ int expectedOuterCount
{
var mutability = new bool[indirection + 1];
MetadataUtils.GetTypeDetails(type, mutability, out var outerCount);
Assert.That(outerCount, Is.EqualTo(outerCount));
Assert.That(mutability, Is.EquivalentTo(expectedMutability));
Assert.Multiple(() =>
{
Assert.That(outerCount, Is.EqualTo(expectedOuterCount));
Assert.That(mutability, Is.EquivalentTo(expectedMutability));
});
}
}
9 changes: 4 additions & 5 deletions tests/SilkTouch/SilkTouch/Silk.NET.SilkTouch.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="NUnit" Version="4.2.2" />
<PackageReference Include="Silk.NET.BuildTools" Version="2.22.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Verify.DiffPlex" Version="3.1.2" />
<PackageReference Include="Verify.NUnit" Version="28.3.2" />
<PackageReference Include="Silk.NET.BuildTools" />
<PackageReference Include="System.Linq.Async" />
<PackageReference Include="Verify.DiffPlex" />
<PackageReference Include="Verify.NUnit" />
<None Include="**/*.received.*" />
<None Include="**/*.verified.*" />
</ItemGroup>
Expand Down

0 comments on commit 771b619

Please sign in to comment.