Skip to content

Commit

Permalink
Update EF Core to .NET 8 (#47)
Browse files Browse the repository at this point in the history
* Update EF Core to .NET 8

Fixes #33. The bug was caused by a bug in EF Core/Npgsql that made it generate the SQL query incorrectly.

* Add RT as sub-submodule in Rider

Yes I've actually needed this

* Update SS14, central package management, update deps
  • Loading branch information
PJB3005 authored Jan 12, 2024
1 parent e8d1fa6 commit cc555e7
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{csproj,xml,yml,dll.config,msbuildproj,targets}]
[*.{csproj,xml,yml,dll.config,msbuildproj,targets,props}]
indent_size = 2
1 change: 1 addition & 0 deletions .idea/.idea.SS14.Admin/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<Import Project="SS14/Directory.Packages.props"/>
<ItemGroup>
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<PackageVersion Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="5.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion SS14
Submodule SS14 updated 2662 files
7 changes: 7 additions & 0 deletions SS14.Admin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
README.md = README.md
Dockerfile = Dockerfile
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Server.Database", "SS14\Content.Server.Database\Content.Server.Database.csproj", "{0DE28821-8C9F-4770-BA7C-5D38AC77F872}"
Expand All @@ -22,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{
.github\workflows\publish-ghcr.yml = .github\workflows\publish-ghcr.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Serialization.Generator", "SS14\RobustToolbox\Robust.Serialization.Generator\Robust.Serialization.Generator.csproj", "{B30D497E-2240-4968-9FAD-D2967F04DEEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -44,6 +47,10 @@ Global
{F718671B-FAD0-4783-90B8-32059AB9552F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F718671B-FAD0-4783-90B8-32059AB9552F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F718671B-FAD0-4783-90B8-32059AB9552F}.Release|Any CPU.Build.0 = Release|Any CPU
{B30D497E-2240-4968-9FAD-D2967F04DEEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B30D497E-2240-4968-9FAD-D2967F04DEEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B30D497E-2240-4968-9FAD-D2967F04DEEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B30D497E-2240-4968-9FAD-D2967F04DEEC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{20A0EC6E-8DE5-4587-BC4A-7EB0C5D65001} = {0DA4417F-14E5-49E9-8A0D-4F76C3CDED5C}
Expand Down
5 changes: 3 additions & 2 deletions SS14.Admin/Helpers/BanHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net.Sockets;
using Content.Server.Database;
using Microsoft.EntityFrameworkCore;
using NpgsqlTypes;

namespace SS14.Admin.Helpers;

Expand Down Expand Up @@ -140,9 +141,9 @@ public sealed class BanJoin<TBan, TUnban> where TBan: IBanCommon<TUnban> where T
var parsedIp = parsedAddr.Item1;
var parsedCidr = parsedAddr.Item2;
// Ban /64 on IPv6.
parsedCidr ??= parsedIp.AddressFamily == AddressFamily.InterNetwork ? 32 : 64;
parsedCidr ??= (byte)(parsedIp.AddressFamily == AddressFamily.InterNetwork ? 32 : 64);

ban.Address = (parsedIp, parsedCidr.Value);
ban.Address = new NpgsqlInet(parsedIp, parsedCidr.Value);
}

if (!string.IsNullOrWhiteSpace(hwid))
Expand Down
21 changes: 12 additions & 9 deletions SS14.Admin/Helpers/IPHelper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Net;
using System.Net.Sockets;
using NpgsqlTypes;

namespace SS14.Admin.Helpers
{
public static class IPHelper
{
public static bool TryParseIpOrCidr(string str, out (IPAddress, int?) cidr)
public static bool TryParseIpOrCidr(string str, out (IPAddress, byte?) cidr)
{
if (IPAddress.TryParse(str, out var addr))
{
Expand All @@ -14,32 +15,34 @@ public static bool TryParseIpOrCidr(string str, out (IPAddress, int?) cidr)
}

var res = TryParseCidr(str, out var cidrParsed);
cidr = (cidrParsed.Item1, cidrParsed.Item2);
cidr = (cidrParsed.Address, cidrParsed.Netmask);
return res;
}

public static bool TryParseCidr(string str, out (IPAddress, int) cidr)
public static bool TryParseCidr(string str, out NpgsqlInet cidr)
{
cidr = default;

IPAddress? address;
byte mask;

var split = str.Split("/");
if (split.Length != 2)
return false;

if (!IPAddress.TryParse(split[0], out cidr.Item1!))
if (!IPAddress.TryParse(split[0], out address))
return false;

if (!int.TryParse(split[1], out cidr.Item2))
if (!byte.TryParse(split[1], out mask))
return false;

cidr = new NpgsqlInet(address, mask);
return true;
}

public static string FormatCidr(this (IPAddress, int) cidr)
public static string FormatCidr(this NpgsqlInet cidr)
{
var (addr, range) = cidr;

return $"{addr}/{range}";
return $"{cidr.Address}/{cidr.Netmask}";
}
}
}
19 changes: 10 additions & 9 deletions SS14.Admin/SS14.Admin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.1.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<PackageReference Include="JetBrains.Annotations" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="NetEscapades.Configuration.Yaml" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Settings.Configuration" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit cc555e7

Please sign in to comment.