diff --git a/VS/CSHARP/asm-dude-vsix/.editorconfig b/VS/CSHARP/asm-dude-vsix/.editorconfig index a75b1946..380ee93b 100644 --- a/VS/CSHARP/asm-dude-vsix/.editorconfig +++ b/VS/CSHARP/asm-dude-vsix/.editorconfig @@ -146,3 +146,9 @@ dotnet_diagnostic.CA1714.severity = silent # CA1303: Do not pass literals as localized parameters dotnet_diagnostic.CA1303.severity = silent + +# SA1307: Accessible fields should begin with upper-case letter +dotnet_diagnostic.SA1307.severity = none + +# SA1404: Code analysis suppression should have justification +dotnet_diagnostic.SA1404.severity = none diff --git a/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs b/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs index 0681480f..6b0f9cb7 100644 --- a/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs +++ b/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs @@ -433,7 +433,7 @@ private IEnumerable Selected_Completions(bool useCapitals, ISet previousStates) State result2 = new State(result, prev, true); if (counter > 2) { + //TODO HJ 26 okt 2019 investigate dispose result.Dispose(); } diff --git a/VS/CSHARP/asm-sim-main/DotVisualizer.cs b/VS/CSHARP/asm-sim-main/DotVisualizer.cs index 2e632b4d..48230bef 100644 --- a/VS/CSHARP/asm-sim-main/DotVisualizer.cs +++ b/VS/CSHARP/asm-sim-main/DotVisualizer.cs @@ -100,7 +100,7 @@ private static void MyEdgeFormatter(object sender, FormatEdgeEventArgs e) { Contract.Requires(e != null); - e.VertexFormatter.Label = e.Vertex.ToString(); + e.VertexFormatter.Label = e.Vertex.ToString(CultureInfo.InvariantCulture); } private sealed class FileDotEngine : IDotEngine diff --git a/VS/CSHARP/asm-sim-main/ProgramZ3.cs b/VS/CSHARP/asm-sim-main/ProgramZ3.cs index c19f02f9..b666ac3a 100644 --- a/VS/CSHARP/asm-sim-main/ProgramZ3.cs +++ b/VS/CSHARP/asm-sim-main/ProgramZ3.cs @@ -106,7 +106,7 @@ global and module parameters. For this purpose we should now use { "unsat_core", "false" }, // enable generation of unsat cores { "model", "false" }, // enable model generation { "proof", "false" }, // enable proof generation - { "timeout", timeOut.ToString() }, + { "timeout", timeOut.ToString(CultureInfo.InvariantCulture) }, }; return new Tools(settings); } @@ -777,7 +777,7 @@ private static void TestMnemonic() tools.Quiet = false; DynamicFlow tree1 = new DynamicFlow(tools); tree1.Reset(sFlow1, false); - Console.WriteLine(tree1.EndState); + Console.WriteLine(tree1.Create_EndState); } if (false) { @@ -809,7 +809,7 @@ private static void TestMnemonic() State state_FirstLine = tree0.Create_States_Before(lineNumber_JZ, 0); BranchInfo branchInfo = new BranchInfo(state_FirstLine.Create(Flags.ZF), true); - State state0 = tree0.EndState; + State state0 = tree0.Create_EndState; state0.BranchInfoStore.Add(branchInfo, true); Console.WriteLine("State0:" + state0); } @@ -822,7 +822,7 @@ private static void TestMnemonic() State state_FirstLine = tree1.Create_States_Before(lineNumber_JZ, 0); BranchInfo branchInfo = new BranchInfo(state_FirstLine.Create(Flags.ZF), false); - State state1 = tree1.EndState; + State state1 = tree1.Create_EndState; state1.BranchInfoStore.Add(branchInfo, true); Console.WriteLine("State1:" + state1); } @@ -852,8 +852,8 @@ private static void TestMnemonic() DynamicFlow tree2 = Runner.Construct_DynamicFlow_Forward(sFlow2, tools); // Console.WriteLine(tree1.ToString(flow1)); - State state1 = tree1.EndState; - State state2 = tree2.EndState; + State state1 = tree1.Create_EndState; + State state2 = tree2.Create_EndState; Console.WriteLine("state1:" + state1); Console.WriteLine("state2:" + state2); @@ -882,8 +882,8 @@ private static void TestMnemonic() // Console.WriteLine(tree1.ToString(flow1)); - State state1 = tree1.Leafs.ElementAt(0); - State state2 = tree2.Leafs.ElementAt(0); + State state1 = tree1.Create_Leafs.ElementAt(0); + State state2 = tree2.Create_Leafs.ElementAt(0); Console.WriteLine("state1:" + state1); Console.WriteLine("state2:" + state2); @@ -1020,7 +1020,7 @@ private static void TestDynamicFlow() } if (true) { - State endState = dFlow.EndState; + State endState = dFlow.Create_EndState; Console.WriteLine("in endState we know:\n" + endState); } } diff --git a/VS/CSHARP/asm-tools-lib/.editorconfig b/VS/CSHARP/asm-tools-lib/.editorconfig index ccfaac7d..170a1dce 100644 --- a/VS/CSHARP/asm-tools-lib/.editorconfig +++ b/VS/CSHARP/asm-tools-lib/.editorconfig @@ -113,3 +113,6 @@ dotnet_diagnostic.SA1516.severity = none # SA1649: File name should match first type name dotnet_diagnostic.SA1649.severity = silent + +# SA1214: Readonly fields should appear before non-readonly fields +dotnet_diagnostic.SA1214.severity = none diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs b/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs index f1f38ec4..8f3b994c 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs @@ -24,6 +24,7 @@ namespace unit_tests_asm_z3 { using System; using System.Collections.Generic; + using System.Globalization; using AsmSim; using AsmTools; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -58,7 +59,7 @@ global and module parameters. For this purpose we should now use { "unsat_core", "false" }, // enable generation of unsat cores { "model", "true" }, // enable model generation { "proof", "false" }, // enable proof generation - { "timeout", timeOut.ToString() }, + { "timeout", timeOut.ToString(CultureInfo.InvariantCulture) }, }; return new Tools(settings); } @@ -119,7 +120,7 @@ public void Test_BitTricks_LegatosMultiplier() Console.WriteLine("DynamicFlow:\n" + dFlow.ToString(sFlow)); } - State state = dFlow.EndState; + State state = dFlow.Create_EndState; } [TestMethod] diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_ExecutionTree.cs b/VS/CSHARP/unit-tests-asm-sim/Test_ExecutionTree.cs index 27653a76..5b7e8d84 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_ExecutionTree.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_ExecutionTree.cs @@ -24,6 +24,7 @@ namespace unit_tests_asm_z3 { using System; using System.Collections.Generic; + using System.Globalization; using AsmSim; using AsmTools; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -40,7 +41,7 @@ private Tools CreateTools(int timeOut = AsmTestTools.DEFAULT_TIMEOUT) { "unsat-core", "false" }, // enable generation of unsat cores { "model", "false" }, // enable model generation { "proof", "false" }, // enable proof generation - { "timeout", timeOut.ToString() }, + { "timeout", timeOut.ToString(CultureInfo.InvariantCulture) }, }; return new Tools(settings); } diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_MemZ3.cs b/VS/CSHARP/unit-tests-asm-sim/Test_MemZ3.cs index 9e8312d7..06c45077 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_MemZ3.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_MemZ3.cs @@ -25,6 +25,7 @@ namespace unit_tests_asm_z3 using System; using System.Collections.Generic; using System.Diagnostics; + using System.Globalization; using AsmSim; using AsmTools; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -59,7 +60,7 @@ global and module parameters. For this purpose we should now use { "unsat_core", "false" }, // enable generation of unsat cores { "model", "false" }, // enable model generation { "proof", "false" }, // enable proof generation - { "timeout", timeOut.ToString() }, + { "timeout", timeOut.ToString(CultureInfo.InvariantCulture) }, }; return new Tools(settings); } diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs b/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs index 62e02c2e..adfe70ed 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs @@ -24,6 +24,7 @@ namespace unit_tests_asm_z3 { using System; using System.Collections.Generic; + using System.Globalization; using System.Numerics; // for BigInt using AsmSim; using AsmTools; @@ -64,7 +65,7 @@ global and module parameters. For this purpose we should now use { "unsat_core", "false" }, // enable generation of unsat cores { "model", "false" }, // enable model generation { "proof", "false" }, // enable proof generation - { "timeout", timeOut.ToString() }, + { "timeout", timeOut.ToString(CultureInfo.InvariantCulture) }, { "parallel", "true" }, }; return new Tools(settings); diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_Runner.cs b/VS/CSHARP/unit-tests-asm-sim/Test_Runner.cs index 5ba207c0..09aefac7 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_Runner.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_Runner.cs @@ -34,7 +34,7 @@ namespace unit_tests_asm_z3 public class Test_Runner { private const bool LogToDisplay = AsmTestTools.LOG_TO_DISPLAY; - private static readonly CultureInfo Culture = CultureInfo.CurrentCulture; + private static readonly CultureInfo Culture = CultureInfo.InvariantCulture; #region Private Methods @@ -73,8 +73,8 @@ private State Equal_Forward_Backward(string programStr, bool logToDispay2, Tools // Console.WriteLine("Forward:" + tree0.ToString(dFlow0)); // Console.WriteLine("Backward:" + tree1.ToString(dFlow1)); - State state0 = dFlow0.EndState; - State state1 = dFlow1.EndState; + State state0 = dFlow0.Create_EndState; + State state1 = dFlow1.Create_EndState; if (logToDispay2) { @@ -256,7 +256,7 @@ public void Test_Runner_Jmp_1() tools.StateConfig = sFlow.Create_StateConfig(); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; // if (logToDisplay) Console.WriteLine("DynamicFlow:\n" + dFlow.ToString(staticFlow)); if (LogToDisplay) { @@ -284,7 +284,7 @@ public void Test_Runner_Jmp_2() tools.StateConfig = sFlow.Create_StateConfig(); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; if (LogToDisplay) { Console.WriteLine(state); @@ -312,7 +312,7 @@ public void Test_Runner_Jmp_3() // var dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Forward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; if (LogToDisplay) { Console.WriteLine(state); @@ -342,7 +342,7 @@ public void Test_Runner_Jmp_4() DynamicFlow dFlow = Runner.Construct_DynamicFlow_Forward(sFlow, tools); // if (logToDisplay) Console.WriteLine(dFlow.ToString(sFlow)); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; // if (logToDisplay) Console.WriteLine(state); AsmTestTools.IsTrue(state.IsConsistent); @@ -369,7 +369,7 @@ public void Test_Runner_Jmp_5() bool logToDisplay2 = true; tools.Quiet = true; // !logToDisplay2; - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (logToDisplay2) @@ -432,7 +432,7 @@ public void Test_Runner_Jmp_5a() State state0 = dFlow.Create_States_Before(0, 0); Assert.IsNotNull(state0); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (LogToDisplay) @@ -466,7 +466,7 @@ public void Test_Runner_Jmp_5b() State state0 = dFlow.Create_States_Before(0, 0); Assert.IsNotNull(state0); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (LogToDisplay) @@ -491,7 +491,7 @@ public void Test_Runner_Jmp_6() tools.StateConfig = sFlow.Create_StateConfig(); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); // DotVisualizer.SaveToDot(sFlow, dFlow, "test1.dot"); @@ -548,7 +548,7 @@ public void Test_Runner_Jmp_7() DynamicFlow dFlow = Runner.Construct_DynamicFlow_Forward(sFlow, tools); // DotVisualizer.SaveToDot(sFlow, dFlow, "test1.dot"); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (LogToDisplay) @@ -606,7 +606,7 @@ public void Test_Runner_Jmp_8() tools.StateConfig = sFlow.Create_StateConfig(); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (LogToDisplay) @@ -721,7 +721,7 @@ public void Test_Runner_Jmp_9() tools.StateConfig = sFlow.Create_StateConfig(); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (LogToDisplay) @@ -826,7 +826,7 @@ public void Test_Runner_Jmp_10() tools.StateConfig = sFlow.Create_StateConfig(); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (LogToDisplay) @@ -894,7 +894,7 @@ public void Test_Runner_Jmp_11() tools.StateConfig = sFlow.Create_StateConfig(); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Assert.IsNotNull(state); if (LogToDisplay) @@ -966,7 +966,7 @@ public void Test_Runner_Mem_1() StaticFlow sFlow = new StaticFlow(tools); sFlow.Update(programStr); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; AsmTestTools.AreEqual(Rn.RCX, 20, state); AsmTestTools.AreEqual(Rn.RDX, 20, state); @@ -993,7 +993,7 @@ public void Test_Runner_Mem_2() StaticFlow sFlow = new StaticFlow(tools); sFlow.Update(programStr); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; AsmTestTools.AreEqual(Rn.RAX, 0, state); AsmTestTools.AreEqual(Rn.RBX, 10, state); @@ -1022,7 +1022,7 @@ public void Test_Runner_Mem_3() sFlow.Update(programStr); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); State state0 = dFlow.Create_States_Before(0, 0); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; Microsoft.Z3.Expr rax = state0.Create(Rn.RAX).Translate(state.Ctx); state.Frozen = false; @@ -1060,7 +1060,7 @@ public void Test_Runner_Mem_Merge_1() StaticFlow sFlow = new StaticFlow(tools); sFlow.Update(programStr); DynamicFlow dFlow = Runner.Construct_DynamicFlow_Backward(sFlow, tools); - State state = dFlow.EndState; + State state = dFlow.Create_EndState; State state3 = new State(state); State state4 = new State(state); @@ -1112,7 +1112,7 @@ public void Test_Runner_Loop_1() if (false) { - State state = dFlow.EndState; + State state = dFlow.Create_EndState; if (logToDisplay2) { Console.WriteLine(state); @@ -1154,7 +1154,7 @@ public void Test_Runner_Loop_2() if (false) { // backward - State state = dFlow.EndState; + State state = dFlow.Create_EndState; if (logToDisplay2) { Console.WriteLine(state); diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_State.cs b/VS/CSHARP/unit-tests-asm-sim/Test_State.cs index b13bb8ba..4fa76a33 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_State.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_State.cs @@ -33,7 +33,7 @@ namespace unit_tests_asm_z3 public class Test_State { private const bool LogToDisplay = AsmTestTools.LOG_TO_DISPLAY; - private static readonly CultureInfo Culture = CultureInfo.CurrentCulture; + private static readonly CultureInfo Culture = CultureInfo.InvariantCulture; private Tools CreateTools(int timeOut = AsmTestTools.DEFAULT_TIMEOUT) {