Dependency update / fixes / skrungle bungle (#4825)

* 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.

* Fix double loading of assemblies due to ALC shenanigans.

Due to how the "sideloading" code for the ModLoader was set up, it would first try to load Microsoft.Extensions.Primitives from next to the content dll. But we already have that library in Robust!

Chaos ensues.

We now try to forcibly prioritize loading from the default ALC first to avoid this.

* 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 🥲

* Mute CA1416 (platform check) errors

TerraFX started annotating APIs with this and I can't be arsed to entertain this analyzer so out it goes.

* Fine ya cranky, no more CPM for Robust.Client.Injectors

* Changelog

* Oh so that's what dotnet-eng was used for. Yeah ok that makes sense.

* Central package management for remaining 2 robust projects

* Ok that was a bad idea let's just use NUnit 3 on the analyzer test project

* Oh right forgot to remove this one

* Update to a newer version of RemoteExecutor

* Disable RemoteExecutor test

https://github.com/dotnet/arcade/issues/8483 Yeah this package is not well maintained and clearly we can't rely on it.

* Fix immutable list serialization
This commit is contained in:
Pieter-Jan Briers
2024-01-12 22:59:52 +01:00
committed by GitHub
parent dfb5369664
commit 0094040d68
71 changed files with 432 additions and 339 deletions
+3
View File
@@ -10,5 +10,8 @@ charset = utf-8
[*.{csproj,xml,yml,dll.config,targets,props}] [*.{csproj,xml,yml,dll.config,targets,props}]
indent_size = 2 indent_size = 2
[nuget.config]
indent_size = 2
[*.gdsl] [*.gdsl]
indent_style = tab indent_style = tab
+61
View File
@@ -0,0 +1,61 @@
<Project>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
<PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageVersion Include="ILReader.Core" Version="1.0.0.4" />
<PackageVersion Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageVersion Include="JetBrains.Profiler.Api" Version="1.4.0" />
<PackageVersion Include="Linguini.Bundle" Version="0.1.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="1.1.1"/>
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit" Version="1.1.1"/>
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeCoverage" Version="17.8.0" />
<PackageVersion Include="Microsoft.Data.Sqlite.Core" Version="8.0.0" />
<PackageVersion Include="Microsoft.DotNet.RemoteExecutor" Version="8.0.0-beta.24059.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
<PackageVersion Include="Microsoft.ILVerification" Version="8.0.0" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageVersion Include="Microsoft.NET.ILLink.Tasks" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="NUnit" Version="4.0.1" />
<PackageVersion Include="NUnit.Analyzers" Version="3.10.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="Nett" Version="0.15.0" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.4" />
<PackageVersion Include="OpenTK.OpenAL" Version="4.7.7" />
<PackageVersion Include="OpenToolkit.Graphics" Version="4.0.0-pre9.1" />
<PackageVersion Include="Pidgin" Version="3.2.2" />
<PackageVersion Include="Robust.Natives" Version="0.1.1" />
<PackageVersion Include="Robust.Natives.Cef" Version="120.1.9" />
<PackageVersion Include="Robust.Shared.AuthLib" Version="0.1.2" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.7" />
<PackageVersion Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.7" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Serilog.Sinks.Loki" Version="4.0.0-beta3" />
<PackageVersion Include="SharpZstd.Interop" Version="1.5.2-beta2" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageVersion Include="SpaceWizards.HttpListener" Version="0.1.0" />
<PackageVersion Include="SpaceWizards.NFluidsynth" Version="0.1.1" />
<PackageVersion Include="SpaceWizards.SharpFont" Version="1.0.2" />
<PackageVersion Include="SpaceWizards.Sodium" Version="0.2.1" />
<PackageVersion Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageVersion Include="TerraFX.Interop.Windows" Version="10.0.22621.5" />
<PackageVersion Include="TerraFX.Interop.Xlib" Version="6.4.0" />
<PackageVersion Include="VorbisPizza" Version="1.3.0" />
<PackageVersion Include="YamlDotNet" Version="13.7.1" />
<PackageVersion Include="prometheus-net" Version="8.2.1" />
<PackageVersion Include="prometheus-net.DotNetRuntime" Version="4.4.0" />
</ItemGroup>
</Project>
+1
View File
@@ -4,6 +4,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup> </PropertyGroup>
<Import Project="Robust.Custom.targets" Condition="Exists('Robust.Custom.targets')"/> <Import Project="Robust.Custom.targets" Condition="Exists('Robust.Custom.targets')"/>
+5 -2
View File
@@ -35,7 +35,10 @@ END TEMPLATE-->
### Breaking changes ### Breaking changes
*None yet* * The unused `Robust.Physics` project has been deleted.
* The project now uses [Central Package Management](https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management).
* (Almost) all the NuGet packages have been updated. This causes many problems. I am so sorry.
* Cleaned up some unused packages as well.
### New features ### New features
@@ -63,7 +66,7 @@ END TEMPLATE-->
### Bugfixes ### Bugfixes
* Avoid buggy behavior if a Bound UI is closed inside the `BoundUIOpenedEvent` that's opening it. * Avoid loading assemblies from content `/Assemblies` if Robust ships its own copy. This avoid duplicate or weird mismatching version issues.
### Other ### Other
@@ -1,23 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" /> <Import Project="..\MSBuild\Robust.Properties.targets"/>
<Import Project="..\MSBuild\Robust.Engine.props" /> <Import Project="..\MSBuild\Robust.Engine.props"/>
<PropertyGroup> <PropertyGroup>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="1.1.1"/> <PackageVersion Update="NUnit" Version="3.14.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit" Version="1.1.1"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1"/>
<PackageReference Include="NUnit" Version="3.13.2"/>
<PackageReference Include="NUnit.ConsoleRunner" Version="3.15.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>
<PackageReference Include="NUnit.Analyzers" Version="3.3.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzer.Testing"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces"/>
<PackageReference Include="NUnit"/>
<PackageReference Include="NUnit3TestAdapter"/>
<PackageReference Include="NUnit.Analyzers"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Robust.Analyzers\Robust.Analyzers.csproj"/> <ProjectReference Include="..\Robust.Analyzers\Robust.Analyzers.csproj"/>
</ItemGroup> </ItemGroup>
+5 -4
View File
@@ -3,19 +3,20 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.0.1" /> <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<!-- Needed for NotNullableFlagAnalyzer. --> <!-- Needed for NotNullableFlagAnalyzer. -->
<Compile Include="..\Robust.Shared\Analyzers\NotNullableFlagAttribute.cs" /> <Compile Include="..\Robust.Shared\Analyzers\NotNullableFlagAttribute.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<!-- Needed for FriendAnalyzer. --> <!-- Needed for FriendAnalyzer. -->
<Compile Include="..\Robust.Shared\Analyzers\AccessAttribute.cs" /> <Compile Include="..\Robust.Shared\Analyzers\AccessAttribute.cs" />
+10 -1
View File
@@ -1,15 +1,18 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using BenchmarkDotNet.Analysers; using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Columns; using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs; using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.EventProcessors;
using BenchmarkDotNet.Exporters; using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Filters; using BenchmarkDotNet.Filters;
using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Order; using BenchmarkDotNet.Order;
using BenchmarkDotNet.Reports; using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Validators; using BenchmarkDotNet.Validators;
using Robust.Benchmarks.Exporters; using Robust.Benchmarks.Exporters;
@@ -44,10 +47,16 @@ public sealed class DefaultSQLConfig : IConfig
public IEnumerable<BenchmarkLogicalGroupRule> GetLogicalGroupRules() => DefaultConfig.Instance.GetLogicalGroupRules(); public IEnumerable<BenchmarkLogicalGroupRule> GetLogicalGroupRules() => DefaultConfig.Instance.GetLogicalGroupRules();
public IEnumerable<EventProcessor> GetEventProcessors() => DefaultConfig.Instance.GetEventProcessors();
public IEnumerable<IColumnHidingRule> GetColumnHidingRules() => DefaultConfig.Instance.GetColumnHidingRules();
public IOrderer Orderer => DefaultConfig.Instance.Orderer!; public IOrderer Orderer => DefaultConfig.Instance.Orderer!;
public ICategoryDiscoverer? CategoryDiscoverer => DefaultConfig.Instance.CategoryDiscoverer;
public SummaryStyle SummaryStyle => DefaultConfig.Instance.SummaryStyle; public SummaryStyle SummaryStyle => DefaultConfig.Instance.SummaryStyle;
public ConfigUnionRule UnionRule => DefaultConfig.Instance.UnionRule; public ConfigUnionRule UnionRule => DefaultConfig.Instance.UnionRule;
public string ArtifactsPath => DefaultConfig.Instance.ArtifactsPath; public string ArtifactsPath => DefaultConfig.Instance.ArtifactsPath;
public CultureInfo CultureInfo => DefaultConfig.Instance.CultureInfo!; public CultureInfo CultureInfo => DefaultConfig.Instance.CultureInfo!;
public ConfigOptions Options => DefaultConfig.Instance.Options; public ConfigOptions Options => DefaultConfig.Instance.Options;
public TimeSpan BuildTimeout => DefaultConfig.Instance.BuildTimeout;
public IReadOnlyList<Conclusion> ConfigAnalysisConclusion => DefaultConfig.Instance.ConfigAnalysisConclusion;
} }
+3 -3
View File
@@ -13,12 +13,12 @@
<ProjectReference Include="..\Robust.UnitTesting\Robust.UnitTesting.csproj" /> <ProjectReference Include="..\Robust.UnitTesting\Robust.UnitTesting.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" /> <PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
</ItemGroup> </ItemGroup>
<Import Project="..\MSBuild\Robust.Properties.targets" /> <Import Project="..\MSBuild\Robust.Properties.targets" />
@@ -6,8 +6,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="17.0.0" /> <PackageReference Include="Microsoft.Build.Framework" Version="17.8.3" />
<PackageReference Include="Mono.Cecil" Version="0.11.3" /> <PackageReference Include="Mono.Cecil" Version="0.11.5" />
<PackageReference Include="Pidgin" Version="2.5.0" /> <PackageReference Include="Pidgin" Version="2.5.0" />
</ItemGroup> </ItemGroup>
@@ -2,11 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -8,8 +8,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.3.0" /> <PackageReference Include="JetBrains.Annotations" />
<PackageReference Include="Robust.Natives.Cef" Version="120.1.9" /> <PackageReference Include="Robust.Natives.Cef" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -224,8 +224,8 @@ namespace Robust.Client.Graphics.Clyde
fixed (char* pCaption = "RobustToolbox: Failed to create window") fixed (char* pCaption = "RobustToolbox: Failed to create window")
{ {
Windows.MessageBoxW(HWND.NULL, Windows.MessageBoxW(HWND.NULL,
(ushort*) pText, pText,
(ushort*) pCaption, pCaption,
MB.MB_OK | MB.MB_ICONERROR); MB.MB_OK | MB.MB_ICONERROR);
} }
} }
@@ -413,7 +413,7 @@ namespace Robust.Client.Graphics.Clyde
DXGI_ADAPTER_DESC1 desc; DXGI_ADAPTER_DESC1 desc;
ThrowIfFailed("GetDesc1", _adapter->GetDesc1(&desc)); ThrowIfFailed("GetDesc1", _adapter->GetDesc1(&desc));
var descName = new ReadOnlySpan<char>(desc.Description, 128).TrimEnd('\0'); var descName = ((ReadOnlySpan<char>)desc.Description).TrimEnd('\0');
Logger.DebugS("clyde.ogl.angle", "Successfully created D3D11 device!"); Logger.DebugS("clyde.ogl.angle", "Successfully created D3D11 device!");
Logger.DebugS("clyde.ogl.angle", $"D3D11 Device Adapter: {descName.ToString()}"); Logger.DebugS("clyde.ogl.angle", $"D3D11 Device Adapter: {descName.ToString()}");
@@ -493,7 +493,7 @@ namespace Robust.Client.Graphics.Clyde
DXGI_ADAPTER_DESC1 desc; DXGI_ADAPTER_DESC1 desc;
ThrowIfFailed("GetDesc1", adapter->GetDesc1(&desc)); ThrowIfFailed("GetDesc1", adapter->GetDesc1(&desc));
var descName = new ReadOnlySpan<char>(desc.Description, 128); var descName = ((ReadOnlySpan<char>)desc.Description);
if (descName.StartsWith(name)) if (descName.StartsWith(name))
return adapter; return adapter;
+1 -1
View File
@@ -36,7 +36,7 @@ namespace Robust.Client.Graphics.Clyde
adapter->Release(); adapter->Release();
ThrowIfFailed("GetDesc", adapter3->GetDesc2(&desc)); ThrowIfFailed("GetDesc", adapter3->GetDesc2(&desc));
var descString = new ReadOnlySpan<char>(desc.Description, 128).TrimEnd('\0'); var descString = ((ReadOnlySpan<char>)desc.Description).TrimEnd('\0');
shell.WriteLine(descString.ToString()); shell.WriteLine(descString.ToString());
DXGI_QUERY_VIDEO_MEMORY_INFO memInfo; DXGI_QUERY_VIDEO_MEMORY_INFO memInfo;
+21 -22
View File
@@ -5,33 +5,33 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<NoWarn>NU1701</NoWarn> <NoWarn>NU1701;CA1416</NoWarn>
<OutputPath>../bin/Client</OutputPath> <OutputPath>../bin/Client</OutputPath>
<RobustILLink>true</RobustILLink> <RobustILLink>true</RobustILLink>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DiscordRichPresence" Version="1.0.175" PrivateAssets="compile" /> <PackageReference Include="DiscordRichPresence" PrivateAssets="compile" />
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" /> <PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="6.0.9" PrivateAssets="compile" /> <PackageReference Include="Microsoft.Data.Sqlite.Core" PrivateAssets="compile" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.2" Condition="'$(UseSystemSqlite)' == 'True'" PrivateAssets="compile" /> <PackageReference Include="SQLitePCLRaw.provider.sqlite3" Condition="'$(UseSystemSqlite)' == 'True'" PrivateAssets="compile" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.2" Condition="'$(UseSystemSqlite)' != 'True'" PrivateAssets="compile" /> <PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Condition="'$(UseSystemSqlite)' != 'True'" PrivateAssets="compile" />
<PackageReference Include="SpaceWizards.NFluidsynth" Version="0.1.1" PrivateAssets="compile" /> <PackageReference Include="SpaceWizards.NFluidsynth" PrivateAssets="compile" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" /> <PackageReference Include="SixLabors.ImageSharp" />
<PackageReference Include="OpenToolkit.Graphics" Version="4.0.0-pre9.1" PrivateAssets="compile" /> <PackageReference Include="OpenToolkit.Graphics" PrivateAssets="compile" />
<PackageReference Include="OpenTK.OpenAL" Version="4.7.5" PrivateAssets="compile" /> <PackageReference Include="OpenTK.OpenAL" PrivateAssets="compile" />
<PackageReference Include="SpaceWizards.SharpFont" Version="1.0.1" PrivateAssets="compile" /> <PackageReference Include="SpaceWizards.SharpFont" PrivateAssets="compile" />
<PackageReference Include="Robust.Natives" Version="0.1.1" /> <PackageReference Include="Robust.Natives" />
<PackageReference Include="System.Numerics.Vectors" Version="4.4.0" /> <PackageReference Include="System.Numerics.Vectors" />
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.20348-rc2" PrivateAssets="compile" /> <PackageReference Include="TerraFX.Interop.Windows" PrivateAssets="compile" />
<PackageReference Condition="'$(FullRelease)' != 'True'" Include="JetBrains.Profiler.Api" Version="1.2.0" PrivateAssets="compile" /> <PackageReference Condition="'$(FullRelease)' != 'True'" Include="JetBrains.Profiler.Api" PrivateAssets="compile" />
<PackageReference Include="SpaceWizards.Sodium" Version="0.2.1" PrivateAssets="compile" /> <PackageReference Include="SpaceWizards.Sodium" PrivateAssets="compile" />
<PackageReference Include="Microsoft.NET.ILLink.Tasks" Version="8.0.0" /> <PackageReference Include="Microsoft.NET.ILLink.Tasks" />
<PackageReference Include="TerraFX.Interop.Xlib" Version="6.4.0" /> <PackageReference Include="TerraFX.Interop.Xlib" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(EnableClientScripting)' == 'True'"> <ItemGroup Condition="'$(EnableClientScripting)' == 'True'">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.0.1" PrivateAssets="compile" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" PrivateAssets="compile" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.0.1" PrivateAssets="compile" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" PrivateAssets="compile" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" PrivateAssets="compile" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" PrivateAssets="compile" />
<ProjectReference Include="..\Robust.Shared.Scripting\Robust.Shared.Scripting.csproj" /> <ProjectReference Include="..\Robust.Shared.Scripting\Robust.Shared.Scripting.csproj" />
</ItemGroup> </ItemGroup>
@@ -40,7 +40,6 @@
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" /> <ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\OpenToolkit.GraphicsLibraryFramework\OpenToolkit.GraphicsLibraryFramework.csproj" /> <ProjectReference Include="..\OpenToolkit.GraphicsLibraryFramework\OpenToolkit.GraphicsLibraryFramework.csproj" />
<ProjectReference Include="..\Robust.LoaderApi\Robust.LoaderApi\Robust.LoaderApi.csproj" /> <ProjectReference Include="..\Robust.LoaderApi\Robust.LoaderApi\Robust.LoaderApi.csproj" />
<ProjectReference Include="..\Robust.Physics\Robust.Physics.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" /> <ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" /> <ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
</ItemGroup> </ItemGroup>
@@ -4,6 +4,7 @@ using Robust.Shared.Resources;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using SixLabors.ImageSharp; using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Png.Chunks;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
namespace Robust.Packaging.AssetProcessing.Passes; namespace Robust.Packaging.AssetProcessing.Passes;
@@ -168,7 +169,7 @@ internal sealed class AssetPassPackRsis : AssetPass
} }
var ms = new MemoryStream(); var ms = new MemoryStream();
sheet.Metadata.GetPngMetadata().TextData.Add(new PngTextData("Description", metaJson, null, null)); sheet.Metadata.GetPngMetadata().TextData.Add(new PngTextData("Description", metaJson, "", ""));
sheet.SaveAsPng(ms); sheet.SaveAsPng(ms);
sheet.Dispose(); sheet.Dispose();
-4
View File
@@ -10,9 +10,5 @@
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" /> <ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="NVorbis" Version="0.10.5" />
</ItemGroup>
<Import Project="..\MSBuild\Robust.Properties.targets" /> <Import Project="..\MSBuild\Robust.Properties.targets" />
</Project> </Project>
-22
View File
@@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Engine.props" />
<PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>TRACE;RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
</ItemGroup>
<Import Project="..\MSBuild\Robust.Properties.targets" />
</Project>
@@ -4,12 +4,13 @@
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11</LangVersion> <LangVersion>11</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.4.0" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.Common" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.4.0" /> <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -19,13 +19,15 @@ internal sealed partial class MetricsManager
{ {
private readonly ISawmill _sawmill; private readonly ISawmill _sawmill;
private readonly HttpListener _listener; private readonly HttpListener _listener;
private readonly CollectorRegistry _registry;
public ManagedHttpListenerMetricsServer(ISawmill sawmill, string host, int port, string url = "metrics/", public ManagedHttpListenerMetricsServer(ISawmill sawmill, string host, int port, string url = "metrics/",
CollectorRegistry? registry = null) : base(registry) CollectorRegistry? registry = null)
{ {
_sawmill = sawmill; _sawmill = sawmill;
_listener = new HttpListener(); _listener = new HttpListener();
_listener.Prefixes.Add($"http://{host}:{port}/{url}"); _listener.Prefixes.Add($"http://{host}:{port}/{url}");
_registry = registry ?? Metrics.DefaultRegistry;
} }
protected override Task StartServer(CancellationToken cancel) protected override Task StartServer(CancellationToken cancel)
+1 -1
View File
@@ -27,7 +27,7 @@ namespace Robust.Server.Log
if (valid) if (valid)
{ {
message.AddOrUpdateProperty(sawmillProperty); message.AddOrUpdateProperty(sawmillProperty!);
} }
_sLogger.Write(message); _sLogger.Write(message);
+19 -16
View File
@@ -10,27 +10,30 @@
<!-- Try to fix sporadic errors against Robust.Packaging, apparently?? --> <!-- Try to fix sporadic errors against Robust.Packaging, apparently?? -->
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained> <ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<RobustILLink>true</RobustILLink> <RobustILLink>true</RobustILLink>
<NoWarn>CA1416</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" /> <PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
<PackageReference Include="SpaceWizards.HttpListener" Version="0.1.0" PrivateAssets="compile" /> <PackageReference Include="SpaceWizards.HttpListener" PrivateAssets="compile" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="6.0.9" /> <PackageReference Include="Microsoft.Data.Sqlite.Core" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.4" Condition="'$(UseSystemSqlite)' == 'True'" /> <!-- Cannot be private since Content.Server/Database/ServerDbManager.cs depends on SQLitePCL.raw --> <PackageReference Include="SQLitePCLRaw.provider.sqlite3" Condition="'$(UseSystemSqlite)' == 'True'" /> <!-- Cannot be private since Content.Server/Database/ServerDbManager.cs depends on SQLitePCL.raw -->
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.4" Condition="'$(UseSystemSqlite)' != 'True'" PrivateAssets="compile" /> <PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Condition="'$(UseSystemSqlite)' != 'True'" PrivateAssets="compile" />
<PackageReference Include="prometheus-net" Version="4.1.1" /> <PackageReference Include="prometheus-net" />
<PackageReference Include="Serilog.Sinks.Loki" Version="4.0.0-beta3" PrivateAssets="compile" /> <PackageReference Include="Serilog.Sinks.Loki" PrivateAssets="compile" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Primitives" />
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.2.2" /> <!-- Needed to pull-up the dependency from prometheus-net -->
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.20348-rc2" PrivateAssets="compile" /> <PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="6.0.2" PrivateAssets="compile" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="SpaceWizards.Sodium" Version="0.2.1" PrivateAssets="compile" /> <PackageReference Include="prometheus-net.DotNetRuntime" />
<PackageReference Include="SharpZstd.Interop" Version="1.5.2-beta2" PrivateAssets="compile" /> <PackageReference Include="TerraFX.Interop.Windows" PrivateAssets="compile" />
<PackageReference Condition="'$(FullRelease)' != 'True'" Include="JetBrains.Profiler.Api" Version="1.2.0" /> <PackageReference Include="Microsoft.Extensions.ObjectPool" PrivateAssets="compile" />
<PackageReference Include="Microsoft.NET.ILLink.Tasks" Version="8.0.0" /> <PackageReference Include="SpaceWizards.Sodium" PrivateAssets="compile" />
<PackageReference Include="SharpZstd.Interop" PrivateAssets="compile" />
<PackageReference Condition="'$(FullRelease)' != 'True'" Include="JetBrains.Profiler.Api" />
<PackageReference Include="Microsoft.NET.ILLink.Tasks" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" /> <ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\Robust.Physics\Robust.Physics.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" /> <ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared.Scripting\Robust.Shared.Scripting.csproj" /> <ProjectReference Include="..\Robust.Shared.Scripting\Robust.Shared.Scripting.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" /> <ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
+12 -17
View File
@@ -297,25 +297,20 @@ namespace Robust.Server.Scripting
var results = await (CompletionService var results = await (CompletionService
.GetService(document)? .GetService(document)?
.GetCompletionsAsync(document, message.Cursor) ?? Task.FromResult<CompletionList?>(null)); .GetCompletionsAsync(document, message.Cursor) ?? Task.FromResult(CompletionList.Empty));
if (results is not null) var ires = ImmutableArray.CreateBuilder<LiteResult>();
{ foreach (var r in results.ItemsList)
var ires = ImmutableArray.CreateBuilder<LiteResult>(); ires.Add(new LiteResult(
foreach (var r in results.Items) displayText: r.DisplayText,
ires.Add(new LiteResult( displayTextPrefix: r.DisplayTextPrefix,
displayText: r.DisplayText, displayTextSuffix: r.DisplayTextSuffix,
displayTextPrefix: r.DisplayTextPrefix, inlineDescription: r.InlineDescription,
displayTextSuffix: r.DisplayTextSuffix, tags: r.Tags,
inlineDescription: r.InlineDescription, properties: r.Properties
tags: r.Tags, ));
properties: r.Properties
));
replyMessage.Results = ires.ToImmutable(); replyMessage.Results = ires.ToImmutable();
}
else
replyMessage.Results = ImmutableArray<LiteResult>.Empty;
_netManager.ServerSendMessage(replyMessage, message.MsgChannel); _netManager.ServerSendMessage(replyMessage, message.MsgChannel);
} }
+1 -1
View File
@@ -308,7 +308,7 @@ namespace Robust.Server.ServerStatus
private static bool RequestWantsZStd(IStatusHandlerContext context) private static bool RequestWantsZStd(IStatusHandlerContext context)
{ {
// Yeah this isn't a good parser for Accept-Encoding but who cares. // Yeah this isn't a good parser for Accept-Encoding but who cares.
return context.RequestHeaders.TryGetValue("Accept-Encoding", out var ac) && ac.Count > 0 && ac[0].Contains("zstd"); return context.RequestHeaders.TryGetValue("Accept-Encoding", out var ac) && ac.Count > 0 && ac[0]?.Contains("zstd") == true;
} }
// Only call this if the download URL is not available! // Only call this if the download URL is not available!
@@ -3,10 +3,11 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion> <LangVersion>9</LangVersion>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -6,7 +6,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" /> <PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<Import Project="..\MSBuild\Robust.Properties.targets" /> <Import Project="..\MSBuild\Robust.Properties.targets" />
@@ -7,11 +7,11 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ILReader.Core" Version="1.0.0.4" /> <PackageReference Include="ILReader.Core" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.0.1" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.0.1" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" /> <PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -913,9 +913,14 @@ namespace Robust.Shared.ContentPack
return null; return null;
} }
public PEReader? Resolve(string simpleName) public PEReader? ResolveAssembly(AssemblyName assemblyName)
{ {
return _dictionary.GetOrAdd(simpleName, ResolveCore); return _dictionary.GetOrAdd(assemblyName.Name!, ResolveCore);
}
public PEReader? ResolveModule(AssemblyName referencingAssembly, string fileName)
{
throw new NotSupportedException();
} }
public void Dispose() public void Dispose()
+30 -2
View File
@@ -325,19 +325,23 @@ namespace Robust.Shared.ContentPack
{ {
lock (_lock) lock (_lock)
{ {
Sawmill.Debug("ResolvingAssembly {0}", name); Sawmill.Verbose("ResolvingAssembly {0}", name);
// Try main modules. // Try main modules.
foreach (var mod in Mods) foreach (var mod in Mods)
{ {
if (mod.GameAssembly.FullName == name.FullName) if (mod.GameAssembly.FullName == name.FullName)
{ {
Sawmill.Verbose($"Found assembly in modloader ALC: {mod.GameAssembly}");
return mod.GameAssembly; return mod.GameAssembly;
} }
} }
if (TryLoadExtra(name) is { } asm) if (TryLoadExtra(name) is { } asm)
{
Sawmill.Verbose($"Found assembly through extra loader: {asm}");
return asm; return asm;
}
// Do not allow sideloading when sandboxing is enabled. // Do not allow sideloading when sandboxing is enabled.
// Side loaded assemblies would not be checked for sandboxing currently, so we can't have that. // Side loaded assemblies would not be checked for sandboxing currently, so we can't have that.
@@ -347,18 +351,42 @@ namespace Robust.Shared.ContentPack
{ {
if (assembly.FullName == name.FullName) if (assembly.FullName == name.FullName)
{ {
Sawmill.Verbose($"Found assembly in existing side modules: {assembly}");
return assembly; return assembly;
} }
} }
// Try to resolve assemblies in the default AssemblyLoadContext.
// If we don't do this manually, the sideloading code below could load assemblies from content,
// even if Robust provides its own versions.
// This can lead to:
// * Multiple copies of the same assembly being loaded.
// * Mismatching versions of dependencies being loaded.
// * e.g. Microsoft.Extensions.Primitives 6.0 with Microsoft.Extensions.DependencyInjection 7.0
//
// Now, to be clear, this is 100% an error in packaging. But it's also one that's really easy to make.
//
try
{
var defaultAssembly = AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(name.Name!));
Sawmill.Verbose($"Found assembly through default ALC (early): {defaultAssembly}");
return defaultAssembly;
}
catch
{
// Assume assembly not loadable from Robust's directory, proceed with loading from content.
}
if (_res.TryContentFileRead($"/Assemblies/{name.Name}.dll", out var dll)) if (_res.TryContentFileRead($"/Assemblies/{name.Name}.dll", out var dll))
{ {
var assembly = _loadContext.LoadFromStream(dll); var assembly = _loadContext.LoadFromStream(dll);
_sideModules.Add(assembly); _sideModules.Add(assembly);
Sawmill.Verbose($"Found assembly in NEW side module: {assembly}");
return assembly; return assembly;
} }
} }
Sawmill.Verbose("Did not find assembly directly. Should fall back to default ALC.");
return null; return null;
} }
} }
@@ -381,7 +409,7 @@ namespace Robust.Shared.ContentPack
// Otherwise it would load the assemblies a second time which is an amazing way to have everything break. // Otherwise it would load the assemblies a second time which is an amazing way to have everything break.
if (_useLoadContext) if (_useLoadContext)
{ {
Sawmill.Debug($"RESOLVING DEFAULT: {name}"); Sawmill.Verbose($"RESOLVING DEFAULT: {name}");
foreach (var module in LoadedModules) foreach (var module in LoadedModules)
{ {
if (module.GetName().Name == name.Name) if (module.GetName().Name == name.Name)
+3
View File
@@ -1408,4 +1408,7 @@ Types:
# should be fine to do All: True, but this has some methods to read filestreams. So just in case this ever adds an extension method that directly opens a file: # should be fine to do All: True, but this has some methods to read filestreams. So just in case this ever adds an extension method that directly opens a file:
Methods: Methods:
- "!!0 ParseOrThrow<>(Pidgin.Parser`2<char, !!0>, string, System.Func`3<char, Pidgin.SourcePos, Pidgin.SourcePos>)" - "!!0 ParseOrThrow<>(Pidgin.Parser`2<char, !!0>, string, System.Func`3<char, Pidgin.SourcePos, Pidgin.SourcePos>)"
- "!!0 ParseOrThrow<>(Pidgin.Parser`2<char, !!0>, string, Pidgin.Configuration.IConfiguration`1<char>)"
SourcePos: { } SourcePos: { }
Pidgin.Configuration:
IConfiguration`1: { All: True }
@@ -13,10 +13,10 @@ internal sealed class RobustMemoryManager
// Let's be real this is a bandaid for pooling bullshit at an engine level and I don't know what // Let's be real this is a bandaid for pooling bullshit at an engine level and I don't know what
// good memory management looks like for PVS or the RobustSerializer. // good memory management looks like for PVS or the RobustSerializer.
private static readonly RecyclableMemoryStreamManager MemStreamManager = new() private static readonly RecyclableMemoryStreamManager MemStreamManager = new(new RecyclableMemoryStreamManager.Options
{ {
ThrowExceptionOnToArray = true, ThrowExceptionOnToArray = true,
}; });
public RobustMemoryManager() public RobustMemoryManager()
{ {
+3 -1
View File
@@ -73,7 +73,9 @@ namespace Robust.Shared.Log
public void Log(LogLevel level, Exception? exception, string message, params object?[] args) public void Log(LogLevel level, Exception? exception, string message, params object?[] args)
{ {
_sLogger.BindMessageTemplate(message, args, out var parsedTemplate, out var properties); if (!_sLogger.BindMessageTemplate(message, args, out var parsedTemplate, out var properties))
return;
var msg = new LogEvent(DateTimeOffset.Now, level.ToSerilog(), exception, parsedTemplate, properties); var msg = new LogEvent(DateTimeOffset.Now, level.ToSerilog(), exception, parsedTemplate, properties);
LogInternal(Name, msg); LogInternal(Name, msg);
} }
+18 -18
View File
@@ -4,30 +4,30 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>CA1416</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" /> <PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="6.0.2" /> <PackageReference Include="Microsoft.Extensions.ObjectPool" />
<PackageReference Include="Microsoft.ILVerification" Version="6.0.0" PrivateAssets="compile" /> <PackageReference Include="Microsoft.ILVerification" PrivateAssets="compile" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" /> <PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
<PackageReference Include="Nett" Version="0.15.0" PrivateAssets="compile" /> <PackageReference Include="Nett" PrivateAssets="compile" />
<PackageReference Include="VorbisPizza" Version="1.3.0" PrivateAssets="compile" /> <PackageReference Include="VorbisPizza" PrivateAssets="compile" />
<PackageReference Include="Pidgin" Version="2.5.0" /> <PackageReference Include="Pidgin" />
<PackageReference Include="prometheus-net" Version="4.1.1" /> <PackageReference Include="prometheus-net" />
<PackageReference Include="Robust.Shared.AuthLib" Version="0.1.2" /> <PackageReference Include="Robust.Shared.AuthLib" />
<PackageReference Include="Serilog" Version="2.10.0" /> <PackageReference Include="Serilog" />
<PackageReference Include="YamlDotNet" Version="12.0.0" /> <PackageReference Include="YamlDotNet" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" PrivateAssets="compile" /> <PackageReference Include="Microsoft.Win32.Registry" PrivateAssets="compile" />
<PackageReference Include="Linguini.Bundle" Version="0.1.3" /> <PackageReference Include="Linguini.Bundle" />
<PackageReference Include="SharpZstd.Interop" Version="1.5.2-beta2" PrivateAssets="compile" /> <PackageReference Include="SharpZstd.Interop" PrivateAssets="compile" />
<PackageReference Include="SpaceWizards.Sodium" Version="0.2.1" PrivateAssets="compile" /> <PackageReference Include="SpaceWizards.Sodium" PrivateAssets="compile" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" /> <PackageReference Include="SixLabors.ImageSharp" />
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.20348-rc2" PrivateAssets="compile" /> <PackageReference Include="TerraFX.Interop.Windows" PrivateAssets="compile" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" /> <ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" /> <ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" />
<ProjectReference Include="..\Robust.Physics\Robust.Physics.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" /> <ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+3 -3
View File
@@ -63,7 +63,7 @@ internal sealed unsafe class PrecisionSleepWindowsHighResolution : PrecisionSlee
Windows.TIMER_ALL_ACCESS); Windows.TIMER_ALL_ACCESS);
if (_timerHandle == HANDLE.NULL) if (_timerHandle == HANDLE.NULL)
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); Marshal.ThrowExceptionForHR(Windows.HRESULT_FROM_WIN32(Marshal.GetLastSystemError()));
} }
public override void Sleep(TimeSpan time) public override void Sleep(TimeSpan time)
@@ -82,11 +82,11 @@ internal sealed unsafe class PrecisionSleepWindowsHighResolution : PrecisionSlee
); );
if (!success) if (!success)
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); Marshal.ThrowExceptionForHR(Windows.HRESULT_FROM_WIN32(Marshal.GetLastSystemError()));
var waitResult = Windows.WaitForSingleObject(_timerHandle, Windows.INFINITE); var waitResult = Windows.WaitForSingleObject(_timerHandle, Windows.INFINITE);
if (waitResult == WAIT.WAIT_FAILED) if (waitResult == WAIT.WAIT_FAILED)
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); Marshal.ThrowExceptionForHR(Windows.HRESULT_FROM_WIN32(Marshal.GetLastSystemError()));
GC.KeepAlive(this); GC.KeepAlive(this);
} }
+2 -2
View File
@@ -50,7 +50,7 @@ internal static class FileHelper
fixed (char* pPath = path) fixed (char* pPath = path)
{ {
file = Windows.CreateFileW( file = Windows.CreateFileW(
(ushort*)pPath, pPath,
Windows.GENERIC_READ, Windows.GENERIC_READ,
FILE.FILE_SHARE_READ, FILE.FILE_SHARE_READ,
null, null,
@@ -61,7 +61,7 @@ internal static class FileHelper
if (file == HANDLE.INVALID_VALUE) if (file == HANDLE.INVALID_VALUE)
{ {
var lastError = Marshal.GetLastWin32Error(); var lastError = Marshal.GetLastSystemError();
if (lastError is ERROR.ERROR_FILE_NOT_FOUND or ERROR.ERROR_PATH_NOT_FOUND) if (lastError is ERROR.ERROR_FILE_NOT_FOUND or ERROR.ERROR_PATH_NOT_FOUND)
{ {
stream = null; stream = null;
@@ -81,7 +81,7 @@ namespace Robust.UnitTesting.Client.GameStates
timing.LastProcessedTick = new GameTick(2); timing.LastProcessedTick = new GameTick(2);
processor.TryGetServerState(out var state, out _); processor.TryGetServerState(out var state, out _);
Assert.NotNull(state); Assert.That(state, Is.Not.Null);
Assert.That(state!.ToSequence.Value, Is.EqualTo(1)); Assert.That(state!.ToSequence.Value, Is.EqualTo(1));
} }
+9 -12
View File
@@ -7,21 +7,18 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" /> <PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="Castle.Core" Version="4.4.1" /> <PackageReference Include="JetBrains.Annotations" />
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" /> <PackageReference Include="Microsoft.CodeCoverage" />
<PackageReference Include="Microsoft.CodeCoverage" Version="17.0.0" /> <PackageReference Include="Microsoft.DotNet.RemoteExecutor" />
<PackageReference Include="Microsoft.DotNet.RemoteExecutor" Version="6.0.0-beta.20562.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> <PackageReference Include="Moq" />
<PackageReference Include="Moq" Version="4.16.1" /> <PackageReference Include="NUnit" />
<PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.15.0" /> <PackageReference Include="NUnit.Analyzers" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" /> <ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\Robust.Physics\Robust.Physics.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" /> <ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" /> <ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
<ProjectReference Include="..\Robust.Client\Robust.Client.csproj" /> <ProjectReference Include="..\Robust.Client\Robust.Client.csproj" />
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@@ -23,8 +23,8 @@ public sealed class OverflowDictionary_Test
var dict = new OverflowDictionary<int, int>(1, (_) => disposedCalled++); var dict = new OverflowDictionary<int, int>(1, (_) => disposedCalled++);
dict.Add(0,0); dict.Add(0,0);
dict.Add(1,0); dict.Add(1,0);
Assert.False(dict.ContainsKey(0)); Assert.That(dict.ContainsKey(0), Is.False);
Assert.True(dict.ContainsKey(1)); Assert.That(dict.ContainsKey(1));
Assert.That(disposedCalled, Is.EqualTo(1)); Assert.That(disposedCalled, Is.EqualTo(1));
Assert.That(dict.Count, Is.EqualTo(1)); Assert.That(dict.Count, Is.EqualTo(1));
} }
@@ -56,7 +56,7 @@ public sealed class OverflowDictionary_Test
if(overlap > 0) if(overlap > 0)
{ {
Assert.False(dict.ContainsKey(0)); Assert.That(dict.ContainsKey(0), Is.False);
Assert.That(dict.Count, Is.EqualTo(test.size)); Assert.That(dict.Count, Is.EqualTo(test.size));
} }
else else
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.Collections; using Robust.Shared.Collections;
@@ -20,7 +20,7 @@ public sealed class OverflowQueue_Test
{ {
var queue = new OverflowQueue<int>(test.size); var queue = new OverflowQueue<int>(test.size);
Assert.False(queue.Contains(0)); Assert.That(queue.Contains(0), Is.False);
for (int i = 0; i < test.iterations; i++) for (int i = 0; i < test.iterations; i++)
{ {
@@ -34,7 +34,7 @@ public sealed class OverflowQueue_Test
} }
Assert.That(queue.Contains(test.iterations-1)); Assert.That(queue.Contains(test.iterations-1));
Assert.False(queue.Contains(-1)); Assert.That(queue.Contains(-1), Is.False);
Assert.That(queue.Peek(), Is.EqualTo(overlap)); Assert.That(queue.Peek(), Is.EqualTo(overlap));
var array = queue.ToArray(); var array = queue.ToArray();
@@ -51,6 +51,6 @@ public sealed class OverflowQueue_Test
} }
Assert.Throws<InvalidOperationException>(() => queue.Dequeue()); Assert.Throws<InvalidOperationException>(() => queue.Dequeue());
Assert.False(queue.TryDequeue(out _)); Assert.That(queue.TryDequeue(out _), Is.False);
} }
} }
@@ -48,16 +48,16 @@ namespace Robust.UnitTesting.Shared.GameObjects
Assert.Throws<UnknownComponentException>(() => componentFactory.GetComponent(NonexistentComponentName, true)); Assert.Throws<UnknownComponentException>(() => componentFactory.GetComponent(NonexistentComponentName, true));
// Normal casing, do not ignore case, should exist // Normal casing, do not ignore case, should exist
Assert.IsInstanceOf<TestComponent>(componentFactory.GetComponent(TestComponentName)); Assert.That(componentFactory.GetComponent(TestComponentName), Is.InstanceOf<TestComponent>());
// Normal casing, ignore case, should exist // Normal casing, ignore case, should exist
Assert.IsInstanceOf<TestComponent>(componentFactory.GetComponent(TestComponentName, true)); Assert.That(componentFactory.GetComponent(TestComponentName, true), Is.InstanceOf<TestComponent>());
// Lower casing, do not ignore case, should not exist // Lower casing, do not ignore case, should not exist
Assert.Throws<UnknownComponentException>(() => componentFactory.GetComponent(LowercaseTestComponentName)); Assert.Throws<UnknownComponentException>(() => componentFactory.GetComponent(LowercaseTestComponentName));
// Lower casing, ignore case, should exist // Lower casing, ignore case, should exist
Assert.IsInstanceOf<TestComponent>(componentFactory.GetComponent(LowercaseTestComponentName, true)); Assert.That(componentFactory.GetComponent(LowercaseTestComponentName, true), Is.InstanceOf<TestComponent>());
} }
[Test] [Test]
@@ -88,20 +88,20 @@ namespace Robust.UnitTesting.Shared.GameObjects
var componentFactory = IoCManager.Resolve<IComponentFactory>(); var componentFactory = IoCManager.Resolve<IComponentFactory>();
// Should not exist // Should not exist
Assert.False(componentFactory.TryGetRegistration(NonexistentComponentName, out _)); Assert.That(componentFactory.TryGetRegistration(NonexistentComponentName, out _), Is.False);
Assert.False(componentFactory.TryGetRegistration(NonexistentComponentName, out _, true)); Assert.That(componentFactory.TryGetRegistration(NonexistentComponentName, out _, true), Is.False);
// Normal casing, do not ignore case, should exist // Normal casing, do not ignore case, should exist
Assert.True(componentFactory.TryGetRegistration(TestComponentName, out _)); Assert.That(componentFactory.TryGetRegistration(TestComponentName, out _));
// Normal casing, ignore case, should exist // Normal casing, ignore case, should exist
Assert.True(componentFactory.TryGetRegistration(TestComponentName, out _, true)); Assert.That(componentFactory.TryGetRegistration(TestComponentName, out _, true));
// Lower casing, do not ignore case, should not exist // Lower casing, do not ignore case, should not exist
Assert.False(componentFactory.TryGetRegistration(LowercaseTestComponentName, out _)); Assert.That(componentFactory.TryGetRegistration(LowercaseTestComponentName, out _), Is.False);
// Lower casing, ignore case, should exist // Lower casing, ignore case, should exist
Assert.True(componentFactory.TryGetRegistration(LowercaseTestComponentName, out _, true)); Assert.That(componentFactory.TryGetRegistration(LowercaseTestComponentName, out _, true));
} }
[ComponentProtoName(TestComponentName)] [ComponentProtoName(TestComponentName)]
@@ -347,7 +347,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
} }
var containerEnt = container.Owner; var containerEnt = container.Owner;
Assert.NotNull(container.Comp); Assert.That(container.Comp, Is.Not.Null);
Assert.That(sEntManager.GetComponent<MetaDataComponent>(containerEnt).EntityName, Is.EqualTo("ContainerEnt")); Assert.That(sEntManager.GetComponent<MetaDataComponent>(containerEnt).EntityName, Is.EqualTo("ContainerEnt"));
@@ -214,7 +214,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
entMan.RemoveComponentDeferred(entity, component); entMan.RemoveComponentDeferred(entity, component);
Assert.That(component.LifeStage, Is.EqualTo(ComponentLifeStage.Stopped)); Assert.That(component.LifeStage, Is.EqualTo(ComponentLifeStage.Stopped));
Assert.False(entMan.EnsureComponent<DummyComponent>(entity, out var comp2)); Assert.That(entMan.EnsureComponent<DummyComponent>(entity, out var comp2), Is.False);
Assert.That(comp2.LifeStage, Is.LessThanOrEqualTo(ComponentLifeStage.Running)); Assert.That(comp2.LifeStage, Is.LessThanOrEqualTo(ComponentLifeStage.Running));
Assert.That(component.LifeStage, Is.EqualTo(ComponentLifeStage.Deleted)); Assert.That(component.LifeStage, Is.EqualTo(ComponentLifeStage.Deleted));
} }
@@ -172,14 +172,14 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
grid.SetTile(pos, new Tile(1)); grid.SetTile(pos, new Tile(1));
var ent1 = entMan.SpawnEntity(null, coordinates); var ent1 = entMan.SpawnEntity(null, coordinates);
Assert.False(entMan.GetComponent<TransformComponent>(ent1).Anchored); Assert.That(entMan.GetComponent<TransformComponent>(ent1).Anchored, Is.False);
Assert.That(!grid.GetAnchoredEntities(pos).Any()); Assert.That(!grid.GetAnchoredEntities(pos).Any());
entMan.DeleteEntity(ent1); entMan.DeleteEntity(ent1);
var ent2 = entMan.CreateEntityUninitialized(null, coordinates); var ent2 = entMan.CreateEntityUninitialized(null, coordinates);
entMan.AddComponent<AnchorOnInitComponent>(ent2); entMan.AddComponent<AnchorOnInitComponent>(ent2);
entMan.InitializeAndStartEntity(ent2); entMan.InitializeAndStartEntity(ent2);
Assert.True(entMan.GetComponent<TransformComponent>(ent2).Anchored); Assert.That(entMan.GetComponent<TransformComponent>(ent2).Anchored);
Assert.That(grid.GetAnchoredEntities(pos).Count(), Is.EqualTo(1)); Assert.That(grid.GetAnchoredEntities(pos).Count(), Is.EqualTo(1));
Assert.That(grid.GetAnchoredEntities(pos).Contains(ent2)); Assert.That(grid.GetAnchoredEntities(pos).Contains(ent2));
} }
@@ -84,7 +84,7 @@ namespace Robust.UnitTesting.Shared.Input.Binding
var expectedHandlers = bkfToExpectedHandlers.Value; var expectedHandlers = bkfToExpectedHandlers.Value;
HashSet<InputCmdHandler> returnedHandlers = registry.GetHandlers(bkf).ToHashSet(); HashSet<InputCmdHandler> returnedHandlers = registry.GetHandlers(bkf).ToHashSet();
CollectionAssert.AreEqual(returnedHandlers, expectedHandlers); Assert.That(expectedHandlers, Is.EqualTo(returnedHandlers).AsCollection);
} }
// type b stuff should no longer fire // type b stuff should no longer fire
@@ -96,7 +96,7 @@ namespace Robust.UnitTesting.Shared.Input.Binding
var expectedHandlers = bkfToExpectedHandlers.Value; var expectedHandlers = bkfToExpectedHandlers.Value;
expectedHandlers.RemoveAll(handler => ((TestInputCmdHandler) handler).ForType == typeof(TypeB)); expectedHandlers.RemoveAll(handler => ((TestInputCmdHandler) handler).ForType == typeof(TypeB));
HashSet<InputCmdHandler> returnedHandlers = registry.GetHandlers(bkf).ToHashSet(); HashSet<InputCmdHandler> returnedHandlers = registry.GetHandlers(bkf).ToHashSet();
CollectionAssert.AreEqual(returnedHandlers, expectedHandlers); Assert.That(expectedHandlers, Is.EqualTo(returnedHandlers).AsCollection);
} }
} }
@@ -188,7 +188,7 @@ namespace Robust.UnitTesting.Shared.Input.Binding
} }
else if (returnedHandler == aHandler2) else if (returnedHandler == aHandler2)
{ {
Assert.True(foundB1 && foundB2 && foundC1 && foundC2, "bind registry didn't respect" + Assert.That(foundB1 && foundB2 && foundC1 && foundC2, "bind registry didn't respect" +
" handler dependency order"); " handler dependency order");
} }
} }
@@ -198,7 +198,7 @@ namespace Robust.UnitTesting.Shared.Input.Binding
var returnedHandlerSet = new HashSet<InputCmdHandler>(returnedHandlers); var returnedHandlerSet = new HashSet<InputCmdHandler>(returnedHandlers);
foreach (var expectedHandler in expectedHandlers) foreach (var expectedHandler in expectedHandlers)
{ {
Assert.True(returnedHandlerSet.Contains(expectedHandler)); Assert.That(returnedHandlerSet.Contains(expectedHandler));
} }
} }
@@ -88,6 +88,7 @@ namespace Robust.UnitTesting.Shared.Maths
#endregion #endregion
/*
[Test] [Test]
public void EnvironmentVariablesWorkAvx() public void EnvironmentVariablesWorkAvx()
{ {
@@ -99,6 +100,7 @@ namespace Robust.UnitTesting.Shared.Maths
RemoteExecutor.Invoke(() => { Assert.That(NumericsHelpers.Vector256Enabled, Is.True); }, RemoteExecutor.Invoke(() => { Assert.That(NumericsHelpers.Vector256Enabled, Is.True); },
GetInvokeOptions(true)).Dispose(); GetInvokeOptions(true)).Dispose();
} }
*/
#region Multiply #region Multiply
@@ -74,7 +74,7 @@ public sealed class DisconnectTest : RobustIntegrationTest
session = sPlayerMan.Sessions.Single(); session = sPlayerMan.Sessions.Single();
Assert.That(session.Status, Is.EqualTo(SessionStatus.Connected)); Assert.That(session.Status, Is.EqualTo(SessionStatus.Connected));
Assert.That(session.UserId, Is.EqualTo(cPlayerMan!.LocalPlayer?.UserId)); Assert.That(session.UserId, Is.EqualTo(cPlayerMan!.LocalPlayer?.UserId));
Assert.NotNull(cPlayerMan.LocalPlayer); Assert.That(cPlayerMan.LocalPlayer, Is.Not.Null);
} }
void AssertDisconnected() void AssertDisconnected()
@@ -72,7 +72,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.True(dt.Add(i), $"Add {i}"); Assert.That(dt.Add(i), $"Add {i}");
} }
}); });
@@ -88,7 +88,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.True(dt.Add(i), $"Add {i}"); Assert.That(dt.Add(i), $"Add {i}");
} }
}); });
@@ -96,7 +96,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.False(dt.Add(i), $"Add Dupe {i}"); Assert.That(dt.Add(i), Is.False, $"Add Dupe {i}");
} }
}); });
} }
@@ -110,7 +110,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.False(dt.Remove(i), $"Remove {i}"); Assert.That(dt.Remove(i), Is.False, $"Remove {i}");
} }
}); });
} }
@@ -124,7 +124,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.False(dt.Update(i), $"Update {i}"); Assert.That(dt.Update(i), Is.False, $"Update {i}");
} }
}); });
} }
@@ -138,7 +138,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.True(dt.Add(i), $"Add {i}"); Assert.That(dt.Add(i), $"Add {i}");
} }
}); });
@@ -146,7 +146,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = aabbs1.Length; i < aabbs1.Length + aabbs2.Length; ++i) for (var i = aabbs1.Length; i < aabbs1.Length + aabbs2.Length; ++i)
{ {
Assert.False(dt.Remove(i), $"Remove {i}"); Assert.That(dt.Remove(i), Is.False, $"Remove {i}");
} }
}); });
} }
@@ -160,14 +160,14 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.True(dt.Add(i), $"Add {i}"); Assert.That(dt.Add(i), $"Add {i}");
} }
}); });
Assert.Multiple(() => { Assert.Multiple(() => {
for (var i = aabbs1.Length; i < aabbs1.Length + aabbs2.Length; ++i) for (var i = aabbs1.Length; i < aabbs1.Length + aabbs2.Length; ++i)
{ {
Assert.False(dt.Update(i), $"Update {i}"); Assert.That(dt.Update(i), Is.False, $"Update {i}");
} }
}); });
} }
@@ -182,7 +182,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs.Length; ++i) for (var i = 0; i < aabbs.Length; ++i)
{ {
Assert.True(dt.Add(i), $"Add {i}"); Assert.That(dt.Add(i), $"Add {i}");
} }
}); });
aabbs = aabbs2; aabbs = aabbs2;
@@ -191,7 +191,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs.Length; ++i) for (var i = 0; i < aabbs.Length; ++i)
{ {
Assert.True(dt.Remove(i), $"Remove {i}"); Assert.That(dt.Remove(i), $"Remove {i}");
} }
}); });
} }
@@ -204,7 +204,7 @@ namespace Robust.UnitTesting.Shared.Physics
{ {
for (var i = 0; i < aabbs1.Length; ++i) for (var i = 0; i < aabbs1.Length; ++i)
{ {
Assert.True(dt.Add(i), $"Add {i}"); Assert.That(dt.Add(i), $"Add {i}");
} }
}); });
@@ -60,44 +60,44 @@ namespace Robust.UnitTesting.Shared.Prototypes
var entityComponent = IoCManager.Resolve<IEntityManager>().GetComponent<HotReloadTestOneComponent>(entity); var entityComponent = IoCManager.Resolve<IEntityManager>().GetComponent<HotReloadTestOneComponent>(entity);
Assert.That(entityComponent.Value, Is.EqualTo(5)); Assert.That(entityComponent.Value, Is.EqualTo(5));
Assert.False(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity)); Assert.That(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity), Is.False);
var reloaded = false; var reloaded = false;
_prototypes.PrototypesReloaded += _ => reloaded = true; _prototypes.PrototypesReloaded += _ => reloaded = true;
_prototypes.ReloadPrototypes(new Dictionary<Type, HashSet<string>>()); _prototypes.ReloadPrototypes(new Dictionary<Type, HashSet<string>>());
Assert.True(reloaded); Assert.That(reloaded);
reloaded = false; reloaded = false;
Assert.That(entityComponent.Value, Is.EqualTo(5)); Assert.That(entityComponent.Value, Is.EqualTo(5));
Assert.False(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity)); Assert.That(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity), Is.False);
var changedPrototypes = new Dictionary<Type, HashSet<string>>(); var changedPrototypes = new Dictionary<Type, HashSet<string>>();
_prototypes.LoadString(ReloadedPrototypes, true, changedPrototypes); _prototypes.LoadString(ReloadedPrototypes, true, changedPrototypes);
_prototypes.ReloadPrototypes(changedPrototypes); _prototypes.ReloadPrototypes(changedPrototypes);
Assert.True(reloaded); Assert.That(reloaded);
reloaded = false; reloaded = false;
// Existing component values are not modified in the current implementation // Existing component values are not modified in the current implementation
Assert.That(entityComponent.Value, Is.EqualTo(5)); Assert.That(entityComponent.Value, Is.EqualTo(5));
// New components are added // New components are added
Assert.True(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity)); Assert.That(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity));
changedPrototypes = new Dictionary<Type, HashSet<string>>(); changedPrototypes = new Dictionary<Type, HashSet<string>>();
_prototypes.LoadString(InitialPrototypes, true, changedPrototypes); _prototypes.LoadString(InitialPrototypes, true, changedPrototypes);
_prototypes.ReloadPrototypes(changedPrototypes); _prototypes.ReloadPrototypes(changedPrototypes);
Assert.True(reloaded); Assert.That(reloaded);
reloaded = false; reloaded = false;
// Existing component values are not modified in the current implementation // Existing component values are not modified in the current implementation
Assert.That(entityComponent.Value, Is.EqualTo(5)); Assert.That(entityComponent.Value, Is.EqualTo(5));
// Old components are removed // Old components are removed
Assert.False(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity)); Assert.That(IoCManager.Resolve<IEntityManager>().HasComponent<HotReloadTestTwoComponent>(entity), Is.False);
} }
} }
@@ -70,7 +70,7 @@ namespace Robust.UnitTesting.Shared.Prototypes
var componentData = prototype.Components["TestBasicPrototype"].Component as TestBasicPrototypeComponent; var componentData = prototype.Components["TestBasicPrototype"].Component as TestBasicPrototypeComponent;
Assert.NotNull(componentData); Assert.That(componentData, Is.Not.Null);
Assert.That(componentData!.Str, Is.EqualTo("hi!")); Assert.That(componentData!.Str, Is.EqualTo("hi!"));
Assert.That(componentData!.int_field, Is.EqualTo(10)); Assert.That(componentData!.int_field, Is.EqualTo(10));
Assert.That(componentData!.float_field, Is.EqualTo(10f)); Assert.That(componentData!.float_field, Is.EqualTo(10f));
@@ -53,7 +53,7 @@ namespace Robust.UnitTesting.Shared.Reflection
Assert.Fail("ReflectionManager returned too many types."); Assert.Fail("ReflectionManager returned too many types.");
} }
} }
Assert.That(did1 && did2, Is.True, "IoCManager did not return both expected types. First: {0}, Second: {1}", did1, did2); Assert.That(did1 && did2, Is.True, $"IoCManager did not return both expected types. First: {did1}, Second: {did2}");
} }
public interface IReflectionManagerTest { } public interface IReflectionManagerTest { }
@@ -1,4 +1,4 @@
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Reflection; using Robust.Shared.Reflection;
@@ -24,7 +24,7 @@ namespace Robust.UnitTesting.Shared.Serialization
foreach (var type in types) foreach (var type in types)
{ {
Assert.IsTrue(Attribute.IsDefined(type, typeof(NetSerializableAttribute), true), Assert.That(Attribute.IsDefined(type, typeof(NetSerializableAttribute), true),
$"{type.FullName} has {nameof(NetSerializableAttribute)}, but not the required {nameof(SerializableAttribute)}."); $"{type.FullName} has {nameof(NetSerializableAttribute)}, but not the required {nameof(SerializableAttribute)}.");
} }
@@ -32,7 +32,7 @@ namespace Robust.UnitTesting.Shared.Serialization
serializer.DeserializeDirect<List<int>?>(stream, out var deserialized); serializer.DeserializeDirect<List<int>?>(stream, out var deserialized);
if (list == null) if (list == null)
{ {
Assert.Null(deserialized); Assert.That(deserialized, Is.Null);
} }
else else
{ {
@@ -59,7 +59,7 @@ namespace Robust.UnitTesting.Shared.Serialization
serializer.DeserializeDirect<Dictionary<string, int>?>(stream, out var deserialized); serializer.DeserializeDirect<Dictionary<string, int>?>(stream, out var deserialized);
if (list == null) if (list == null)
{ {
Assert.Null(deserialized); Assert.That(deserialized, Is.Null);
} }
else else
{ {
@@ -85,7 +85,7 @@ namespace Robust.UnitTesting.Shared.Serialization
serializer.DeserializeDirect<HashSet<int>?>(stream, out var deserialized); serializer.DeserializeDirect<HashSet<int>?>(stream, out var deserialized);
if (set == null) if (set == null)
{ {
Assert.Null(deserialized); Assert.That(deserialized, Is.Null);
} }
else else
{ {
@@ -37,13 +37,13 @@ namespace Robust.UnitTesting.Shared.Serialization
var definition = Serialization.Read<PropertyAndFieldDefinitionTestDefinition>(mapping, notNullableOverride: true); var definition = Serialization.Read<PropertyAndFieldDefinitionTestDefinition>(mapping, notNullableOverride: true);
Assert.NotNull(definition); Assert.That(definition, Is.Not.Null);
// Get only property with backing field, property targeted // Get only property with backing field, property targeted
Assert.That(definition!.GetOnlyProperty, Is.EqualTo(5)); Assert.That(definition!.GetOnlyProperty, Is.EqualTo(5));
var backingField = definition.GetType().GetBackingField(GetOnlyPropertyName); var backingField = definition.GetType().GetBackingField(GetOnlyPropertyName);
Assert.NotNull(backingField); Assert.That(backingField, Is.Not.Null);
var backingFieldValue = backingField!.GetValue(definition); var backingFieldValue = backingField!.GetValue(definition);
Assert.That(backingFieldValue, Is.EqualTo(5)); Assert.That(backingFieldValue, Is.EqualTo(5));
@@ -61,21 +61,21 @@ namespace Robust.UnitTesting.Shared.Serialization
Assert.That(definition.GetOnlyPropertyWithOtherAttributeFieldTargeted, Is.EqualTo(25)); Assert.That(definition.GetOnlyPropertyWithOtherAttributeFieldTargeted, Is.EqualTo(25));
var property = definition.GetType().GetProperty(GetOnlyPropertyWithOtherAttributeFieldTargetedName); var property = definition.GetType().GetProperty(GetOnlyPropertyWithOtherAttributeFieldTargetedName);
Assert.NotNull(property); Assert.That(property, Is.Not.Null);
var propertyInfo = new SpecificPropertyInfo(property!); var propertyInfo = new SpecificPropertyInfo(property!);
Assert.NotNull(propertyInfo.GetAttribute<DataFieldAttribute>()); Assert.That(propertyInfo.GetAttribute<DataFieldAttribute>(), Is.Not.Null);
Assert.NotNull(propertyInfo.GetAttribute<AlwaysPushInheritanceAttribute>()); Assert.That(propertyInfo.GetAttribute<AlwaysPushInheritanceAttribute>(), Is.Not.Null);
// We check for the property info properly finding field targeted attributes as // We check for the property info properly finding field targeted attributes as
// well, otherwise we run the risk of the data field being targeted to the // well, otherwise we run the risk of the data field being targeted to the
// property but an additional attribute like AlwaysPushInheritance being targeted // property but an additional attribute like AlwaysPushInheritance being targeted
// to the field, as was the case in EntityPrototype. // to the field, as was the case in EntityPrototype.
// And I don't want to debug that ever again. // And I don't want to debug that ever again.
Assert.NotNull(propertyInfo.DeclaringType); Assert.That(propertyInfo.DeclaringType, Is.Not.Null);
var dataDefinition = ((SerializationManager) Serialization).GetDefinition(propertyInfo.DeclaringType!); var dataDefinition = ((SerializationManager) Serialization).GetDefinition(propertyInfo.DeclaringType!);
Assert.NotNull(dataDefinition); Assert.That(dataDefinition, Is.Not.Null);
var alwaysPushDataField = propertyInfo.GetAttribute<DataFieldAttribute>(); var alwaysPushDataField = propertyInfo.GetAttribute<DataFieldAttribute>();
var propertyDefinition = var propertyDefinition =
@@ -87,26 +87,26 @@ namespace Robust.UnitTesting.Shared.Serialization
Assert.That(definition.GetOnlyPropertyFieldTargetedAndOtherAttribute, Is.EqualTo(30)); Assert.That(definition.GetOnlyPropertyFieldTargetedAndOtherAttribute, Is.EqualTo(30));
property = definition.GetType().GetProperty(GetOnlyPropertyFieldTargetedAndOtherAttributeName); property = definition.GetType().GetProperty(GetOnlyPropertyFieldTargetedAndOtherAttributeName);
Assert.NotNull(property); Assert.That(property, Is.Not.Null);
propertyInfo = new SpecificPropertyInfo(property!); propertyInfo = new SpecificPropertyInfo(property!);
// Data field is targeted to the backing field // Data field is targeted to the backing field
Assert.NotNull(propertyInfo.GetAttribute<DataFieldAttribute>()); Assert.That(propertyInfo.GetAttribute<DataFieldAttribute>(), Is.Not.Null);
Assert.Null(propertyInfo.GetBackingField()!.GetAttribute<DataFieldAttribute>()); Assert.That(propertyInfo.GetBackingField()!.GetAttribute<DataFieldAttribute>(), Is.Null);
Assert.NotNull(propertyInfo.GetAttribute<DataFieldAttribute>(true)); Assert.That(propertyInfo.GetAttribute<DataFieldAttribute>(true), Is.Not.Null);
// NeverPushInheritanceAttribute is targeted to the property // NeverPushInheritanceAttribute is targeted to the property
Assert.NotNull(propertyInfo.GetAttribute<NeverPushInheritanceAttribute>()); Assert.That(propertyInfo.GetAttribute<NeverPushInheritanceAttribute>(), Is.Not.Null);
Assert.Null(propertyInfo.GetBackingField()!.GetAttribute<NeverPushInheritanceAttribute>()); Assert.That(propertyInfo.GetBackingField()!.GetAttribute<NeverPushInheritanceAttribute>(), Is.Null);
Assert.NotNull(propertyInfo.GetAttribute<NeverPushInheritanceAttribute>(true)); Assert.That(propertyInfo.GetAttribute<NeverPushInheritanceAttribute>(true), Is.Not.Null);
var neverPushDataField = propertyInfo.GetAttribute<DataFieldAttribute>(); var neverPushDataField = propertyInfo.GetAttribute<DataFieldAttribute>();
propertyDefinition = propertyDefinition =
dataDefinition!.BaseFieldDefinitions.Single(e => e.Attribute.Equals(neverPushDataField)); dataDefinition!.BaseFieldDefinitions.Single(e => e.Attribute.Equals(neverPushDataField));
inheritanceBehaviour = propertyDefinition.InheritanceBehavior; inheritanceBehaviour = propertyDefinition.InheritanceBehavior;
dataDefinition = ((SerializationManager) Serialization).GetDefinition(property!.DeclaringType!); dataDefinition = ((SerializationManager) Serialization).GetDefinition(property!.DeclaringType!);
Assert.NotNull(dataDefinition); Assert.That(dataDefinition, Is.Not.Null);
Assert.That(inheritanceBehaviour, Is.EqualTo(InheritanceBehavior.Never)); Assert.That(inheritanceBehaviour, Is.EqualTo(InheritanceBehavior.Never));
} }
@@ -148,7 +148,7 @@ public sealed partial class DataDefinitionTests : SerializationTest
{ {
var mapping = new MappingDataNode{ { fieldName, ValueDataNode.Null() } }; var mapping = new MappingDataNode{ { fieldName, ValueDataNode.Null() } };
var res = Serialization.Read<DataDefTestDummy>(mapping, notNullableOverride: true); var res = Serialization.Read<DataDefTestDummy>(mapping, notNullableOverride: true);
Assert.Null(GetValue(res, fieldName)); Assert.That(GetValue(res, fieldName), Is.Null);
} }
[TestCaseSource(nameof(AllFieldsData))] [TestCaseSource(nameof(AllFieldsData))]
@@ -209,8 +209,8 @@ public sealed partial class DataDefinitionTests : SerializationTest
var target = new DataDefTestDummy(); var target = new DataDefTestDummy();
SetValue(target, fieldName, null); SetValue(target, fieldName, null);
Serialization.CopyTo(source, ref target, notNullableOverride: true); Serialization.CopyTo(source, ref target, notNullableOverride: true);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.Null(GetValue(target!, fieldName)); Assert.That(GetValue(target!, fieldName), Is.Null);
} }
[TestCaseSource(nameof(NullableFieldsData))] [TestCaseSource(nameof(NullableFieldsData))]
@@ -221,8 +221,8 @@ public sealed partial class DataDefinitionTests : SerializationTest
var target = new DataDefTestDummy(); var target = new DataDefTestDummy();
SetValue(target, fieldName, altValue()); SetValue(target, fieldName, altValue());
Serialization.CopyTo(source, ref target, notNullableOverride: true); Serialization.CopyTo(source, ref target, notNullableOverride: true);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.Null(GetValue(target!, fieldName)); Assert.That(GetValue(target!, fieldName), Is.Null);
} }
[TestCaseSource(nameof(NullableFieldsData))] [TestCaseSource(nameof(NullableFieldsData))]
@@ -233,7 +233,7 @@ public sealed partial class DataDefinitionTests : SerializationTest
var target = new DataDefTestDummy(); var target = new DataDefTestDummy();
SetValue(target, fieldName, null); SetValue(target, fieldName, null);
Serialization.CopyTo(source, ref target, notNullableOverride: true); Serialization.CopyTo(source, ref target, notNullableOverride: true);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.That(GetValue(target!, fieldName), Is.EqualTo(value())); Assert.That(GetValue(target!, fieldName), Is.EqualTo(value()));
} }
@@ -245,7 +245,7 @@ public sealed partial class DataDefinitionTests : SerializationTest
var target = new DataDefTestDummy(); var target = new DataDefTestDummy();
SetValue(target, fieldName, altValue()); SetValue(target, fieldName, altValue());
Serialization.CopyTo(source, ref target, notNullableOverride: true); Serialization.CopyTo(source, ref target, notNullableOverride: true);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.That(GetValue(target!, fieldName), Is.EqualTo(value())); Assert.That(GetValue(target!, fieldName), Is.EqualTo(value()));
} }
@@ -283,7 +283,7 @@ public sealed partial class DataDefinitionTests : SerializationTest
var target = new DataDefTestDummy(); var target = new DataDefTestDummy();
SetValue(target, fieldName, null); SetValue(target, fieldName, null);
Serialization.CopyTo(source, ref target, notNullableOverride: true); Serialization.CopyTo(source, ref target, notNullableOverride: true);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.That(GetValue(target!, fieldName), Is.EqualTo(value())); Assert.That(GetValue(target!, fieldName), Is.EqualTo(value()));
} }
@@ -295,7 +295,7 @@ public sealed partial class DataDefinitionTests : SerializationTest
var target = new DataDefTestDummy(); var target = new DataDefTestDummy();
SetValue(target, fieldName, altValue()); SetValue(target, fieldName, altValue());
Serialization.CopyTo(source, ref target, notNullableOverride: true); Serialization.CopyTo(source, ref target, notNullableOverride: true);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.That(GetValue(target!, fieldName), Is.EqualTo(value())); Assert.That(GetValue(target!, fieldName), Is.EqualTo(value()));
} }
} }
@@ -321,21 +321,21 @@ public sealed partial class ManagerTests : SerializationTest
public void Read_NT_NV_Struct<T>(DataNode _, Func<T> __, Func<T> ___, bool useContext, object[] ____) where T : struct public void Read_NT_NV_Struct<T>(DataNode _, Func<T> __, Func<T> ___, bool useContext, object[] ____) where T : struct
{ {
var val = Serialization.Read<T?>(ValueDataNode.Null(), context: Context(useContext)); var val = Serialization.Read<T?>(ValueDataNode.Null(), context: Context(useContext));
Assert.Null(val); Assert.That(val, Is.Null);
} }
[TestCaseSource(nameof(ReadWriteTypesClass))] [TestCaseSource(nameof(ReadWriteTypesClass))]
public void Read_NT_NV_Class<T>(DataNode _, Func<T> __, Func<T> ___, bool useContext, object[] ____) where T : class public void Read_NT_NV_Class<T>(DataNode _, Func<T> __, Func<T> ___, bool useContext, object[] ____) where T : class
{ {
var val = Serialization.Read<T?>(ValueDataNode.Null(), context: Context(useContext)); var val = Serialization.Read<T?>(ValueDataNode.Null(), context: Context(useContext));
Assert.Null(val); Assert.That(val, Is.Null);
} }
[TestCaseSource(nameof(ReadWriteTypesStruct))] [TestCaseSource(nameof(ReadWriteTypesStruct))]
public void Read_NT_RV_Struct<T>(DataNode node, Func<T> value, Func<T> _, bool useContext, object[] valueExtractors) where T : struct public void Read_NT_RV_Struct<T>(DataNode node, Func<T> value, Func<T> _, bool useContext, object[] valueExtractors) where T : struct
{ {
var val = Serialization.Read<T?>(node, context: Context(useContext)); var val = Serialization.Read<T?>(node, context: Context(useContext));
Assert.NotNull(val); Assert.That(val, Is.Not.Null);
AssertEqual(val!.Value, value(), valueExtractors); AssertEqual(val!.Value, value(), valueExtractors);
} }
@@ -343,7 +343,7 @@ public sealed partial class ManagerTests : SerializationTest
public void Read_NT_RV_Class<T>(DataNode node, Func<T> value, Func<T> _, bool useContext, object[] valueExtractors) where T : class public void Read_NT_RV_Class<T>(DataNode node, Func<T> value, Func<T> _, bool useContext, object[] valueExtractors) where T : class
{ {
var val = Serialization.Read<T?>(node, context: Context(useContext)); var val = Serialization.Read<T?>(node, context: Context(useContext));
Assert.NotNull(val); Assert.That(val, Is.Not.Null);
AssertEqual(val!, value(), valueExtractors); AssertEqual(val!, value(), valueExtractors);
} }
@@ -371,7 +371,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = null; T? target = null;
Serialization.CopyTo<T?>(null, ref target, context: Context(useContext)); Serialization.CopyTo<T?>(null, ref target, context: Context(useContext));
Assert.Null(target); Assert.That(target, Is.Null);
} }
[TestCaseSource(nameof(TestableTypesClass))] [TestCaseSource(nameof(TestableTypesClass))]
@@ -380,7 +380,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = null; T? target = null;
Serialization.CopyTo<T?>(null, ref target, context: Context(useContext)); Serialization.CopyTo<T?>(null, ref target, context: Context(useContext));
Assert.Null(target); Assert.That(target, Is.Null);
} }
[TestCaseSource(nameof(TestableTypesStruct))] [TestCaseSource(nameof(TestableTypesStruct))]
@@ -389,7 +389,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = value(); T? target = value();
Serialization.CopyTo<T?>(null, ref target, context: Context(useContext)); Serialization.CopyTo<T?>(null, ref target, context: Context(useContext));
Assert.Null(target); Assert.That(target, Is.Null);
} }
[TestCaseSource(nameof(TestableTypesClass))] [TestCaseSource(nameof(TestableTypesClass))]
@@ -398,7 +398,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = value(); T? target = value();
Serialization.CopyTo<T?>(null, ref target, context: Context(useContext)); Serialization.CopyTo<T?>(null, ref target, context: Context(useContext));
Assert.Null(target); Assert.That(target, Is.Null);
} }
[TestCaseSource(nameof(TestableTypesStruct))] [TestCaseSource(nameof(TestableTypesStruct))]
@@ -407,7 +407,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = null; T? target = null;
Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext)); Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext));
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
AssertEqual(target!.Value, value(), valueExtractors); AssertEqual(target!.Value, value(), valueExtractors);
} }
@@ -417,7 +417,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = null; T? target = null;
Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext)); Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext));
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
AssertEqual(target!, value(), valueExtractors); AssertEqual(target!, value(), valueExtractors);
} }
@@ -427,7 +427,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = altValue(); T? target = altValue();
Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext)); Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext));
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
AssertEqual(target!.Value, value(), valueExtractors); AssertEqual(target!.Value, value(), valueExtractors);
} }
@@ -437,7 +437,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T? target = altValue(); T? target = altValue();
Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext)); Serialization.CopyTo<T?>(value(), ref target, context: Context(useContext));
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
AssertEqual(target!, value(), valueExtractors); AssertEqual(target!, value(), valueExtractors);
} }
@@ -466,7 +466,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
T target = null!; T target = null!;
Serialization.CopyTo(value(), ref target, context: Context(useContext)); Serialization.CopyTo(value(), ref target, context: Context(useContext));
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
AssertEqual(target!, value(), valueExtractors); AssertEqual(target!, value(), valueExtractors);
} }
@@ -488,7 +488,7 @@ public sealed partial class ManagerTests : SerializationTest
object[] valueExtractors) where T : struct object[] valueExtractors) where T : struct
{ {
var copy = Serialization.CreateCopy<T?>(null, context: Context(useContext)); var copy = Serialization.CreateCopy<T?>(null, context: Context(useContext));
Assert.Null(copy); Assert.That(copy, Is.Null);
} }
[TestCaseSource(nameof(TestableTypesClass))] [TestCaseSource(nameof(TestableTypesClass))]
@@ -496,7 +496,7 @@ public sealed partial class ManagerTests : SerializationTest
object[] valueExtractors) where T : class object[] valueExtractors) where T : class
{ {
var copy = Serialization.CreateCopy<T?>(null, context: Context(useContext)); var copy = Serialization.CreateCopy<T?>(null, context: Context(useContext));
Assert.Null(copy); Assert.That(copy, Is.Null);
} }
[TestCaseSource(nameof(TestableTypesAll))] [TestCaseSource(nameof(TestableTypesAll))]
@@ -504,7 +504,7 @@ public sealed partial class ManagerTests : SerializationTest
object[] valueExtractors) object[] valueExtractors)
{ {
var copy = Serialization.CreateCopy<T?>(value(), context: Context(useContext)); var copy = Serialization.CreateCopy<T?>(value(), context: Context(useContext));
Assert.NotNull(copy); Assert.That(copy, Is.Not.Null);
AssertEqual(copy!, value(), valueExtractors); AssertEqual(copy!, value(), valueExtractors);
} }
@@ -536,7 +536,7 @@ public sealed partial class ManagerTests : SerializationTest
CopyByRefTestClass target = null!; CopyByRefTestClass target = null!;
var source = new CopyByRefTestClass(); var source = new CopyByRefTestClass();
Serialization.CopyTo(source, ref target, notNullableOverride: true); Serialization.CopyTo(source, ref target, notNullableOverride: true);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.That(target!, Is.SameAs(source)); Assert.That(target!, Is.SameAs(source));
} }
@@ -545,7 +545,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
CopyByRefTestClass? target = null; CopyByRefTestClass? target = null;
Serialization.CopyTo(null, ref target); Serialization.CopyTo(null, ref target);
Assert.Null(target); Assert.That(target, Is.Null);
} }
[Test] [Test]
@@ -560,7 +560,7 @@ public sealed partial class ManagerTests : SerializationTest
public void CreateCopy_CopyByRef_NV_Class() public void CreateCopy_CopyByRef_NV_Class()
{ {
var copy = Serialization.CreateCopy<CopyByRefTestClass?>(null); var copy = Serialization.CreateCopy<CopyByRefTestClass?>(null);
Assert.Null(copy); Assert.That(copy, Is.Null);
} }
[Test] [Test]
@@ -569,7 +569,7 @@ public sealed partial class ManagerTests : SerializationTest
CopyByRefTestStruct? target = null; CopyByRefTestStruct? target = null;
var source = new CopyByRefTestStruct{ID = 5}; var source = new CopyByRefTestStruct{ID = 5};
Serialization.CopyTo(source, ref target); Serialization.CopyTo(source, ref target);
Assert.NotNull(target); Assert.That(target, Is.Not.Null);
Assert.That(target!.Value.ID, Is.EqualTo(source.ID)); Assert.That(target!.Value.ID, Is.EqualTo(source.ID));
} }
@@ -578,7 +578,7 @@ public sealed partial class ManagerTests : SerializationTest
{ {
CopyByRefTestStruct? target = null; CopyByRefTestStruct? target = null;
Serialization.CopyTo(null, ref target); Serialization.CopyTo(null, ref target);
Assert.Null(target); Assert.That(target, Is.Null);
} }
[Test] [Test]
@@ -593,7 +593,7 @@ public sealed partial class ManagerTests : SerializationTest
public void CreateCopy_CopyByRef_NV_Struct() public void CreateCopy_CopyByRef_NV_Struct()
{ {
var copy = Serialization.CreateCopy<CopyByRefTestStruct?>(null); var copy = Serialization.CreateCopy<CopyByRefTestStruct?>(null);
Assert.Null(copy); Assert.That(copy, Is.Null);
} }
#endregion #endregion
@@ -30,7 +30,7 @@ namespace Robust.UnitTesting.Shared.Serialization.TypeSerializers
var node = Serialization.WriteValueAs<SequenceDataNode>(registry); var node = Serialization.WriteValueAs<SequenceDataNode>(registry);
Assert.That(node.Sequence.Count, Is.EqualTo(1)); Assert.That(node.Sequence.Count, Is.EqualTo(1));
Assert.IsInstanceOf<MappingDataNode>(node[0]); Assert.That(node[0], Is.InstanceOf<MappingDataNode>());
var mapping = node.Cast<MappingDataNode>(0); var mapping = node.Cast<MappingDataNode>(0);
Assert.That(mapping.Cast<ValueDataNode>("type").Value, Is.EqualTo("Test")); Assert.That(mapping.Cast<ValueDataNode>("type").Value, Is.EqualTo("Test"));
@@ -49,7 +49,7 @@ namespace Robust.UnitTesting.Shared.Serialization.TypeSerializers
Assert.That(deserializedRegistry.Count, Is.EqualTo(1)); Assert.That(deserializedRegistry.Count, Is.EqualTo(1));
Assert.That(deserializedRegistry.ContainsKey("Test")); Assert.That(deserializedRegistry.ContainsKey("Test"));
Assert.IsInstanceOf<TestComponent>(deserializedRegistry["Test"].Component); Assert.That(deserializedRegistry["Test"].Component, Is.InstanceOf<TestComponent>());
} }
} }
@@ -46,7 +46,7 @@ SealedTestTypeB:
MappingDataNode, MappingDataNode,
AbstractDictionarySerializer<AbstractTestData>> AbstractDictionarySerializer<AbstractTestData>>
(node, notNullableOverride:true); (node, notNullableOverride:true);
Assert.NotNull(data); Assert.That(data, Is.Not.Null);
Assert.That(data.Count, Is.EqualTo(2)); Assert.That(data.Count, Is.EqualTo(2));
Assert.That(data.ContainsKey(typeof(SealedTestTypeA))); Assert.That(data.ContainsKey(typeof(SealedTestTypeA)));
Assert.That(data.ContainsKey(typeof(SealedTestTypeB))); Assert.That(data.ContainsKey(typeof(SealedTestTypeB)));
@@ -54,8 +54,8 @@ SealedTestTypeB:
var a = data[typeof(SealedTestTypeA)] as SealedTestTypeA; var a = data[typeof(SealedTestTypeA)] as SealedTestTypeA;
var b = data[typeof(SealedTestTypeB)] as SealedTestTypeB; var b = data[typeof(SealedTestTypeB)] as SealedTestTypeB;
Assert.NotNull(a); Assert.That(a, Is.Not.Null);
Assert.NotNull(b); Assert.That(b, Is.Not.Null);
Assert.That(a!.X, Is.EqualTo(1)); Assert.That(a!.X, Is.EqualTo(1));
Assert.That(a.Y, Is.EqualTo(2)); Assert.That(a.Y, Is.EqualTo(2));
@@ -66,7 +66,7 @@ SealedTestTypeB:
AbstractDictionarySerializer<AbstractTestData>> AbstractDictionarySerializer<AbstractTestData>>
(data, notNullableOverride:true); (data, notNullableOverride:true);
Assert.Null(node.Except(newNode)); Assert.That(node.Except(newNode), Is.Null);
validation = seri.ValidateNode<Dictionary<Type, AbstractTestData>, validation = seri.ValidateNode<Dictionary<Type, AbstractTestData>,
MappingDataNode, MappingDataNode,
AbstractDictionarySerializer<AbstractTestData>> AbstractDictionarySerializer<AbstractTestData>>
@@ -90,7 +90,7 @@ entitiesImmutableList:
var node = stream.Documents[0].RootNode.ToDataNode(); var node = stream.Documents[0].RootNode.ToDataNode();
var definition = Serialization.Read<PrototypeIdListSerializerTestDataDefinition>(node, notNullableOverride: true); var definition = Serialization.Read<PrototypeIdListSerializerTestDataDefinition>(node, notNullableOverride: true);
Assert.NotNull(definition); Assert.That(definition, Is.Not.Null);
Assert.That(definition!.EntitiesList.Count, Is.EqualTo(1)); Assert.That(definition!.EntitiesList.Count, Is.EqualTo(1));
Assert.That(definition.EntitiesList[0], Is.EqualTo(TestEntityId)); Assert.That(definition.EntitiesList[0], Is.EqualTo(TestEntityId));
@@ -111,16 +111,16 @@ entitiesImmutableList:
var validSequence = new SequenceDataNode(TestEntityId); var validSequence = new SequenceDataNode(TestEntityId);
var validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence); var validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence);
Assert.True(validations.Valid); Assert.That(validations.Valid);
validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence); validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence);
Assert.True(validations.Valid); Assert.That(validations.Valid);
validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence); validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence);
Assert.True(validations.Valid); Assert.That(validations.Valid);
validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence); validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(validSequence);
Assert.True(validations.Valid); Assert.That(validations.Valid);
} }
[Test] [Test]
@@ -129,16 +129,16 @@ entitiesImmutableList:
var invalidSequence = new SequenceDataNode(TestInvalidEntityId); var invalidSequence = new SequenceDataNode(TestInvalidEntityId);
var validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence); var validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence);
Assert.False(validations.Valid); Assert.That(validations.Valid, Is.False);
validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence); validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence);
Assert.False(validations.Valid); Assert.That(validations.Valid, Is.False);
validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence); validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence);
Assert.False(validations.Valid); Assert.That(validations.Valid, Is.False);
validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence); validations = Serialization.ValidateNode<List<string>, SequenceDataNode, PrototypeIdListSerializer<EntityPrototype>>(invalidSequence);
Assert.False(validations.Valid); Assert.That(validations.Valid, Is.False);
} }
} }
@@ -1,4 +1,4 @@
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.Serialization.Markdown.Value; using Robust.Shared.Serialization.Markdown.Value;
// ReSharper disable AccessToStaticMemberViaDerivedType // ReSharper disable AccessToStaticMemberViaDerivedType
@@ -13,7 +13,6 @@ namespace Robust.UnitTesting.Shared.Serialization.TypeSerializers
{ {
var value = Serialization.Read<int>(new ValueDataNode("5")); var value = Serialization.Read<int>(new ValueDataNode("5"));
Assert.NotNull(value);
Assert.That(value, Is.EqualTo(5)); Assert.That(value, Is.EqualTo(5));
} }
@@ -22,7 +21,7 @@ namespace Robust.UnitTesting.Shared.Serialization.TypeSerializers
{ {
var nullValue = Serialization.Read<int?>(ValueDataNode.Null()); var nullValue = Serialization.Read<int?>(ValueDataNode.Null());
Assert.Null(nullValue); Assert.That(nullValue, Is.Null);
var value = Serialization.Read<int?>(new ValueDataNode("5")); var value = Serialization.Read<int?>(new ValueDataNode("5"));
@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown.Sequence; using Robust.Shared.Serialization.Markdown.Sequence;
@@ -41,8 +41,8 @@ namespace Robust.UnitTesting.Shared.Serialization.TypeSerializers
var result = Serialization.Read<List<string>, SequenceDataNode, ListSerializers<string>>(node, notNullableOverride: true); var result = Serialization.Read<List<string>, SequenceDataNode, ListSerializers<string>>(node, notNullableOverride: true);
var list = (List<string>?) result; var list = (List<string>?) result;
Assert.NotNull(list); Assert.That(list, Is.Not.Null);
Assert.IsNotEmpty(list!); Assert.That(list!, Is.Not.Empty);
Assert.That(list, Has.Count.EqualTo(2)); Assert.That(list, Has.Count.EqualTo(2));
Assert.That(list, Does.Contain("A")); Assert.That(list, Does.Contain("A"));
Assert.That(list, Does.Contain("E")); Assert.That(list, Does.Contain("E"));
@@ -66,15 +66,15 @@ namespace Robust.UnitTesting.Shared.Serialization.TypeSerializers
var source = new List<string> {"A", "E"}; var source = new List<string> {"A", "E"};
var target = new List<string>(); var target = new List<string>();
Assert.IsNotEmpty(source); Assert.That(source, Is.Not.Empty);
Assert.IsEmpty(target); Assert.That(target, Is.Empty);
Serialization.CopyTo<List<string>, ListSerializers<string>>(source, ref target, notNullableOverride: true); Serialization.CopyTo<List<string>, ListSerializers<string>>(source, ref target, notNullableOverride: true);
Assert.NotNull(source); Assert.That(source, Is.Not.Null);
Assert.IsNotEmpty(source); Assert.That(source, Is.Not.Empty);
Assert.IsNotEmpty(target!); Assert.That(target!, Is.Not.Empty);
Assert.That(source, Is.EqualTo(target)); Assert.That(source, Is.EqualTo(target));
@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
@@ -45,7 +45,7 @@ public sealed partial class VirtualObjectArrayTest : SerializationTest
// Check that the yaml doesn't differ in any way. // Check that the yaml doesn't differ in any way.
var diff = newSquence.Except(sequence); var diff = newSquence.Except(sequence);
Assert.IsNull(diff); Assert.That(diff, Is.Null);
// And finally, double check that the serialized data can be re-deserialized (dataNode.Except isn't perfect). // And finally, double check that the serialized data can be re-deserialized (dataNode.Except isn't perfect).
arr = Serialization.Read<BaseTestDataDef[]>(newSquence, notNullableOverride: true); arr = Serialization.Read<BaseTestDataDef[]>(newSquence, notNullableOverride: true);
@@ -64,7 +64,7 @@ public sealed partial class VirtualObjectArrayTest : SerializationTest
var newSquence = Serialization.WriteValue(list, notNullableOverride: true); var newSquence = Serialization.WriteValue(list, notNullableOverride: true);
var diff = newSquence.Except(sequence); var diff = newSquence.Except(sequence);
Assert.IsNull(diff); Assert.That(diff, Is.Null);
list = Serialization.Read<List<BaseTestDataDef>>(sequence, notNullableOverride: true); list = Serialization.Read<List<BaseTestDataDef>>(sequence, notNullableOverride: true);
Assert.That(list[0], Is.TypeOf(typeof(SealedTestDataDef))); Assert.That(list[0], Is.TypeOf(typeof(SealedTestDataDef)));
@@ -90,10 +90,10 @@ public sealed partial class VirtualObjectArrayTest : SerializationTest
// The old sequence will now differ as it should not write the redundant !type tag // The old sequence will now differ as it should not write the redundant !type tag
var newSquence = Serialization.WriteValue(virtArr, notNullableOverride: true); var newSquence = Serialization.WriteValue(virtArr, notNullableOverride: true);
var diff = newSquence.Except(sequence); var diff = newSquence.Except(sequence);
Assert.NotNull(diff); Assert.That(diff, Is.Not.Null);
diff = newSquence.Except(expectedSequence); diff = newSquence.Except(expectedSequence);
Assert.IsNull(diff); Assert.That(diff, Is.Null);
virtArr = Serialization.Read<VirtualTestDataDef[]>(newSquence, notNullableOverride: true); virtArr = Serialization.Read<VirtualTestDataDef[]>(newSquence, notNullableOverride: true);
Assert.That(virtArr[0], Is.TypeOf(typeof(VirtualTestDataDef))); Assert.That(virtArr[0], Is.TypeOf(typeof(VirtualTestDataDef)));
@@ -108,10 +108,10 @@ public sealed partial class VirtualObjectArrayTest : SerializationTest
var newSquence = Serialization.WriteValue(virtList, notNullableOverride: true); var newSquence = Serialization.WriteValue(virtList, notNullableOverride: true);
var diff = newSquence.Except(sequence); var diff = newSquence.Except(sequence);
Assert.NotNull(diff); Assert.That(diff, Is.Not.Null);
diff = newSquence.Except(expectedSequence); diff = newSquence.Except(expectedSequence);
Assert.IsNull(diff); Assert.That(diff, Is.Null);
virtList = Serialization.Read<List<VirtualTestDataDef>>(newSquence, notNullableOverride: true); virtList = Serialization.Read<List<VirtualTestDataDef>>(newSquence, notNullableOverride: true);
Assert.That(virtList[0], Is.TypeOf(typeof(VirtualTestDataDef))); Assert.That(virtList[0], Is.TypeOf(typeof(VirtualTestDataDef)));
@@ -7,6 +7,7 @@ using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Sequence; using Robust.Shared.Serialization.Markdown.Sequence;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using YamlDotNet.Core;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
// ReSharper disable AccessToStaticMemberViaDerivedType // ReSharper disable AccessToStaticMemberViaDerivedType
@@ -65,13 +66,12 @@ namespace Robust.UnitTesting.Shared.Serialization.YamlObjectSerializerTests
{ {
var document = new YamlDocument(root.ToYamlNode()); var document = new YamlDocument(root.ToYamlNode());
using var stream = new MemoryStream(); using var writer = new StringWriter();
using var writer = new StreamWriter(stream) {NewLine = "\n"};
var yamlStream = new YamlStream(document); var yamlStream = new YamlStream(document);
yamlStream.Save(writer); yamlStream.Save(new Emitter(writer, new EmitterSettings().WithNewLine("\n")), true);
writer.Flush(); writer.Flush();
return EncodingHelpers.UTF8.GetString(stream.ToArray()); return writer.ToString();
} }
// deserializes yaml text, loads the first document, and returns the first entity // deserializes yaml text, loads the first document, and returns the first entity
@@ -34,13 +34,13 @@ namespace Robust.UnitTesting.Shared.Serialization.YamlObjectSerializerTests
var serMan = IoCManager.Resolve<ISerializationManager>(); var serMan = IoCManager.Resolve<ISerializationManager>();
var mapping = (MappingDataNode) serMan.WriteValue(type, notNullableOverride: true); var mapping = (MappingDataNode) serMan.WriteValue(type, notNullableOverride: true);
Assert.IsNotEmpty(mapping.Children); Assert.That(mapping.Children, Is.Not.Empty);
var testPropertyOne = mapping.Get("testPropertyOne") as ValueDataNode; var testPropertyOne = mapping.Get("testPropertyOne") as ValueDataNode;
var testPropertyTwo = mapping.Get("testPropertyTwo") as ValueDataNode; var testPropertyTwo = mapping.Get("testPropertyTwo") as ValueDataNode;
Assert.NotNull(testPropertyOne); Assert.That(testPropertyOne, Is.Not.Null);
Assert.NotNull(testPropertyTwo); Assert.That(testPropertyTwo, Is.Not.Null);
Assert.That(testPropertyOne!.Value, Is.EqualTo("B")); Assert.That(testPropertyOne!.Value, Is.EqualTo("B"));
Assert.That(testPropertyTwo!.Value, Is.EqualTo("10")); Assert.That(testPropertyTwo!.Value, Is.EqualTo("10"));
} }
@@ -71,8 +71,8 @@ namespace Robust.UnitTesting.Shared.Serialization.YamlObjectSerializerTests
var serMan = IoCManager.Resolve<ISerializationManager>(); var serMan = IoCManager.Resolve<ISerializationManager>();
var type = serMan.Read<ITestType>(mapping["test"].ToDataNode(), notNullableOverride: true); var type = serMan.Read<ITestType>(mapping["test"].ToDataNode(), notNullableOverride: true);
Assert.NotNull(type); Assert.That(type, Is.Not.Null);
Assert.IsInstanceOf<TestTypeTwo>(type); Assert.That(type, Is.InstanceOf<TestTypeTwo>());
var testTypeTwo = (TestTypeTwo) type!; var testTypeTwo = (TestTypeTwo) type!;
@@ -1,4 +1,4 @@
using System.IO; using System.IO;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -27,7 +27,7 @@ namespace Robust.UnitTesting.Shared.Serialization.YamlObjectSerializerTests
var serMan = IoCManager.Resolve<ISerializationManager>(); var serMan = IoCManager.Resolve<ISerializationManager>();
var mapping = serMan.WriteValue(type, notNullableOverride: true); var mapping = serMan.WriteValue(type, notNullableOverride: true);
Assert.IsInstanceOf<MappingDataNode>(mapping); Assert.That(mapping, Is.InstanceOf<MappingDataNode>());
var scalar = (MappingDataNode) mapping; var scalar = (MappingDataNode) mapping;
@@ -58,8 +58,8 @@ test:
var serMan = IoCManager.Resolve<ISerializationManager>(); var serMan = IoCManager.Resolve<ISerializationManager>();
var type = serMan.Read<ITestType>(new MappingDataNode(mapping)["test"], notNullableOverride: true); var type = serMan.Read<ITestType>(new MappingDataNode(mapping)["test"], notNullableOverride: true);
Assert.NotNull(type); Assert.That(type, Is.Not.Null);
Assert.IsInstanceOf<TestTypeOne>(type); Assert.That(type, Is.InstanceOf<TestTypeOne>());
} }
} }
@@ -112,8 +112,8 @@ public sealed class SpawnInContainerOrDropTest : EntitySpawnHelpersTest
var xform = EntMan.GetComponent<TransformComponent>(uid); var xform = EntMan.GetComponent<TransformComponent>(uid);
Assert.That(xform.ParentUid, Is.EqualTo(EntityUid.Invalid)); Assert.That(xform.ParentUid, Is.EqualTo(EntityUid.Invalid));
Assert.That(xform.MapID, Is.EqualTo(MapId.Nullspace)); Assert.That(xform.MapID, Is.EqualTo(MapId.Nullspace));
Assert.Null(xform.MapUid); Assert.That(xform.MapUid, Is.Null);
Assert.Null(xform.GridUid); Assert.That(xform.GridUid, Is.Null);
}); });
await Server.WaitPost(() =>MapMan.DeleteMap(MapId)); await Server.WaitPost(() =>MapMan.DeleteMap(MapId));
@@ -103,8 +103,8 @@ public sealed class SpawnNextToOrDropTest : EntitySpawnHelpersTest
var xform = EntMan.GetComponent<TransformComponent>(uid); var xform = EntMan.GetComponent<TransformComponent>(uid);
Assert.That(xform.ParentUid, Is.EqualTo(EntityUid.Invalid)); Assert.That(xform.ParentUid, Is.EqualTo(EntityUid.Invalid));
Assert.That(xform.MapID, Is.EqualTo(MapId.Nullspace)); Assert.That(xform.MapID, Is.EqualTo(MapId.Nullspace));
Assert.Null(xform.MapUid); Assert.That(xform.MapUid, Is.Null);
Assert.Null(xform.GridUid); Assert.That(xform.GridUid, Is.Null);
}); });
await Server.WaitPost(() =>MapMan.DeleteMap(MapId)); await Server.WaitPost(() =>MapMan.DeleteMap(MapId));
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using NUnit.Framework; using NUnit.Framework;
@@ -29,11 +29,12 @@ public abstract class ToolshedTest : RobustIntegrationTest, IInvocationContext
public async Task TearDownInternal() public async Task TearDownInternal()
{ {
await TearDown(); await TearDown();
Server.Dispose();
} }
protected virtual async Task TearDown() protected virtual async Task TearDown()
{ {
Assert.IsEmpty(_expectedErrors); Assert.That(_expectedErrors, Is.Empty);
ClearErrors(); ClearErrors();
} }
@@ -69,19 +69,19 @@ public sealed class GridTraversalTest : RobustIntegrationTest
// Spawning an entity far away from the grid will leave it parented to the map. // Spawning an entity far away from the grid will leave it parented to the map.
entity = sEntMan.SpawnEntity(null, new MapCoordinates(new Vector2(100f, 100f), mapId)); entity = sEntMan.SpawnEntity(null, new MapCoordinates(new Vector2(100f, 100f), mapId));
Assert.That(sEntMan.GetComponent<TransformComponent>(entity).MapUid, Is.EqualTo(map)); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).MapUid, Is.EqualTo(map));
Assert.Null(sEntMan.GetComponent<TransformComponent>(entity).GridUid); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).GridUid, Is.Null);
Assert.That(sEntMan.GetComponent<TransformComponent>(entity).ParentUid, Is.EqualTo(map)); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).ParentUid, Is.EqualTo(map));
sEntMan.Deleted(entity); sEntMan.Deleted(entity);
entity = sEntMan.SpawnEntity(null, new EntityCoordinates(map, new Vector2(100f, 100f))); entity = sEntMan.SpawnEntity(null, new EntityCoordinates(map, new Vector2(100f, 100f)));
Assert.That(sEntMan.GetComponent<TransformComponent>(entity).MapUid, Is.EqualTo(map)); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).MapUid, Is.EqualTo(map));
Assert.Null(sEntMan.GetComponent<TransformComponent>(entity).GridUid); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).GridUid, Is.Null);
Assert.That(sEntMan.GetComponent<TransformComponent>(entity).ParentUid, Is.EqualTo(map)); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).ParentUid, Is.EqualTo(map));
sEntMan.Deleted(entity); sEntMan.Deleted(entity);
entity = sEntMan.SpawnEntity(null, new EntityCoordinates(grid, 100f, 100f)); entity = sEntMan.SpawnEntity(null, new EntityCoordinates(grid, 100f, 100f));
Assert.That(sEntMan.GetComponent<TransformComponent>(entity).MapUid, Is.EqualTo(map)); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).MapUid, Is.EqualTo(map));
Assert.Null(sEntMan.GetComponent<TransformComponent>(entity).GridUid); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).GridUid, Is.Null);
Assert.That(sEntMan.GetComponent<TransformComponent>(entity).ParentUid, Is.EqualTo(map)); Assert.That(sEntMan.GetComponent<TransformComponent>(entity).ParentUid, Is.EqualTo(map));
sEntMan.Deleted(entity); sEntMan.Deleted(entity);
}); });
@@ -208,7 +208,7 @@ public sealed class ResPathTest
Assert.That(empty?.Extension, Is.EqualTo("")); Assert.That(empty?.Extension, Is.EqualTo(""));
Assert.That(empty?.Filename, Is.EqualTo(".")); Assert.That(empty?.Filename, Is.EqualTo("."));
Assert.That(empty?.FilenameWithoutExtension, Is.EqualTo(".")); Assert.That(empty?.FilenameWithoutExtension, Is.EqualTo("."));
Assert.False(empty.Equals(null)); Assert.That(empty.Equals(null), Is.False);
} }
[Test] [Test]
-10
View File
@@ -23,8 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetSerializer", "NetSeriali
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetSerializer", "NetSerializer\NetSerializer\NetSerializer.csproj", "{ECBCE1D8-05C2-4881-9446-197C4C8E1C14}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetSerializer", "NetSerializer\NetSerializer\NetSerializer.csproj", "{ECBCE1D8-05C2-4881-9446-197C4C8E1C14}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Robust.Physics", "Robust.Physics\Robust.Physics.csproj", "{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Robust.LoaderApi", "Robust.LoaderApi", "{805C8FD2-0C32-4DA8-BC4B-143BA5D48FF4}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Robust.LoaderApi", "Robust.LoaderApi", "{805C8FD2-0C32-4DA8-BC4B-143BA5D48FF4}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Robust.LoaderApi", "Robust.LoaderApi\Robust.LoaderApi\Robust.LoaderApi.csproj", "{4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Robust.LoaderApi", "Robust.LoaderApi\Robust.LoaderApi\Robust.LoaderApi.csproj", "{4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}"
@@ -135,14 +133,6 @@ Global
{ECBCE1D8-05C2-4881-9446-197C4C8E1C14}.Release|Any CPU.Build.0 = Release|Any CPU {ECBCE1D8-05C2-4881-9446-197C4C8E1C14}.Release|Any CPU.Build.0 = Release|Any CPU
{ECBCE1D8-05C2-4881-9446-197C4C8E1C14}.Release|x64.ActiveCfg = Release|Any CPU {ECBCE1D8-05C2-4881-9446-197C4C8E1C14}.Release|x64.ActiveCfg = Release|Any CPU
{ECBCE1D8-05C2-4881-9446-197C4C8E1C14}.Release|x64.Build.0 = Release|Any CPU {ECBCE1D8-05C2-4881-9446-197C4C8E1C14}.Release|x64.Build.0 = Release|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Debug|Any CPU.Build.0 = Debug|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Debug|x64.ActiveCfg = Debug|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Debug|x64.Build.0 = Debug|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Release|Any CPU.ActiveCfg = Release|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Release|Any CPU.Build.0 = Release|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Release|x64.ActiveCfg = Release|Any CPU
{887A54FA-7D31-4D6D-9D7F-9AE3739E4982}.Release|x64.Build.0 = Release|Any CPU
{4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}.Debug|Any CPU.Build.0 = Debug|Any CPU {4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}.Debug|x64.ActiveCfg = Debug|Any CPU {4FC5049F-AEEC-4DC0-9F4D-EB927AAB4F15}.Debug|x64.ActiveCfg = Debug|Any CPU
+9 -1
View File
@@ -1,7 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<packageSources> <packageSources>
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> <add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" /> <add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
</packageSources> </packageSources>
<packageSourceMapping>
<packageSource key="nuget">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet-eng">
<package pattern="Microsoft.DotNet.RemoteExecutor" />
</packageSource>
</packageSourceMapping>
</configuration> </configuration>