Update to .NET 6 and C# 10 (#5233)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
committed by
GitHub
parent
29f3d2d1ca
commit
af579b15cc
2
.github/workflows/build-test.yml
vendored
2
.github/workflows/build-test.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 5.0.100
|
||||
dotnet-version: 6.0.100
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
|
||||
2
.github/workflows/yaml-linter.yml
vendored
2
.github/workflows/yaml-linter.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 5.0.100
|
||||
dotnet-version: 6.0.100
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>9</LangVersion>
|
||||
<LangVersion>10</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<LangVersion>9</LangVersion>
|
||||
<LangVersion>10</LangVersion>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>..\bin\Content.Client\</OutputPath>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<OutputPath>..\bin\Content.IntegrationTests\</OutputPath>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<LangVersion>9</LangVersion>
|
||||
<LangVersion>10</LangVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -68,9 +68,9 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
// Test for components existing
|
||||
Assert.True(human.TryGetComponent(out cuffed!), $"Human has no {nameof(CuffableComponent)}");
|
||||
Assert.True(human.TryGetComponent(out hands!), $"Human has no {nameof(HandsComponent)}");
|
||||
Assert.True(human.TryGetComponent(out SharedBodyComponent _), $"Human has no {nameof(SharedBodyComponent)}");
|
||||
Assert.True(cuffs.TryGetComponent(out HandcuffComponent _), $"Handcuff has no {nameof(HandcuffComponent)}");
|
||||
Assert.True(secondCuffs.TryGetComponent(out HandcuffComponent _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
|
||||
Assert.True(human.TryGetComponent(out SharedBodyComponent? _), $"Human has no {nameof(SharedBodyComponent)}");
|
||||
Assert.True(cuffs.TryGetComponent(out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}");
|
||||
Assert.True(secondCuffs.TryGetComponent(out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
|
||||
|
||||
// Test to ensure cuffed players register the handcuffs
|
||||
cuffed.TryAddNewCuffs(human, cuffs);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
|
||||
// Test for climb components existing
|
||||
// Players and tables should have these in their prototypes.
|
||||
Assert.That(human.TryGetComponent(out climbing!), "Human has no climbing");
|
||||
Assert.That(table.TryGetComponent(out ClimbableComponent _), "Table has no climbable");
|
||||
Assert.That(table.TryGetComponent(out ClimbableComponent? _), "Table has no climbable");
|
||||
|
||||
// Now let's make the player enter a climbing transitioning state.
|
||||
climbing.IsClimbing = true;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<LangVersion>9</LangVersion>
|
||||
<LangVersion>10</LangVersion>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>..\bin\Content.Server.Database\</OutputPath>
|
||||
@@ -13,12 +13,12 @@
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0-rc.2" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.Analyzers.targets" />
|
||||
</Project>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
|
||||
@@ -28,6 +29,11 @@ namespace Content.Server.Database
|
||||
options.ReplaceService<IRelationalTypeMappingSource, CustomNpgsqlTypeMappingSource>();
|
||||
|
||||
((IDbContextOptionsBuilderInfrastructure) options).AddOrUpdateExtension(new SnakeCaseExtension());
|
||||
|
||||
options.ConfigureWarnings(x =>
|
||||
{
|
||||
x.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning);
|
||||
});
|
||||
}
|
||||
|
||||
public PostgresServerDbContext(DbContextOptions<ServerDbContext> options) : base(options)
|
||||
@@ -82,7 +88,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
foreach(var property in entity.GetProperties())
|
||||
{
|
||||
if (property.FieldInfo.FieldType == typeof(DateTime) || property.FieldInfo.FieldType == typeof(DateTime?))
|
||||
if (property.FieldInfo?.FieldType == typeof(DateTime) || property.FieldInfo?.FieldType == typeof(DateTime?))
|
||||
property.SetColumnType("timestamp with time zone");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
@@ -25,6 +26,11 @@ namespace Content.Server.Database
|
||||
options.UseSqlite("dummy connection string");
|
||||
|
||||
((IDbContextOptionsBuilderInfrastructure) options).AddOrUpdateExtension(new SnakeCaseExtension());
|
||||
|
||||
options.ConfigureWarnings(x =>
|
||||
{
|
||||
x.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
||||
@@ -33,7 +33,12 @@ namespace Content.Server.Database
|
||||
|
||||
public override string LogFragment => "Snake Case Extension";
|
||||
|
||||
public override long GetServiceProviderHashCode() => 0;
|
||||
public override int GetServiceProviderHashCode() => 0;
|
||||
|
||||
public override bool ShouldUseSameServiceProvider(DbContextOptionsExtensionInfo other)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void PopulateDebugInfo(IDictionary<string, string> debugInfo)
|
||||
{
|
||||
@@ -118,26 +123,26 @@ namespace Content.Server.Database
|
||||
|
||||
if (entityType.BaseType is null)
|
||||
{
|
||||
entityTypeBuilder.ToTable(RewriteName(entityType.GetTableName()), entityType.GetSchema());
|
||||
entityTypeBuilder.ToTable(RewriteName(entityType.GetTableName()!), entityType.GetSchema());
|
||||
|
||||
if (entityType.GetViewNameConfigurationSource() == ConfigurationSource.Convention)
|
||||
{
|
||||
entityTypeBuilder.ToView(RewriteName(entityType.GetViewName()), entityType.GetViewSchema());
|
||||
entityTypeBuilder.ToView(RewriteName(entityType.GetViewName()!), entityType.GetViewSchema());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessEntityTypeBaseTypeChanged(
|
||||
IConventionEntityTypeBuilder entityTypeBuilder,
|
||||
IConventionEntityType newBaseType,
|
||||
IConventionEntityType oldBaseType,
|
||||
IConventionEntityType? newBaseType,
|
||||
IConventionEntityType? oldBaseType,
|
||||
IConventionContext<IConventionEntityType> context)
|
||||
{
|
||||
var entityType = entityTypeBuilder.Metadata;
|
||||
|
||||
if (newBaseType is null)
|
||||
{
|
||||
entityTypeBuilder.ToTable(RewriteName(entityType.GetTableName()), entityType.GetSchema());
|
||||
entityTypeBuilder.ToTable(RewriteName(entityType.GetTableName()!), entityType.GetSchema());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -173,8 +178,8 @@ namespace Content.Server.Database
|
||||
public void ProcessEntityTypeAnnotationChanged(
|
||||
IConventionEntityTypeBuilder entityTypeBuilder,
|
||||
string name,
|
||||
IConventionAnnotation annotation,
|
||||
IConventionAnnotation oldAnnotation,
|
||||
IConventionAnnotation? annotation,
|
||||
IConventionAnnotation? oldAnnotation,
|
||||
IConventionContext<IConventionAnnotation> context)
|
||||
{
|
||||
var entityType = entityTypeBuilder.Metadata;
|
||||
@@ -216,7 +221,7 @@ namespace Content.Server.Database
|
||||
&& (string)annotation.Value != ownership.PrincipalEntityType.GetTableName())
|
||||
{
|
||||
foreach (var property in entityType.GetProperties()
|
||||
.Except(entityType.FindPrimaryKey().Properties)
|
||||
.Except(entityType.FindPrimaryKey()!.Properties)
|
||||
.Where(p => p.Builder.CanSetColumnName(null)))
|
||||
{
|
||||
RewriteColumnName(property.Builder);
|
||||
@@ -271,7 +276,7 @@ namespace Content.Server.Database
|
||||
|
||||
if (property.GetColumnNameConfigurationSource(identifier.Value) == ConfigurationSource.Convention)
|
||||
{
|
||||
columnName = property.GetColumnName(identifier.Value);
|
||||
columnName = property.GetColumnName(identifier.Value)!;
|
||||
if (columnName.StartsWith(entityType.ShortName() + '_', StringComparison.Ordinal))
|
||||
{
|
||||
property.Builder.HasColumnName(
|
||||
@@ -314,7 +319,7 @@ namespace Content.Server.Database
|
||||
if (name == "Id")
|
||||
name = entityType.GetTableName() + name;
|
||||
propertyBuilder.HasColumnName(
|
||||
RewriteName(name), identifier.Value);
|
||||
RewriteName(name!), identifier.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Foam;
|
||||
using Content.Shared.Inventory;
|
||||
@@ -51,7 +50,7 @@ namespace Content.Server.Chemistry.Components
|
||||
slot == EquipmentSlotDefines.Slots.IDCARD)
|
||||
continue;
|
||||
|
||||
if (inventory.TryGetSlotItem(slot, out ItemComponent _))
|
||||
if (inventory.TryGetSlotItem(slot, out ItemComponent? _))
|
||||
protection += 0.025f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<LangVersion>9</LangVersion>
|
||||
<LangVersion>10</LangVersion>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>..\bin\Content.Server\</OutputPath>
|
||||
|
||||
@@ -93,6 +93,11 @@ namespace Content.Server.Database
|
||||
.Where(p => p.Preference.UserId == userId.UserId && p.Slot == slot)
|
||||
.SingleOrDefaultAsync();
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
db.Profile.Remove(profile);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Preferences;
|
||||
using Microsoft.Data.Sqlite;
|
||||
@@ -382,8 +381,8 @@ namespace Content.Server.Database
|
||||
_sawmill = sawmill;
|
||||
}
|
||||
|
||||
public void Log<TState>(MSLogLevel logLevel, EventId eventId, TState state, Exception exception,
|
||||
Func<TState, Exception, string> formatter)
|
||||
public void Log<TState>(MSLogLevel logLevel, EventId eventId, TState state, Exception? exception,
|
||||
Func<TState, Exception?, string> formatter)
|
||||
{
|
||||
var lvl = logLevel switch
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Content.Server.Inventory
|
||||
return false;
|
||||
|
||||
// If we don't have that slot or there's already an item there, we do nothing.
|
||||
if (!inventory.HasSlot(slot) || inventory.TryGetSlotItem(slot, out ItemComponent _))
|
||||
if (!inventory.HasSlot(slot) || inventory.TryGetSlotItem(slot, out ItemComponent? _))
|
||||
return false;
|
||||
|
||||
// If the prototype in question doesn't exist, we do nothing.
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace Content.Server.Strip
|
||||
if (!inventory.HasSlot(slot))
|
||||
return false;
|
||||
|
||||
if (inventory.TryGetSlotItem(slot, out ItemComponent _))
|
||||
if (inventory.TryGetSlotItem(slot, out ItemComponent? _))
|
||||
{
|
||||
user.PopupMessageCursor(Loc.GetString("strippable-component-item-slot-occupied",("owner", Owner)));
|
||||
return false;
|
||||
@@ -403,7 +403,7 @@ namespace Content.Server.Strip
|
||||
|
||||
if (Owner.TryGetComponent<InventoryComponent>(out var inventory))
|
||||
{
|
||||
if (inventory.TryGetSlotItem(inventoryMessage.Slot, out ItemComponent _))
|
||||
if (inventory.TryGetSlotItem(inventoryMessage.Slot, out ItemComponent? _))
|
||||
placingItem = false;
|
||||
|
||||
if (placingItem)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<LangVersion>9</LangVersion>
|
||||
<LangVersion>10</LangVersion>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<Configurations>Release;Debug</Configurations>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<LangVersion>9</LangVersion>
|
||||
<LangVersion>10</LangVersion>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>..\bin\Content.Tests\</OutputPath>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<OutputPath>..\bin\Content.YAMLLinter\</OutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Submodule RobustToolbox updated: 9b215098e4...1c8ed1c5b2
Reference in New Issue
Block a user