mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-20 17:24:00 -05:00
Make nullable warnings a per file opt-in (#1842)
* Make nullable warnings a per file opt-in * Remove unneeded compiler directives * Remove compiler directive for User Data
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters;
|
||||
@@ -35,8 +37,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
yield return new object[] { "[escaped].mixed", new[] { "escaped", "mixed" } };
|
||||
yield return new object[] { "dbo.[[].weird", new[] { "dbo", "[", "weird" } };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(nameof(DecodeMultipartIdentifierTestData))]
|
||||
public void DecodeMultipartIdentifierTest(string input, string[] output)
|
||||
@@ -48,8 +50,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
Assert.AreEqual(output, decoded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
[Test]
|
||||
|
||||
public void DecodeMultipartIdentifierFailTest([Values(
|
||||
"[bracket]closed",
|
||||
"[bracket][closed",
|
||||
@@ -60,12 +62,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
// If: I decode an invalid input
|
||||
// Then: It should throw an exception
|
||||
Assert.Throws<FormatException>(() => FromSqlScript.DecodeMultipartIdentifier(input));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static readonly object[] unescaped =
|
||||
{
|
||||
|
||||
private static readonly object[] unescaped =
|
||||
{
|
||||
new object[] {"(0)", "0" },
|
||||
new object[] {"((0))", "0" },
|
||||
new object[] {"('')", "" },
|
||||
@@ -73,7 +75,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
new object[] {"(N'')", "" },
|
||||
new object[] {"(N'stuff')", "stuff" },
|
||||
new object[] {"('''stuff')", "'stuff" },
|
||||
new object[] {"(N'stu''''ff')", "stu''ff" },
|
||||
new object[] {"(N'stu''''ff')", "stu''ff" },
|
||||
};
|
||||
|
||||
[Test, TestCaseSource(nameof(unescaped))]
|
||||
@@ -82,8 +84,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
Assert.AreEqual(output, FromSqlScript.UnwrapLiteral(input));
|
||||
}
|
||||
|
||||
private static readonly object[] bracketed =
|
||||
{
|
||||
private static readonly object[] bracketed =
|
||||
{
|
||||
new object[] {"[name]", true },
|
||||
new object[] {"[ name ]", true },
|
||||
new object[] {"[na[[]me]", true },
|
||||
@@ -93,7 +95,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
new object[] {"name]", false },
|
||||
new object[] {"[]name", false},
|
||||
new object[] {"name[]", false},
|
||||
new object[] {"[na]me", false },
|
||||
new object[] {"[na]me", false },
|
||||
};
|
||||
|
||||
[Test, TestCaseSource(nameof(bracketed))]
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
@@ -67,14 +69,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
Assert.AreEqual(cell.RawObject, long.Parse(output));
|
||||
}
|
||||
|
||||
private static readonly object[] decimalTypes =
|
||||
{
|
||||
private static readonly object[] decimalTypes =
|
||||
{
|
||||
new object[] {"MONEY", "MONEY", null, null },
|
||||
new object[] {"SMALLMONEY", "SMALLMONEY", null, null },
|
||||
new object[] {"NUMERIC", @"NUMERIC\(\d+, \d+\)", 18, 0},
|
||||
new object[] {"DECIMAL", @"DECIMAL\(\d+, \d+\)", 18, 0 },
|
||||
};
|
||||
|
||||
new object[] {"DECIMAL", @"DECIMAL\(\d+, \d+\)", 18, 0 },
|
||||
};
|
||||
|
||||
[Test, TestCaseSource(nameof(decimalTypes))]
|
||||
public void DecimalTest(string dataType, string regex, int? precision, int? scale)
|
||||
{
|
||||
@@ -260,13 +262,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
Assert.Throws<ArgumentNullException>(() => ToSqlScript.FormatIdentifier(null));
|
||||
}
|
||||
|
||||
private static readonly object[] bracketEscapes =
|
||||
{
|
||||
private static readonly object[] bracketEscapes =
|
||||
{
|
||||
new object[] {"test", "[test]" }, // No escape characters
|
||||
new object[] {"]test", "[]]test]" }, // Escape character at beginning
|
||||
new object[] {"te]st", "[te]]st]" }, // Escape character in middle
|
||||
new object[] {"test]", "[test]]]" }, // Escape character at end
|
||||
new object[] {"t]]est", "[t]]]]est]" }, // Multiple escape characters
|
||||
new object[] {"t]]est", "[t]]]]est]" }, // Multiple escape characters
|
||||
};
|
||||
|
||||
[Test, TestCaseSource(nameof(bracketEscapes))]
|
||||
@@ -279,12 +281,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.UtilityTests
|
||||
Assert.AreEqual(expectedOutput, output);
|
||||
}
|
||||
|
||||
private static readonly object[] multiParts =
|
||||
{
|
||||
private static readonly object[] multiParts =
|
||||
{
|
||||
new object[] {"test", "[test]" }, // No splits, no escape characters
|
||||
new object[] {"test.test", "[test].[test]" }, // One split, no escape characters
|
||||
new object[] {"test.te]st", "[test].[te]]st]" }, // One split, one escape character
|
||||
new object[] {"test.test.test", "[test].[test].[test]" }, // Two splits, no escape characters
|
||||
new object[] {"test.test.test", "[test].[test].[test]" }, // Two splits, no escape characters
|
||||
};
|
||||
|
||||
[Test, TestCaseSource(nameof(multiParts))]
|
||||
|
||||
Reference in New Issue
Block a user