Skip to content

Commit

Permalink
Resolve compiler warnings from C# tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoglan committed Sep 4, 2023
1 parent a284542 commit 215ab9b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 34 deletions.
6 changes: 2 additions & 4 deletions test/cs/ChoicesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ public NodeSpec<Label> node(String text, int offset) {
}
}

#pragma warning disable CS8602
public class NodeWrapper : Node<Label> {
private TreeNode? node;
private TreeNode node;

public NodeWrapper(TreeNode? node) {
public NodeWrapper(TreeNode node) {
this.node = node;
}

Expand Down Expand Up @@ -126,5 +125,4 @@ public void toMatch(NodeSpec<Label> spec) {
spec.assertMatches(this);
}
}
#pragma warning restore CS8602
}
11 changes: 4 additions & 7 deletions test/cs/NodeActionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ public TreeNode make_empty_list(String input, int start, int end, List<TreeNode>
return null;
}
}
#pragma warning disable CS0108

public class CustomNode : TreeNode {
public String type, input;
public int start, end;
public List<TreeNode> elements;
new public List<TreeNode> elements;
public ElementsSpec<Label> elemsSpec = new ElementsSpec<Label>();

public CustomNode(String type, String input, int start, int end) : this(type, input, start, end, null){
Expand All @@ -300,7 +300,6 @@ public CustomNode elem(NodeSpec<Label> elem) {
return this;
}
}
#pragma warning restore CS0108

public class ParseHelper {
public Node<Label> expect(TreeNode node) {
Expand All @@ -320,11 +319,10 @@ public void assertNode(CustomNode expected, CustomNode actual) {
}
}

#pragma warning disable CS8602
public class NodeWrapper : Node<Label> {
private TreeNode? node;
private TreeNode node;

public NodeWrapper(TreeNode? node) {
public NodeWrapper(TreeNode node) {
this.node = node;
}

Expand Down Expand Up @@ -352,5 +350,4 @@ public void toMatch(NodeSpec<Label> spec) {
spec.assertMatches(this);
}
}
#pragma warning restore CS8602
}
7 changes: 3 additions & 4 deletions test/cs/PredicatesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ public NodeSpec<Label> node(String text, int offset) {
return new NodeSpec<Label>(text, offset);
}
}
#pragma warning disable CS8602

public class NodeWrapper : Node<Label> {
private TreeNode? node;
private TreeNode node;

public NodeWrapper(TreeNode? node) {
public NodeWrapper(TreeNode node) {
this.node = node;
}

Expand Down Expand Up @@ -171,5 +171,4 @@ public void toMatch(NodeSpec<Label> spec) {
spec.assertMatches(this);
}
}
#pragma warning restore CS8602
}
7 changes: 3 additions & 4 deletions test/cs/QuantifiersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ public NodeSpec<Label> node(String text, int offset) {
return new NodeSpec<Label>(text, offset);
}
}
#pragma warning disable CS8602

public class NodeWrapper : Node<Label> {
private TreeNode? node;
private TreeNode node;

public NodeWrapper(TreeNode? node) {
public NodeWrapper(TreeNode node) {
this.node = node;
}

Expand Down Expand Up @@ -323,5 +323,4 @@ public void toMatch(NodeSpec<Label> spec) {
spec.assertMatches(this);
}
}
#pragma warning restore CS8602
}
5 changes: 1 addition & 4 deletions test/cs/SequencesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ namespace canopy.sequences {
using Microsoft.VisualStudio.TestTools.UnitTesting;

using canopy.test.grammars.sequences;
#pragma warning disable CS8600
#pragma warning disable CS8604

[TestClass]
public class SequenceStringsTest : ParseHelper {
[TestMethod]
Expand Down Expand Up @@ -387,6 +386,4 @@ public void toMatch(NodeSpec<Label> spec) {
spec.assertMatches(this);
}
}
#pragma warning restore CS8600
#pragma warning restore CS8604
}
7 changes: 3 additions & 4 deletions test/cs/TerminalsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ public NodeSpec<Label> node(String text, int offset) {
return new NodeSpec<Label>(text, offset);
}
}
#pragma warning disable CS8602

public class NodeWrapper : Node<Label> {
private TreeNode? node;
private TreeNode node;

public NodeWrapper(TreeNode? node) {
public NodeWrapper(TreeNode node) {
this.node = node;
}

Expand All @@ -211,5 +211,4 @@ public void toMatch(NodeSpec<Label> spec) {
spec.assertMatches(this);
}
}
#pragma warning restore CS8602
}
4 changes: 0 additions & 4 deletions test/cs/canopy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />

<Compile Include="./helpers/ElementsSpec.cs" />
<Compile Include="./helpers/Node.cs" />
<Compile Include="./helpers/NodeSpec.cs" />

<Compile Include="../grammars/choices/Actions.cs" />
<Compile Include="../grammars/choices/CacheRecord.cs" />
<Compile Include="../grammars/choices/Grammar.cs" />
Expand Down
2 changes: 1 addition & 1 deletion test/cs/helpers/ElementsSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

public class ElementsSpec<L> {
private List<NodeSpec<L>>? elements = null;
private List<NodeSpec<L>> elements;

public void noElems() {
elements = new List<NodeSpec<L>>();
Expand Down
3 changes: 1 addition & 2 deletions test/cs/helpers/NodeSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
public class NodeSpec<L> {
private String text_value;
private int offset_value;
#pragma warning disable CS8714
private ElementsSpec<L> elements = new ElementsSpec<L>();
private Dictionary<L, NodeSpec<L>> labelled = new Dictionary<L, NodeSpec<L>>();
#pragma warning restore CS8714

public NodeSpec(String text, int offset) {
this.text_value = text;
this.offset_value = offset;
Expand Down

0 comments on commit 215ab9b

Please sign in to comment.