Resolve all high-severity architecture review findings
This commit is contained in:
@@ -11,6 +11,25 @@ namespace ZB.MOM.WW.ScadaBridge.ScriptAnalysis.Tests;
|
||||
/// </summary>
|
||||
public class ScriptTrustValidatorTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("object o = new object(); System.Runtime.CompilerServices.Unsafe.As<object, string>(ref o);")]
|
||||
[InlineData("System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(typeof(object));")]
|
||||
[InlineData("new System.Runtime.Loader.AssemblyLoadContext(\"probe\");")]
|
||||
[InlineData("using U = System.Runtime.CompilerServices.Unsafe; object o = new object(); U.As<object, string>(ref o);")]
|
||||
[InlineData("using static System.Runtime.CompilerServices.RuntimeHelpers; GetUninitializedObject(typeof(object));")]
|
||||
public void MG1_RejectsRuntimeEscapeApis(string code)
|
||||
{
|
||||
Assert.NotEmpty(ScriptTrustValidator.FindViolations(code));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("await System.Threading.Tasks.Task.Delay(1);")]
|
||||
[InlineData("string Name([System.Runtime.CompilerServices.CallerMemberName] string name = \"\") => name;")]
|
||||
public void MG1_AllowsCompilerSupport(string code)
|
||||
{
|
||||
Assert.Empty(ScriptTrustValidator.FindViolations(code));
|
||||
}
|
||||
|
||||
// ---- Reject (non-empty violations) --------------------------------------
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user