Dependency update / fixes / skrungle bungle (#23745)
* Give .props files 2-space indents.
* Move to Central Package Management.
Allows us to store NuGet package versions all in one place. Yay!
* Update NuGet packages and fix code for changes.
Notable:
Changes to ILVerify.
Npgsql doesn't need hacks for inet anymore, now we need hacks to make the old code work with this new reality.
NUnit's analyzers are already complaining and I didn't even update it to 4.x yet.
TerraFX changed to GetLastSystemError so error handling had to be changed.
Buncha APIs have more NRT annotations.
* Remove dotnet-eng NuGet package source.
I genuinely don't know what this was for, and Central Package Management starts throwing warnings about it, so YEET.
* Remove Robust.Physics project.
Never used.
* Remove erroneous NVorbis reference.
Should be VorbisPizza and otherwise wasn't used.
* Sandbox fixes
* Remove unused unit test package references.
Castle.Core and NUnit.ConsoleRunner.
* Update NUnit to 4.0.1
This requires replacing all the old assertion methods because they removed them 🥲
* Oh so that's what dotnet-eng was used for. Yeah ok that makes sense.
* Add Robust.Analyzers.Test
* Update submodule
* commit to re-run CI
This commit is contained in:
committed by
GitHub
parent
d2a1eae2d9
commit
a6c9c36b68
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
@@ -12,16 +12,16 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.4" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
|
||||
|
||||
<!-- Necessary at design time -->
|
||||
<PackageReference Include="SQLitePCLRaw.provider.e_sqlite3" Version="2.1.4" Condition="'$(UseSystemSqlite)' != 'True' and '$(Configuration)' != 'Release'" />
|
||||
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.4" Condition="'$(UseSystemSqlite)' != 'True' and '$(Configuration)' != 'Release'" />
|
||||
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Condition="'$(UseSystemSqlite)' == 'True' and '$(Configuration)' != 'Release'" />
|
||||
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Condition="'$(UseSystemSqlite)' != 'True' and '$(Configuration)' != 'Release'" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Net;
|
||||
using System.Text.Json;
|
||||
using Content.Shared.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace Content.Server.Database
|
||||
{
|
||||
@@ -550,7 +551,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
int Id { get; set; }
|
||||
Guid? PlayerUserId { get; set; }
|
||||
(IPAddress, int)? Address { get; set; }
|
||||
NpgsqlInet? Address { get; set; }
|
||||
byte[]? HWId { get; set; }
|
||||
DateTime BanTime { get; set; }
|
||||
DateTime? ExpirationTime { get; set; }
|
||||
@@ -618,8 +619,7 @@ namespace Content.Server.Database
|
||||
/// <summary>
|
||||
/// CIDR IP address range of the ban. The whole range can match the ban.
|
||||
/// </summary>
|
||||
[Column(TypeName = "inet")]
|
||||
public (IPAddress, int)? Address { get; set; }
|
||||
public NpgsqlInet? Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hardware ID of the banned player.
|
||||
@@ -808,7 +808,7 @@ namespace Content.Server.Database
|
||||
public Round? Round { get; set; }
|
||||
public Guid? PlayerUserId { get; set; }
|
||||
[Required] public TimeSpan PlaytimeAtNote { get; set; }
|
||||
[Column(TypeName = "inet")] public (IPAddress, int)? Address { get; set; }
|
||||
public NpgsqlInet? Address { get; set; }
|
||||
public byte[]? HWId { get; set; }
|
||||
|
||||
public DateTime BanTime { get; set; }
|
||||
|
||||
@@ -21,8 +21,6 @@ namespace Content.Server.Database
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
options.ReplaceService<IRelationalTypeMappingSource, CustomNpgsqlTypeMappingSource>();
|
||||
|
||||
((IDbContextOptionsBuilderInfrastructure) options).AddOrUpdateExtension(new SnakeCaseExtension());
|
||||
|
||||
options.ConfigureWarnings(x =>
|
||||
|
||||
@@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace Content.Server.Database
|
||||
{
|
||||
@@ -48,8 +49,8 @@ namespace Content.Server.Database
|
||||
.Property(p => p.LastSeenAddress)
|
||||
.HasConversion(ipConverter);
|
||||
|
||||
var ipMaskConverter = new ValueConverter<(IPAddress address, int mask), string>(
|
||||
v => InetToString(v.address, v.mask),
|
||||
var ipMaskConverter = new ValueConverter<NpgsqlInet, string>(
|
||||
v => InetToString(v.Address, v.Netmask),
|
||||
v => StringToInet(v)
|
||||
);
|
||||
|
||||
@@ -98,11 +99,11 @@ namespace Content.Server.Database
|
||||
return $"{address}/{mask}";
|
||||
}
|
||||
|
||||
private static (IPAddress, int) StringToInet(string inet) {
|
||||
private static NpgsqlInet StringToInet(string inet) {
|
||||
var idx = inet.IndexOf('/', StringComparison.Ordinal);
|
||||
return (
|
||||
return new NpgsqlInet(
|
||||
IPAddress.Parse(inet.AsSpan(0, idx)),
|
||||
int.Parse(inet.AsSpan(idx + 1), provider: CultureInfo.InvariantCulture)
|
||||
byte.Parse(inet.AsSpan(idx + 1), provider: CultureInfo.InvariantCulture)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping;
|
||||
|
||||
#pragma warning disable EF1001
|
||||
namespace Content.Server.Database
|
||||
{
|
||||
// Taken from https://github.com/npgsql/efcore.pg/issues/1158
|
||||
// To support inet -> (IPAddress, int) mapping.
|
||||
public class CustomNpgsqlTypeMappingSource : NpgsqlTypeMappingSource
|
||||
{
|
||||
public CustomNpgsqlTypeMappingSource(
|
||||
TypeMappingSourceDependencies dependencies,
|
||||
RelationalTypeMappingSourceDependencies relationalDependencies,
|
||||
ISqlGenerationHelper sqlGenerationHelper,
|
||||
INpgsqlSingletonOptions npgsqlOptions)
|
||||
: base(dependencies, relationalDependencies, sqlGenerationHelper, npgsqlOptions)
|
||||
{
|
||||
StoreTypeMappings["inet"] =
|
||||
new RelationalTypeMapping[]
|
||||
{
|
||||
new NpgsqlInetWithMaskTypeMapping(),
|
||||
new NpgsqlInetTypeMapping()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Basically copied from NpgsqlCidrTypeMapping
|
||||
public class NpgsqlInetWithMaskTypeMapping : NpgsqlTypeMapping
|
||||
{
|
||||
public NpgsqlInetWithMaskTypeMapping() : base("inet", typeof((IPAddress, int)), NpgsqlTypes.NpgsqlDbType.Inet)
|
||||
{
|
||||
}
|
||||
|
||||
protected NpgsqlInetWithMaskTypeMapping(RelationalTypeMappingParameters parameters)
|
||||
: base(parameters, NpgsqlTypes.NpgsqlDbType.Inet)
|
||||
{
|
||||
}
|
||||
|
||||
protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
|
||||
{
|
||||
return new NpgsqlInetWithMaskTypeMapping(parameters);
|
||||
}
|
||||
|
||||
protected override string GenerateNonNullSqlLiteral(object value)
|
||||
{
|
||||
var (address, subnet) = ((IPAddress, int)) value;
|
||||
return $"INET '{address}/{subnet}'";
|
||||
}
|
||||
|
||||
public override Expression GenerateCodeLiteral(object value)
|
||||
{
|
||||
var (address, subnet) = ((IPAddress, int)) value;
|
||||
return Expression.New(
|
||||
Constructor,
|
||||
Expression.Call(ParseMethod, Expression.Constant(address.ToString())),
|
||||
Expression.Constant(subnet));
|
||||
}
|
||||
|
||||
private static readonly MethodInfo ParseMethod = typeof(IPAddress).GetMethod("Parse", new[] {typeof(string)})!;
|
||||
private static readonly ConstructorInfo Constructor =
|
||||
typeof((IPAddress, int)).GetConstructor(new[] {typeof(IPAddress), typeof(int)})!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user