Address warnings and (some) nullables (#2013)

This commit is contained in:
Cheena Malhotra
2023-04-18 20:57:13 -07:00
committed by GitHub
parent d56f2309da
commit 648d7dbd3c
83 changed files with 674 additions and 588 deletions

View File

@@ -27,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
/// </summary>
public string Id
{
get { return this.ClientUri.ToLower(); }
get { return this.ClientUri.ToLower(System.Globalization.CultureInfo.InvariantCulture); }
}
/// <summary>

View File

@@ -23,7 +23,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
/// Manages a "workspace" of script files that are open for a particular
/// editing session. Also helps to navigate references between ScriptFiles.
/// </summary>
public class Workspace : IDisposable
public partial class Workspace : IDisposable
{
#region Private Fields
@@ -117,8 +117,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
}
// This method allows FileNotFoundException to bubble up
// if the file isn't found.
using (FileStream fileStream = new FileStream(resolvedFile.FilePath, FileMode.Open, FileAccess.Read))
using (StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8))
using (var fileStream = new FileStream(resolvedFile.FilePath, FileMode.Open, FileAccess.Read))
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
{
scriptFile = new ScriptFile(resolvedFile.FilePath, resolvedFile.ClientUri,streamReader);
@@ -150,7 +150,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
// Client sent the path in URI format, extract the local path and trim
// any extraneous slashes
Uri fileUri = new Uri(clientUri);
var fileUri = new Uri(clientUri);
filePath = fileUri.LocalPath;
if (filePath.StartsWith("//") || filePath.StartsWith("\\\\") || filePath.StartsWith("/"))
{
@@ -208,7 +208,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
return path;
}
return Regex.Replace(path, @"`(?=[ \[\]])", "");
return GetEscapeRegex().Replace(path, "");
}
/// <summary>
@@ -363,6 +363,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
{
}
[GeneratedRegex("`(?=[ \\[\\]])")]
private static partial Regex GetEscapeRegex();
#endregion
}
}