diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-09 23:43:13 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-09 23:43:13 -0400 |
commit | 971ed1a17559064ee0ee42a83e786b3e3076059f (patch) | |
tree | b8665f8289ccfc2ef0667d87d22f8849c7f167f1 /src/SMAPI.ModBuildConfig.Analyzer.Tests/UnitTests.cs | |
parent | c8db771e11a0e5224aa3b0766134afc8e733896e (diff) | |
download | SMAPI-971ed1a17559064ee0ee42a83e786b3e3076059f.tar.gz SMAPI-971ed1a17559064ee0ee42a83e786b3e3076059f.tar.bz2 SMAPI-971ed1a17559064ee0ee42a83e786b3e3076059f.zip |
fix net field replacements not reported for a subclass reference (#471)
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer.Tests/UnitTests.cs')
-rw-r--r-- | src/SMAPI.ModBuildConfig.Analyzer.Tests/UnitTests.cs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/UnitTests.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/UnitTests.cs index 92fc9074..f3919f78 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/UnitTests.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/UnitTests.cs @@ -38,6 +38,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests public NetInt type { get; } = new NetInt { Value = 42 }; public NetRef refField { get; } = null; } + class SObject : Item { } } namespace SampleMod @@ -47,9 +48,10 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests public void Entry() { Item item = null; + SObject obj = null; // this line should raise diagnostics - {{test-code}} // line 36 + {{test-code}} // line 38 // these lines should not if (item.type.Value != 42); @@ -59,7 +61,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests "; /// <summary>The line number where the unit tested code is injected into <see cref="SampleProgram"/>.</summary> - private const int SampleCodeLine = 36; + private const int SampleCodeLine = 38; /// <summary>The column number where the unit tested code is injected into <see cref="SampleProgram"/>.</summary> private const int SampleCodeColumn = 25; @@ -93,6 +95,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests [TestCase("if (item.type != 42);", 4, "item.type", "NetInt", "int")] [TestCase("if (item.refField != null);", 4, "item.refField", "NetRef", "object")] [TestCase("if (item?.type != 42);", 4, "item?.type", "NetInt", "int")] + [TestCase("if (obj.type != 42);", 4, "obj.type", "NetInt", "int")] public void AvoidImplicitNetFieldComparisons_RaisesDiagnostic(string codeText, int column, string expression, string fromType, string toType) { // arrange @@ -118,6 +121,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests [TestCase("int category = item.category;", 15, "item.category", "NetInt", "Category")] [TestCase("int category = (item).category;", 15, "(item).category", "NetInt", "Category")] [TestCase("int category = ((Item)item).category;", 15, "((Item)item).category", "NetInt", "Category")] + [TestCase("int category = obj.category;", 15, "obj.category", "NetInt", "Category")] public void AvoidNetFields_RaisesDiagnostic(string codeText, int column, string expression, string netType, string suggestedProperty) { // arrange |