Skip to content

Commit

Permalink
Misg/central package management2 (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: Normen Scheiber <[email protected]>
  • Loading branch information
gmiserez and nscheibe committed Mar 21, 2023
1 parent bc68bd0 commit d749275
Show file tree
Hide file tree
Showing 32 changed files with 215 additions and 163 deletions.
62 changes: 62 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<Project>

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Moq" Version="4.16.1" />
<PackageVersion Include="Snapshooter.Xunit" Version="0.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageVersion Include="Squadron.Mongo" Version="0.17.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="Xunit.Priority" Version="1.1.6" />
<PackageVersion Include="FluentAssertions" Version="6.2.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageVersion Include="coverlet.msbuild" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup>
<PackageVersion Include="MongoDB.Driver" Version="2.19.0" />
<PackageVersion Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="1.3.0" />
<PackageVersion Include="System.Text.Json" Version="7.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="3.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="3.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="2.2.0" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<activePackageSource>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</activePackageSource>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
4 changes: 2 additions & 2 deletions samples/Context/DataAccess/DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions samples/Context/Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions samples/Context/Host/Host.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -10,9 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="NSwag.AspNetCore" Version="13.18.0" />
<PackageReference Include="Squadron.Mongo" Version="0.17.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" />
<PackageReference Include="NSwag.AspNetCore" />
<PackageReference Include="Squadron.Mongo" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions samples/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Packages.props, $(MSBuildThisFileDirectory)..))" />

<ItemGroup>
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageVersion Include="NSwag.AspNetCore" Version="13.18.0" />
<PackageVersion Include="MongoDB.Extensions.Migration" Version="1.4.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions samples/Migration/Migration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="MongoDB.Extensions.Migration" Version="1.4.0" />
<PackageReference Include="MongoDB.Driver" />
<PackageReference Include="MongoDB.Extensions.Migration" />
</ItemGroup>

</Project>
23 changes: 18 additions & 5 deletions samples/MongoDB.Extensions.Samples.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
# Visual Studio Version 17
VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "Context\DataAccess\DataAccess.csproj", "{B08692DA-8E74-4F3D-9B8E-66C5962BD7D1}"
EndProject
Expand All @@ -19,9 +19,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3_DataAccess", "3_DataAcces
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SimpleBlog", "SimpleBlog", "{1B6D9C2E-9D39-49E2-8522-29049C3D4821}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Host", "Context\Host\Host.csproj", "{0CCED088-DBB6-4DA2-8DFC-D9968EEBB9FA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Host", "Context\Host\Host.csproj", "{0CCED088-DBB6-4DA2-8DFC-D9968EEBB9FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Migration", "Migration\Migration.csproj", "{8226313B-FAC9-4D0F-AEE8-424DD310BBFB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Migration", "Migration\Migration.csproj", "{8226313B-FAC9-4D0F-AEE8-424DD310BBFB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".root", ".root", "{5366F688-8087-42D7-BBB3-3D8E6391AD44}"
ProjectSection(SolutionItems) = preProject
..\Directory.Packages.props = ..\Directory.Packages.props
..\global.json = ..\global.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{ED7512B7-0598-4815-9DE5-B3BE0F55C1D2}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -60,8 +71,10 @@ Global
{C4DEA4A3-B50A-4ACD-9017-4919576CE069} = {1B6D9C2E-9D39-49E2-8522-29049C3D4821}
{229E6D6C-AB33-4095-A09B-647434079280} = {1B6D9C2E-9D39-49E2-8522-29049C3D4821}
{A880C40E-8DAF-4EFF-AE50-B8983AF424D3} = {1B6D9C2E-9D39-49E2-8522-29049C3D4821}
{1B6D9C2E-9D39-49E2-8522-29049C3D4821} = {27E20B8D-3948-41A2-9271-69D850357C35}
{1B6D9C2E-9D39-49E2-8522-29049C3D4821} = {ED7512B7-0598-4815-9DE5-B3BE0F55C1D2}
{0CCED088-DBB6-4DA2-8DFC-D9968EEBB9FA} = {C4DEA4A3-B50A-4ACD-9017-4919576CE069}
{8226313B-FAC9-4D0F-AEE8-424DD310BBFB} = {ED7512B7-0598-4815-9DE5-B3BE0F55C1D2}
{ED7512B7-0598-4815-9DE5-B3BE0F55C1D2} = {5366F688-8087-42D7-BBB3-3D8E6391AD44}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E28A6DDE-2575-483D-8C8B-7929357BA44A}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@
<ProjectReference Include="..\Prime.Extensions\Prime.Extensions.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="__snapshots__\__mismatch__\" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Extensions.Context.Internal;

namespace MongoDB.Extensions.Context.AllowedTypes.Tests.Helpers;

internal static class TestHelpers
{
public static object GetTypeObjectSerializerContent()
{
return new
{
AllowedTypes = TypeObjectSerializer.AllowedTypes
.Select(pair => new KeyValuePair<string?, bool>(pair.Key.FullName, pair.Value))
.OrderBy(pair => pair.Key),
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies
};
}
}
17 changes: 5 additions & 12 deletions src/Context.AllowedTypes.Tests/MongoDatabaseBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
using MongoDB.Extensions.Context.AllowedTypes.Tests.Helpers;
using MongoDB.Extensions.Context.Internal;
using Snapshooter.Xunit;
using Squadron;
Expand Down Expand Up @@ -56,10 +58,7 @@ public void AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success()
BsonSerializer.LookupSerializer<object>();

Assert.True(registeredSerializer is TypeObjectSerializer);
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -79,10 +78,7 @@ public void AddAllowedTypes_AddAllowedTypesByNamespaces_Success()
BsonSerializer.LookupSerializer<object>();

Assert.True(registeredSerializer is TypeObjectSerializer);
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -102,10 +98,7 @@ public void AddAllowedTypes_AddAllowedTypesByTypes_Success()
BsonSerializer.LookupSerializer<object>();

Assert.True(registeredSerializer is TypeObjectSerializer);
Snapshot.Match(new {
AllowedTypes = TypeObjectSerializer.AllowedTypes.OrderBy(k => k.Key.FullName),
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

public class Bar
Expand Down
42 changes: 9 additions & 33 deletions src/Context.AllowedTypes.Tests/TypeObjectSerializerTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using MongoDB.Extensions.Context.AllowedTypes.Tests.Helpers;
using MongoDB.Extensions.Context.Internal;
using Snapshooter.Xunit;
using Xunit;
Expand All @@ -19,10 +19,7 @@ public void AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success()
TypeObjectSerializer.AddAllowedTypesOfAllDependencies();

// Assert
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -35,10 +32,7 @@ public void AddAllowedTypes_AddAllowedTypesByNamespaces_Success()
TypeObjectSerializer.AddAllowedTypes("Mongo", "SwissLife");

// Assert
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -51,10 +45,7 @@ public void AddAllowedTypes_AddAllowedTypesByTypes_Success()
TypeObjectSerializer.AddAllowedTypes(typeof(Foo), typeof(Bar));

// Assert
Snapshot.Match(new {
AllowedTypes = TypeObjectSerializer.AllowedTypes.OrderBy(k => k.Key.FullName),
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -69,10 +60,7 @@ public void IsTypeAllowed_InAllowedTypes_True()

// Assert
Assert.True(isAllowed);
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -87,10 +75,7 @@ public void IsTypeAllowed_InAllowedTypes_False()

// Assert
Assert.False(isAllowed);
Snapshot.Match(new {
AllowedTypes = TypeObjectSerializer.AllowedTypes.OrderBy(k => k.Key.FullName),
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -105,10 +90,7 @@ public void IsTypeAllowed_InAllowedNamespaces_True()

// Assert
Assert.True(isAllowed);
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -123,10 +105,7 @@ public void IsTypeAllowed_InAllowedNamespaces_False()

// Assert
Assert.False(isAllowed);
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}

[Fact]
Expand All @@ -141,9 +120,6 @@ public void IsTypeAllowed_InAllowedTypesInDependencies_True()

// Assert
Assert.True(isAllowed);
Snapshot.Match(new {
TypeObjectSerializer.AllowedTypes,
TypeObjectSerializer.AllowedTypesByNamespaces,
TypeObjectSerializer.AllowedTypesByDependencies });
Snapshot.Match(TestHelpers.GetTypeObjectSerializerContent());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"AllowedTypes": {},
"AllowedTypes": [],
"AllowedTypesByNamespaces": [
"Mongo",
"SwissLife"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"AllowedTypes": [
{
"Key": "MongoDB.Extensions.Context.AllowedTypes.Tests.MongoDatabaseBuilderTests+Bar, MongoDB.Extensions.Context.AllowedTypes.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"Key": "MongoDB.Extensions.Context.AllowedTypes.Tests.MongoDatabaseBuilderTests+Bar",
"Value": true
},
{
"Key": "MongoDB.Extensions.Context.AllowedTypes.Tests.MongoDatabaseBuilderTests+Foo, MongoDB.Extensions.Context.AllowedTypes.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"Key": "MongoDB.Extensions.Context.AllowedTypes.Tests.MongoDatabaseBuilderTests+Foo",
"Value": true
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"AllowedTypes": {},
"AllowedTypes": [],
"AllowedTypesByNamespaces": [],
"AllowedTypesByDependencies": [
"Newtonsoft",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"AllowedTypes": {},
"AllowedTypes": [],
"AllowedTypesByNamespaces": [
"Mongo",
"SwissLife"
Expand Down
Loading

0 comments on commit d749275

Please sign in to comment.