Update to .NET 7 SDK (#1792)

This commit is contained in:
Cheena Malhotra
2023-02-07 17:53:36 -08:00
committed by GitHub
parent 51892519ef
commit 8d119876d9
62 changed files with 169 additions and 147 deletions

View File

@@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
internal class BatchParserMockEventHandler : IBatchEventsHandler
public class BatchParserMockEventHandler : IBatchEventsHandler
{
public SqlError Error { get; private set; }

View File

@@ -54,7 +54,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
p.ThrowOnUnresolvedVariable = true;
handler.SetParser(p);
Assert.Throws<BatchParserException>(() => p.Parse());
Assert.Throws<BatchParserException>(p.Parse);
}
}
@@ -77,7 +77,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
p.ThrowOnUnresolvedVariable = true;
handler.SetParser(p);
Assert.Throws<BatchParserException>(() => p.Parse());
Assert.Throws<BatchParserException>(p.Parse);
}
}
@@ -98,7 +98,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
p.ThrowOnUnresolvedVariable = true;
handler.SetParser(p);
Assert.Throws<BatchParserException>(() => p.Parse());
Assert.Throws<BatchParserException>(p.Parse);
}
}
@@ -119,7 +119,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
p.ThrowOnUnresolvedVariable = true;
handler.SetParser(p);
Assert.Throws<BatchParserException>(() => p.Parse());
Assert.Throws<BatchParserException>(p.Parse);
}
}
@@ -142,7 +142,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
handler.SetParser(p);
// This test will fail because we are passing invalid number.
// Exception will be raised from ParseGo()
Assert.Throws<BatchParserException>(() => p.Parse());
Assert.Throws<BatchParserException>(p.Parse);
}
}
@@ -248,7 +248,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
p.ThrowOnUnresolvedVariable = true;
handler.SetParser(p);
var exception = Assert.Throws<BatchParserException>(() => p.Parse());
var exception = Assert.Throws<BatchParserException>(p.Parse);
// Verify the message should be "Command Execute is not supported."
Assert.AreEqual("Command Execute is not supported.", exception.Message);
}

View File

@@ -13,7 +13,7 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser;
namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
{
internal class TestCommandHandler : ICommandHandler
public class TestCommandHandler : ICommandHandler
{
private Parser parser;
private StringBuilder outputString;

View File

@@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine
{
internal class BatchEventHandler : IBatchEventsHandler
public class BatchEventHandler : IBatchEventsHandler
{
private List<int> resultCounts = new List<int>();
private List<string> sqlMessages = new List<string>();

View File

@@ -14,7 +14,7 @@ using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine
{
internal class TestExecutor : IDisposable
public class TestExecutor : IDisposable
{
#region Private variables

View File

@@ -9,7 +9,7 @@ using System.IO;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.Utility
{
internal class FileUtilities
public class FileUtilities
{
/// <summary>
/// Turns off the read-only attribute for this file

View File

@@ -6,6 +6,8 @@
<PackageId>Microsoft.SqlTools.ServiceLayer.IntegrationTests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
<!-- TODO FIX THESE WARNINGS ASAP -->
<NoWarn>$(NoWarn);SYSLIB1045;IDE0200;IDE0230;CA1311;CA1852;CA1854</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../../src/Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />

View File

@@ -9,7 +9,7 @@ using System;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
{
internal class ComparisonFailureException : InvalidOperationException
internal sealed class ComparisonFailureException : InvalidOperationException
{
internal string FullMessageWithDiff { get; private set; }
internal string EditAndCopyMessage { get; private set; }

View File

@@ -180,14 +180,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
Event
}
private class ExpectedEvent
private sealed class ExpectedEvent
{
public EventTypes EventType { get; set; }
public Type ParamType { get; set; }
public Delegate Validator { get; set; }
}
private class ReceivedEvent
private sealed class ReceivedEvent
{
public object EventObject { get; set; }
public EventTypes EventType { get; set; }

View File

@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
// Include a fallback value to for running tests within visual studio
serviceHostExecutable =
@"..\..\..\..\..\src\Microsoft.SqlTools.ServiceLayer\bin\Debug\net6.0\win-x64\MicrosoftSqlToolsServiceLayer.exe";
@"..\..\..\..\..\src\Microsoft.SqlTools.ServiceLayer\bin\Debug\net7.0\win-x64\MicrosoftSqlToolsServiceLayer.exe";
if (!File.Exists(serviceHostExecutable))
{
serviceHostExecutable = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "MicrosoftSqlToolsServiceLayer.exe");

View File

@@ -13,7 +13,7 @@ using System.Collections.Generic;
namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig
{
class Program
sealed class Program
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0210:Convert to top-level statements", Justification = "Structure retained for readability.")]
static void Main(string[] args)

View File

@@ -5,7 +5,9 @@
<DefineConstants>$(DefineConstants);NETCOREAPP1_0;TRACE</DefineConstants>
<IsPackable>false</IsPackable>
<ApplicationIcon />
<StartupObject />
<StartupObject />
<!-- TODO FIX THESE WARNINGS ASAP -->
<NoWarn>$(NoWarn);SYSLIB1045;IDE0200;IDE0230;CA1311;CA1852;CA1854</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Encoding.CodePages" />

View File

@@ -11,21 +11,20 @@ using System.Text.RegularExpressions;
namespace ScriptGenerator
{
class Program
public partial class Program
{
internal const string DefaultFileExtension = "Sql";
static readonly Regex ExtractDbName = new Regex(@"CREATE\s+DATABASE\s+\[(?<dbName>\w+)\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
static readonly Regex CreateTableRegex = new Regex(@"(?<begin>CREATE\s+TABLE\s+.*)(?<middle>\](?![\.])[\s\S]*?CONSTRAINT\s+\[\w+?)(?<end>\](?![\.]))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
static readonly Regex AlterTableConstraintRegex = new Regex(@"(?<begin>ALTER\s+TABLE\s+.*?)(?<middle>\](?![\.])\s*\b(?:ADD|WITH|CHECK)\b[\s\S]*?CONSTRAINT\s+\[\w+?)(?<end>\](?![\.]))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
static readonly Regex CreateViewRegex = new Regex(@"(?<begin>CREATE\s+VIEW\s+.*?)(?<end>\](?![\.])[\s\S]*?\bAS\b)", RegexOptions.Compiled | RegexOptions.IgnoreCase );
static readonly Regex CreateProcedureRegex = new Regex(@"(?<begin>CREATE\s+PROCEDURE\s+.*?)(?<end>\](?![\.])[\s\S]*?(?:@|WITH|AS))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
static readonly Regex ExtractDbName = CreateDbRegex();
static readonly Regex CreateTableRegex = CreateTableSyntaxRegex();
static readonly Regex AlterTableConstraintRegex = AlterTableSyntaxRegex();
static readonly Regex CreateViewRegex = CreateViewSyntaxRegex();
static readonly Regex CreateProcedureRegex = CreateProcedureSyntaxRegex();
static void Main(string[] args)
{
CommandOptions options = new CommandOptions(args);
var options = new CommandOptions(args);
for (int d = 1; d <= options.Databases; d++)
{
using (StreamWriter writer = new StreamWriter(Path.ChangeExtension($@"{options.FilePathPrefix}{d}", DefaultFileExtension)))
using (var writer = new StreamWriter(Path.ChangeExtension($@"{options.FilePathPrefix}{d}", DefaultFileExtension)))
{
string oldDbName = ExtractDbName.Match(Resources.AdventureWorks).Groups["dbName"].Value;
string newDbName = $@"{oldDbName}{d}";
@@ -59,5 +58,16 @@ namespace ScriptGenerator
}
}
}
[GeneratedRegex("CREATE\\s+DATABASE\\s+\\[(?<dbName>\\w+)\\]", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")]
private static partial Regex CreateDbRegex();
[GeneratedRegex("(?<begin>CREATE\\s+TABLE\\s+.*)(?<middle>\\](?![\\.])[\\s\\S]*?CONSTRAINT\\s+\\[\\w+?)(?<end>\\](?![\\.]))", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")]
private static partial Regex CreateTableSyntaxRegex();
[GeneratedRegex("(?<begin>ALTER\\s+TABLE\\s+.*?)(?<middle>\\](?![\\.])\\s*\\b(?:ADD|WITH|CHECK)\\b[\\s\\S]*?CONSTRAINT\\s+\\[\\w+?)(?<end>\\](?![\\.]))", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")]
private static partial Regex AlterTableSyntaxRegex();
[GeneratedRegex("(?<begin>CREATE\\s+VIEW\\s+.*?)(?<end>\\](?![\\.])[\\s\\S]*?\\bAS\\b)", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")]
private static partial Regex CreateViewSyntaxRegex();
[GeneratedRegex("(?<begin>CREATE\\s+PROCEDURE\\s+.*?)(?<end>\\](?![\\.])[\\s\\S]*?(?:@|WITH|AS))", RegexOptions.IgnoreCase | RegexOptions.Compiled, "en-CA")]
private static partial Regex CreateProcedureSyntaxRegex();
}
}