Skip to content

Commit

Permalink
Merge pull request #88 from tintoy/move-to-net8-and-refactor
Browse files Browse the repository at this point in the history
Move server to .NET 8 and a bit of refactoring
  • Loading branch information
DoctorKrolic authored Jan 2, 2024
2 parents ddf722a + 9536dbc commit 2f7b6e3
Show file tree
Hide file tree
Showing 28 changed files with 41 additions and 353 deletions.
3 changes: 1 addition & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.413",
"version": "8.0.100",
"rollForward": "feature"
}
}
22 changes: 9 additions & 13 deletions src/LanguageServer.Common/Utilities/DotNetRuntimeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,18 @@ namespace MSBuildProjectTools.LanguageServer.Utilities
/// <summary>
/// Information about the .NET Core runtime.
/// </summary>
public class DotNetRuntimeInfo
public partial class DotNetRuntimeInfo
{
/// <summary>
/// The minimum SDK version to be considered .NET 6.x.
/// </summary>
static readonly SemanticVersion Sdk60Version = new SemanticVersion(6, 0, 101);

/// <summary>
/// Regular expression to parse SDK information from "dotnet --list-sdks".
/// </summary>
static readonly Regex SdkInfoParser = new Regex(@"(?<SdkVersion>.*) \[(?<SdkBaseDirectory>.*)\]");
[GeneratedRegex(@"(?<SdkVersion>.*) \[(?<SdkBaseDirectory>.*)\]")]
private static partial Regex SdkInfoParser();

/// <summary>
/// Regular expression to parse SDK information from "dotnet --list-runtimes".
/// </summary>
static readonly Regex RuntimeInfoParser = new Regex(@"(?<RuntimeName>.*) (?<RuntimeVersion>.*) \[(?<RuntimeBaseDirectory>.*)\]");
[GeneratedRegex(@"(?<RuntimeName>.*) (?<RuntimeVersion>.*) \[(?<RuntimeBaseDirectory>.*)\]")]
private static partial Regex RuntimeInfoParser();

/// <summary>
/// Information, if known, about the current .NET runtime (i.e. host).
Expand Down Expand Up @@ -189,7 +185,7 @@ public static List<DotnetSdkInfo> ParseDotNetListSdksOutput(TextReader dotNetLis
string currentLine;
while ((currentLine = dotNetListSdksOutput.ReadLine()) != null)
{
Match parseResult = SdkInfoParser.Match(currentLine);
Match parseResult = SdkInfoParser().Match(currentLine);
if (!parseResult.Success)
continue;

Expand Down Expand Up @@ -225,7 +221,7 @@ public static List<DotnetRuntimeInfo> ParseDotNetListRuntimesOutput(TextReader d
string currentLine;
while ((currentLine = dotNetListRuntimesOutput.ReadLine()) != null)
{
Match parseResult = RuntimeInfoParser.Match(currentLine);
Match parseResult = RuntimeInfoParser().Match(currentLine);
if (!parseResult.Success)
continue;

Expand Down Expand Up @@ -382,7 +378,7 @@ public static DotNetRuntimeInfo ParseDotNetInfoOutput(TextReader dotnetInfoOutpu
if (string.IsNullOrWhiteSpace(currentLine))
continue;

if (!currentLine.StartsWith(" ") && currentLine.EndsWith(":"))
if (!currentLine.StartsWith(' ') && currentLine.EndsWith(':'))
{
currentSection++;

Expand All @@ -392,7 +388,7 @@ public static DotNetRuntimeInfo ParseDotNetInfoOutput(TextReader dotnetInfoOutpu
continue;
}

string[] property = currentLine.Split(new char[] { ':' }, count: 2);
string[] property = currentLine.Split(':', count: 2);
if (property.Length != 2)
continue;

Expand Down
14 changes: 5 additions & 9 deletions src/LanguageServer.SemanticModel.Xml/XSPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public sealed class XSPath // TODO: IEquitable<XSPath> (plus equality / inequali
/// The root path.
/// </summary>
public static readonly XSPath Root = new XSPath(
ancestorSegments: ImmutableList<XSPathSegment>.Empty,
segments: ImmutableList<XSPathSegment>.Empty.Add(XSPathSegment.Root)
ancestorSegments: [],
segments: [XSPathSegment.Root]
);

/// <summary>
Expand Down Expand Up @@ -123,7 +123,6 @@ public sealed class XSPath // TODO: IEquitable<XSPath> (plus equality / inequali

_parent = parent;
_ancestorSegments = _parent._segments;
;
_segments = _ancestorSegments.Add(leaf);
}

Expand Down Expand Up @@ -380,7 +379,7 @@ public XSPath Append(string pathOrSegment)
if (pathOrSegment == null)
throw new ArgumentNullException(nameof(pathOrSegment));

if (pathOrSegment.IndexOf(PathSeparatorCharacter) != -1)
if (pathOrSegment.Contains(PathSeparatorCharacter))
{
return Append(
Parse(pathOrSegment)
Expand Down Expand Up @@ -428,10 +427,7 @@ public static XSPath FromSegment(XSPathSegment pathSegment)
if (pathSegment == XSPathSegment.Root)
return Root;

return new XSPath(
ImmutableList<XSPathSegment>.Empty,
ImmutableList<XSPathSegment>.Empty.Add(pathSegment)
);
return new XSPath([], [pathSegment]);
}

/// <summary>
Expand Down Expand Up @@ -510,7 +506,7 @@ public static IEnumerable<XSPathSegment> ParseSegments(string path)
if (path[^1] == PathSeparatorCharacter)
path = path[..^1];

string[] pathSegments = path.Split(new char[] { PathSeparatorCharacter });
string[] pathSegments = path.Split(PathSeparatorCharacter);
foreach (string pathSegment in pathSegments)
yield return XSPathSegment.Create(pathSegment);
}
Expand Down
4 changes: 2 additions & 2 deletions src/LanguageServer/LoggingModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace MSBuildProjectTools.LanguageServer
{
using Logging;

using Serilog.Core;
using LanguageServer = OmniSharp.Extensions.LanguageServer.Server.LanguageServer;

/// <summary>
Expand Down Expand Up @@ -72,7 +72,7 @@ static ILogger CreateLogger(IComponentContext componentContext)
LoggerConfiguration loggerConfiguration = CreateDefaultLoggerConfiguration(languageServerConfiguration)
.WriteTo.LanguageServer(languageServer, languageServerConfiguration.Logging.LevelSwitch);

ILogger logger = loggerConfiguration.CreateLogger();
Logger logger = loggerConfiguration.CreateLogger();
Log.Logger = logger;

logger.Verbose("Logger initialized.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Xunit;
using Xunit.Abstractions;

namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
{
Expand All @@ -9,19 +8,7 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// Tests for parsing of MSBuild comparison expressions.
/// </summary>
public class ComparisonParserTests
: ParserTests
{
/// <summary>
/// Create a new comparison expression parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public ComparisonParserTests(ITestOutputHelper testOutput)
: base(testOutput)
{
}

/// <summary>
/// Verify that the Compare parser can successfully parse the specified input.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,12 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// <summary>
/// Tests for parsing of MSBuild list expressions.
/// </summary>
public class ExpressionListParserTests
public class ExpressionListParserTests(ITestOutputHelper testOutput)
{
/// <summary>
/// Create a new expression list parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public ExpressionListParserTests(ITestOutputHelper testOutput)
{
if (testOutput == null)
throw new ArgumentNullException(nameof(testOutput));

TestOutput = testOutput;
}

/// <summary>
/// Output for the current test.
/// </summary>
ITestOutputHelper TestOutput { get; }
ITestOutputHelper TestOutput { get; } = testOutput;

/// <summary>
/// Verify that the SimpleListItem parser can successfully parse the specified input.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Xunit;
using Xunit.Abstractions;

namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
{
Expand All @@ -11,19 +10,7 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// Tests for parsing of MSBuild expressions.
/// </summary>
public class ExpressionParserTests
: ParserTests
{
/// <summary>
/// Create a new expression parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public ExpressionParserTests(ITestOutputHelper testOutput)
: base(testOutput)
{
}

/// <summary>
/// Verify that the Expression parser can successfully parse an expression.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Linq;
using Xunit;
using Xunit.Abstractions;

namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
{
Expand All @@ -10,19 +9,7 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// Tests for parsing of MSBuild function-call expressions.
/// </summary>
public class FunctionCallParserTests
: ParserTests
{
/// <summary>
/// Create a new function-call expression parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public FunctionCallParserTests(ITestOutputHelper testOutput)
: base(testOutput)
{
}

/// <summary>
/// Verify that the FunctionCall parser can successfully parse a global function-call expression with a single argument.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Xunit;
using Xunit.Abstractions;

namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
{
Expand All @@ -9,19 +8,7 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// Tests for parsing of MSBuild grouped expressions.
/// </summary>
public class GroupedExpressionTests
: ParserTests
{
/// <summary>
/// Create a new grouped expression parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public GroupedExpressionTests(ITestOutputHelper testOutput)
: base(testOutput)
{
}

/// <summary>
/// Verify that the GroupedExpression parser can successfully parse a logical unary expression composed of a comparison between quoted strings.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using Xunit;
using Xunit.Abstractions;

namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
{
Expand All @@ -11,25 +9,6 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// </summary>
public class ItemGroupParserTests
{
/// <summary>
/// Create a new item group expression parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public ItemGroupParserTests(ITestOutputHelper testOutput)
{
if (testOutput == null)
throw new ArgumentNullException(nameof(testOutput));

TestOutput = testOutput;
}

/// <summary>
/// Output for the current test.
/// </summary>
ITestOutputHelper TestOutput { get; }

/// <summary>
/// Verify that the ItemGroup parser can successfully parse the specified input.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using Xunit;
using Xunit.Abstractions;

namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
{
Expand All @@ -11,25 +9,6 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// </summary>
public class ItemGroupTransformParserTests
{
/// <summary>
/// Create a new item group expression parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public ItemGroupTransformParserTests(ITestOutputHelper testOutput)
{
if (testOutput == null)
throw new ArgumentNullException(nameof(testOutput));

TestOutput = testOutput;
}

/// <summary>
/// Output for the current test.
/// </summary>
ITestOutputHelper TestOutput { get; }

/// <summary>
/// Verify that the ItemGroupTransform parser can successfully parse the specified input.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using Xunit;
using Xunit.Abstractions;

namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
{
Expand All @@ -12,25 +10,6 @@ namespace MSBuildProjectTools.LanguageServer.Tests.ExpressionTests
/// </summary>
public class ItemMetadataParserTests
{
/// <summary>
/// Create a new item metadata expression parser test-suite.
/// </summary>
/// <param name="testOutput">
/// Output for the current test.
/// </param>
public ItemMetadataParserTests(ITestOutputHelper testOutput)
{
if (testOutput == null)
throw new ArgumentNullException(nameof(testOutput));

TestOutput = testOutput;
}

/// <summary>
/// Output for the current test.
/// </summary>
ITestOutputHelper TestOutput { get; }

/// <summary>
/// Verify that the ItemMetadata parser can successfully parse an unqualified item metadata expression.
/// </summary>
Expand Down
Loading

0 comments on commit 2f7b6e3

Please sign in to comment.