mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Work around Roslyn scripting bug with ref structs.
This commit is contained in:
@@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Classification;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Scripting;
|
||||
using Microsoft.CodeAnalysis.CSharp.Scripting.Hosting;
|
||||
using Microsoft.CodeAnalysis.Scripting;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -220,5 +221,19 @@ namespace Robust.Shared.Scripting
|
||||
.AddImports(_defaultImports)
|
||||
.AddReferences(GetDefaultReferences(reflectionManager));
|
||||
}
|
||||
|
||||
public static string SafeFormat(object obj)
|
||||
{
|
||||
// Working "around" https://github.com/dotnet/roslyn/issues/51548
|
||||
|
||||
try
|
||||
{
|
||||
return CSharpObjectFormatter.Instance.FormatObject(obj);
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
return "<CSharpObjectFormatter.FormatObject threw>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user