Skip to content

Cleanup warnings and bump minor versions #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Tools.MSBuild;
using Rocket.Surgery.Nuke;
using Rocket.Surgery.Nuke.DotNetCore;

[PublicAPI]
Expand Down Expand Up @@ -37,7 +36,10 @@ public partial class Solution : NukeBuild,
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode
/// </summary>
public static int Main() => Execute<Solution>(x => x.Default);
public static int Main()
{
return Execute<Solution>(x => x.Default);
}

[OptionalGitRepository] public GitRepository? GitRepository { get; }

Expand Down
8 changes: 3 additions & 5 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ function cleanupcode(filenames) {

module.exports = {
'*.cs': filenames => {
return [`echo "'${filenames.join(`' '`)}'" | dotnet format --include -`].concat(cleanupcode(filenames));
return [`echo "'${filenames.join(`' '`)}'" | dotnet format --include -`]; //.concat(cleanupcode(filenames));
},
'*.{csproj,targets,props,xml}': filenames =>
forEachChunk(filenames, chunk => [`prettier --write '${chunk.join(`' '`)}'`]),
'*.{js,ts,jsx,tsx,json,yml,yaml}': filenames =>
forEachChunk(filenames, chunk => [`prettier --write '${chunk.join(`' '`)}'`]),
'*.{csproj,targets,props,xml}': filenames => forEachChunk(filenames, chunk => [`prettier --write '${chunk.join(`' '`)}'`]),
'*.{js,ts,jsx,tsx,json,yml,yaml}': filenames => forEachChunk(filenames, chunk => [`prettier --write '${chunk.join(`' '`)}'`]),
};
6 changes: 3 additions & 3 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
<PackageReference Update="XunitXml.TestLogger" Version="3.0.70" />
<PackageReference Update="coverlet.collector" Version="3.1.2" />
<PackageReference Update="coverlet.msbuild" Version="3.1.2" />
<PackageReference Update="System.Reactive" Version="4.4.1" />
<PackageReference Update="System.Collections.Immutable" Version="1.7.1" />
<PackageReference Update="System.Reactive" Version="5.0.0" />
<PackageReference Update="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Update="System.Threading.Channels" Version="4.7.1" />
<PackageReference Update="Microsoft.Reactive.Testing" Version="4.4.1" />
<PackageReference Update="MediatR" Version="8.1.0" />
<PackageReference Update="Bogus" Version="34.0.1" />
<PackageReference Update="Snapper" Version="2.3.1" />
<PackageReference Update="Xunit.SkippableFact" Version="1.4.13" />
<PackageReference Update="Nerdbank.Streams" Version="2.6.81" />
<PackageReference Update="Nerdbank.Streams" Version="2.8.57" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageReference Update="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
<PackageReference Update="DryIoc.Internal" Version="4.8.6" />
Expand Down
58 changes: 40 additions & 18 deletions sample/SampleServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
using OmniSharp.Extensions.LanguageServer.Server;
using Serilog;

// ReSharper disable UnusedParameter.Local

namespace SampleServer
{
internal class Program
{
private static void Main(string[] args) => MainAsync(args).Wait();
private static void Main(string[] args)
{
MainAsync(args).Wait();
}

private static async Task MainAsync(string[] args)
{
Expand Down Expand Up @@ -51,9 +56,11 @@ private static async Task MainAsync(string[] args)
.WithHandler<SemanticTokensHandler>()
.WithServices(x => x.AddLogging(b => b.SetMinimumLevel(LogLevel.Trace)))
.WithServices(
services => {
services =>
{
services.AddSingleton(
provider => {
provider =>
{
var loggerFactory = provider.GetService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<Foo>();

Expand All @@ -63,20 +70,24 @@ private static async Task MainAsync(string[] args)
}
);
services.AddSingleton(
new ConfigurationItem {
new ConfigurationItem
{
Section = "typescript",
}
).AddSingleton(
new ConfigurationItem {
new ConfigurationItem
{
Section = "terminal",
}
);
}
)
.OnInitialize(
async (server, request, token) => {
async (server, request, token) =>
{
var manager = server.WorkDoneManager.For(
request, new WorkDoneProgressBegin {
request, new WorkDoneProgressBegin
{
Title = "Server is starting...",
Percentage = 10,
}
Expand All @@ -86,17 +97,20 @@ private static async Task MainAsync(string[] args)
await Task.Delay(2000).ConfigureAwait(false);

manager.OnNext(
new WorkDoneProgressReport {
new WorkDoneProgressReport
{
Percentage = 20,
Message = "loading in progress"
}
);
}
)
.OnInitialized(
async (server, request, response, token) => {
async (server, request, response, token) =>
{
workDone.OnNext(
new WorkDoneProgressReport {
new WorkDoneProgressReport
{
Percentage = 40,
Message = "loading almost done",
}
Expand All @@ -105,7 +119,8 @@ private static async Task MainAsync(string[] args)
await Task.Delay(2000).ConfigureAwait(false);

workDone.OnNext(
new WorkDoneProgressReport {
new WorkDoneProgressReport
{
Message = "loading done",
Percentage = 100,
}
Expand All @@ -114,8 +129,10 @@ private static async Task MainAsync(string[] args)
}
)
.OnStarted(
async (languageServer, token) => {
using var manager = await languageServer.WorkDoneManager.Create(new WorkDoneProgressBegin { Title = "Doing some work..." }).ConfigureAwait(false);
async (languageServer, token) =>
{
using var manager = await languageServer.WorkDoneManager.Create(new WorkDoneProgressBegin { Title = "Doing some work..." })
.ConfigureAwait(false);

manager.OnNext(new WorkDoneProgressReport { Message = "doing things..." });
await Task.Delay(10000).ConfigureAwait(false);
Expand All @@ -125,9 +142,11 @@ private static async Task MainAsync(string[] args)

var logger = languageServer.Services.GetService<ILogger<Foo>>();
var configuration = await languageServer.Configuration.GetConfiguration(
new ConfigurationItem {
new ConfigurationItem
{
Section = "typescript",
}, new ConfigurationItem {
}, new ConfigurationItem
{
Section = "terminal",
}
).ConfigureAwait(false);
Expand All @@ -138,15 +157,15 @@ private static async Task MainAsync(string[] args)
baseConfig.Add(config.Key, config.Value);
}

logger.LogInformation("Base Config: {Config}", baseConfig);
logger.LogInformation("Base Config: {@Config}", baseConfig);

var scopedConfig = new JObject();
foreach (var config in configuration.AsEnumerable())
{
scopedConfig.Add(config.Key, config.Value);
}

logger.LogInformation("Scoped Config: {Config}", scopedConfig);
logger.LogInformation("Scoped Config: {@Config}", scopedConfig);
}
)
).ConfigureAwait(false);
Expand All @@ -165,6 +184,9 @@ public Foo(ILogger<Foo> logger)
_logger = logger;
}

public void SayFoo() => _logger.LogInformation("Fooooo!");
public void SayFoo()
{
_logger.LogInformation("Fooooo!");
}
}
}
43 changes: 27 additions & 16 deletions sample/SampleServer/SemanticTokensHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

namespace SampleServer
{
Expand All @@ -18,8 +17,10 @@ public class SemanticTokensHandler : SemanticTokensHandlerBase
{
private readonly ILogger _logger;

public SemanticTokensHandler(ILogger<SemanticTokensHandler> logger) =>
public SemanticTokensHandler(ILogger<SemanticTokensHandler> logger)
{
_logger = logger;
}

public override async Task<SemanticTokens?> Handle(
SemanticTokensParams request, CancellationToken cancellationToken
Expand Down Expand Up @@ -57,7 +58,7 @@ CancellationToken cancellationToken
var content = await File.ReadAllTextAsync(DocumentUri.GetFileSystemPath(identifier), cancellationToken).ConfigureAwait(false);
await Task.Yield();

foreach (var (line, text) in content.Split('\n').Select((text, line) => (line, text)))
foreach (var (line, text) in content.Split('\n').Select((text, line) => ( line, text )))
{
var parts = text.TrimEnd().Split(';', ' ', '.', '"', '(', ')');
var index = 0;
Expand All @@ -73,8 +74,10 @@ CancellationToken cancellationToken
}

protected override Task<SemanticTokensDocument>
GetSemanticTokensDocument(ITextDocumentIdentifierParams @params, CancellationToken cancellationToken) =>
Task.FromResult(new SemanticTokensDocument(RegistrationOptions.Legend));
GetSemanticTokensDocument(ITextDocumentIdentifierParams @params, CancellationToken cancellationToken)
{
return Task.FromResult(new SemanticTokensDocument(RegistrationOptions.Legend));
}


private IEnumerable<T> RotateEnum<T>(IEnumerable<T> values)
Expand All @@ -86,17 +89,25 @@ private IEnumerable<T> RotateEnum<T>(IEnumerable<T> values)
}
}

protected override SemanticTokensRegistrationOptions CreateRegistrationOptions(SemanticTokensCapability capability, ClientCapabilities clientCapabilities) => new SemanticTokensRegistrationOptions {
DocumentSelector = DocumentSelector.ForLanguage("csharp"),
Legend = new SemanticTokensLegend() {
TokenModifiers = capability.TokenModifiers,
TokenTypes = capability.TokenTypes
},
Full = new SemanticTokensCapabilityRequestFull {
Delta = true
},
Range = true
};
protected override SemanticTokensRegistrationOptions CreateRegistrationOptions(
SemanticTokensCapability capability, ClientCapabilities clientCapabilities
)
{
return new SemanticTokensRegistrationOptions
{
DocumentSelector = DocumentSelector.ForLanguage("csharp"),
Legend = new SemanticTokensLegend
{
TokenModifiers = capability.TokenModifiers,
TokenTypes = capability.TokenTypes
},
Full = new SemanticTokensCapabilityRequestFull
{
Delta = true
},
Range = true
};
}
}
#pragma warning restore 618
}
Loading