Skip to content

Commit 2ae01eb

Browse files
committed
Clear build warnings from sample/ and test/ folders.
Mainly acheived this by disabling nullable checking in files with nullability errors.
1 parent 4ab18ec commit 2ae01eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+165
-91
lines changed

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<ImplicitUsings>enable</ImplicitUsings>
2424
<!-- Remove once we drop the net6.0 tfm -->
2525
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
26+
<NoWarn>$(NoWarn);CS4014</NoWarn>
2627
</PropertyGroup>
2728
<PropertyGroup>
2829
<EmbedUntrackedSources>true</EmbedUntrackedSources>

sample/SampleServer/Program.cs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using OmniSharp.Extensions.LanguageServer.Server;
99
using Serilog;
1010

11+
#nullable disable
12+
1113
// ReSharper disable UnusedParameter.Local
1214

1315
namespace SampleServer

sample/SampleServer/SemanticTokensHandler.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
1111
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
1212

13+
#nullable disable
14+
1315
namespace SampleServer
1416
{
1517
#pragma warning disable 618
@@ -22,23 +24,23 @@ public SemanticTokensHandler(ILogger<SemanticTokensHandler> logger)
2224
_logger = logger;
2325
}
2426

25-
public override async Task<SemanticTokens?> Handle(
27+
public override async Task<SemanticTokens> Handle(
2628
SemanticTokensParams request, CancellationToken cancellationToken
2729
)
2830
{
2931
var result = await base.Handle(request, cancellationToken).ConfigureAwait(false);
3032
return result;
3133
}
3234

33-
public override async Task<SemanticTokens?> Handle(
35+
public override async Task<SemanticTokens> Handle(
3436
SemanticTokensRangeParams request, CancellationToken cancellationToken
3537
)
3638
{
3739
var result = await base.Handle(request, cancellationToken).ConfigureAwait(false);
3840
return result;
3941
}
4042

41-
public override async Task<SemanticTokensFullOrDelta?> Handle(
43+
public override async Task<SemanticTokensFullOrDelta> Handle(
4244
SemanticTokensDeltaParams request,
4345
CancellationToken cancellationToken
4446
)

sample/SampleServer/TextDocumentHandler.cs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using OmniSharp.Extensions.LanguageServer.Protocol.Workspace;
1616
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;
1717

18+
#nullable disable
1819

1920
#pragma warning disable CS0618
2021

src/Protocol/Features/Workspace/ExecuteCommandFeature.cs

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
using OmniSharp.Extensions.LanguageServer.Protocol.Shared;
1818
using ISerializer = OmniSharp.Extensions.JsonRpc.ISerializer;
1919

20+
#nullable disable
21+
22+
#pragma warning restore format
2023
// ReSharper disable once CheckNamespace
2124
namespace OmniSharp.Extensions.LanguageServer.Protocol
2225
{

test/Client.Tests/ClientTests.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Xunit.Abstractions;
1212
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;
1313

14+
#nullable disable
1415

1516
namespace OmniSharp.Extensions.LanguageServer.Client.Tests
1617
{
@@ -686,8 +687,8 @@ public async Task Diagnostics_Success()
686687

687688
var receivedDiagnosticsNotification = new TaskCompletionSource<object>();
688689

689-
DocumentUri? actualDocumentUri = null;
690-
List<Diagnostic>? actualDiagnostics = null;
690+
DocumentUri actualDocumentUri = null;
691+
List<Diagnostic> actualDiagnostics = null;
691692

692693
var (_, server) = await Initialize(
693694
clientOptions =>

test/Client.Tests/Logging/TestOutputLogger.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using Microsoft.Extensions.Logging;
44
using Xunit.Abstractions;
55

6+
#nullable disable
7+
68
namespace OmniSharp.Extensions.LanguageServer.Client.Tests.Logging
79
{
810
/// <summary>
@@ -101,7 +103,7 @@ public TestOutputLogger(ITestOutputHelper testOutput, string name, LogLevel mini
101103
/// <param name="formatter">
102104
/// A delegate that formats the log message.
103105
/// </param>
104-
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
106+
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
105107
{
106108
if (logLevel < _minimumLevel)
107109
return;

test/Client.Tests/TestBase.cs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using Xunit;
99
using Xunit.Abstractions;
1010

11+
#nullable disable
12+
1113
namespace OmniSharp.Extensions.LanguageServer.Client.Tests
1214
{
1315
/// <summary>

test/Dap.Tests/DapOutputHandlerTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public class DapOutputHandlerTests
1919
private static OutputHandler NewHandler(PipeWriter writer)
2020
{
2121
return new OutputHandler(
22+
#pragma warning disable CS0618
2223
writer, new DapProtocolSerializer(), new[] { new AlwaysOutputFilter() }, Scheduler.Immediate, NullLogger<OutputHandler>.Instance
24+
#pragma warning restore CS0618
2325
);
2426
}
2527

test/Dap.Tests/DebugAdapterSpecifictionRecieverTests.cs

+4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ public class DebugAdapterSpecificationReceiverTests
1717
public void ShouldRespond_AsExpected(string json, Renor[] request)
1818
{
1919
var receiver = new DapReceiver();
20+
#pragma warning disable CS0618
2021
var inSerializer = new DapProtocolSerializer();
2122
var outSerializer = new DapProtocolSerializer();
23+
#pragma warning restore CS0618
2224
var (requests, _) = receiver.GetRequests(JToken.Parse(json));
2325
var result = requests.ToArray();
2426
request.Length.Should().Be(result.Length);
@@ -36,7 +38,9 @@ public void ShouldRespond_AsExpected(string json, Renor[] request)
3638
[Fact]
3739
public void Should_Camel_Case_As_Expected()
3840
{
41+
#pragma warning disable CS0618
3942
var serializer = new DapProtocolSerializer();
43+
#pragma warning restore CS0618
4044
var response = serializer.SerializeObject(
4145
new InitializeResponse
4246
{

test/Dap.Tests/FoundationTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using Xunit;
2222
using Xunit.Abstractions;
2323

24+
#nullable disable
25+
2426
namespace Dap.Tests
2527
{
2628
public class FoundationTests

test/Dap.Tests/Integration/Fixtures/DebugAdapterProtocolFixture.cs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
using Xunit;
1111
using Xunit.Abstractions;
1212

13+
#nullable disable
14+
1315
namespace Dap.Tests.Integration.Fixtures
1416
{
1517
public class DebugAdapterProtocolFixture<TConfigureFixture, TConfigureClient, TConfigureServer> : DebugAdapterProtocolTestBase, IAsyncLifetime

test/Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<PreserveCompilationContext>true</PreserveCompilationContext>
66
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
77
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
8+
<NoWarn>$(NoWarn);CS1998</NoWarn>
89

910
<Include>[Omnisharp.*]*</Include>
1011

test/Generation.Tests/GenerationHelpers.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
//using OmniSharp.Extensions.DebugAdapter.Protocol.Client;
2121
//using OmniSharp.Extensions.LanguageServer.Protocol.Server;
2222

23+
#nullable disable
24+
2325
namespace Generation.Tests
2426
{
2527
public static class GenerationHelpers
@@ -227,7 +229,7 @@ public NotSureWhatToCallYou(ISyntaxReceiver syntaxReceiver)
227229
_syntaxReceiver = syntaxReceiver;
228230
}
229231

230-
public override void Visit(SyntaxNode? node)
232+
public override void Visit(SyntaxNode node)
231233
{
232234
if (node == null) return;
233235
_syntaxReceiver.OnVisitSyntaxNode(node);

test/JsonRpc.Tests/InputHandlerTests.cs

+12-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
using Xunit;
1919
using Xunit.Abstractions;
2020

21+
#nullable disable
22+
2123
namespace JsonRpc.Tests
2224
{
2325
[Collection("InputHandlers")]
@@ -35,7 +37,7 @@ private InputHandler NewHandler(
3537
PipeReader inputStream,
3638
IOutputHandler outputHandler,
3739
IReceiver receiver,
38-
IRequestRouter<IHandlerDescriptor?> requestRouter,
40+
IRequestRouter<IHandlerDescriptor> requestRouter,
3941
ILoggerFactory loggerFactory,
4042
IResponseRouter responseRouter,
4143
RequestInvoker requestInvoker
@@ -64,7 +66,7 @@ public async Task Should_Pass_In_Requests()
6466

6567
using var handler = NewHandler(
6668
pipe.Reader, outputHandler, receiver,
67-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
69+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
6870
_loggerFactory, Substitute.For<IResponseRouter>(),
6971
Substitute.For<RequestInvoker>()
7072
);
@@ -90,7 +92,7 @@ public async Task Should_Handle_Multiple_Requests_At_Once()
9092

9193
using var handler = NewHandler(
9294
pipe.Reader, outputHandler, receiver,
93-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
95+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
9496
_loggerFactory, Substitute.For<IResponseRouter>(),
9597
Substitute.For<RequestInvoker>()
9698
);
@@ -132,7 +134,7 @@ public async Task Should_Handle_Different_Additional_Headers_and_Whitespace(stri
132134

133135
using var handler = NewHandler(
134136
pipe.Reader, outputHandler, receiver,
135-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
137+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
136138
_loggerFactory, Substitute.For<IResponseRouter>(),
137139
Substitute.For<RequestInvoker>()
138140
);
@@ -160,7 +162,7 @@ public async Task Should_Handle_Multiple_Requests_Back_To_Back()
160162

161163
using var handler = NewHandler(
162164
pipe.Reader, outputHandler, receiver,
163-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
165+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
164166
_loggerFactory, Substitute.For<IResponseRouter>(),
165167
Substitute.For<RequestInvoker>()
166168
);
@@ -193,7 +195,7 @@ public async Task Should_Handle_Multiple_Requests_In_Pieces()
193195

194196
using var handler = NewHandler(
195197
pipe.Reader, outputHandler, receiver,
196-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
198+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
197199
_loggerFactory, Substitute.For<IResponseRouter>(),
198200
Substitute.For<RequestInvoker>()
199201
);
@@ -236,7 +238,7 @@ public async Task Should_Handle_Multiple_Chunked_Requests(string content)
236238

237239
using var handler = NewHandler(
238240
pipe.Reader, outputHandler, receiver,
239-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
241+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
240242
_loggerFactory, Substitute.For<IResponseRouter>(),
241243
Substitute.For<RequestInvoker>()
242244
);
@@ -271,7 +273,7 @@ public async Task Should_Handle_Header_Terminiator_Being_Incomplete()
271273

272274
using var handler = NewHandler(
273275
pipe.Reader, outputHandler, receiver,
274-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
276+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
275277
_loggerFactory, Substitute.For<IResponseRouter>(),
276278
Substitute.For<RequestInvoker>()
277279
);
@@ -324,7 +326,7 @@ public async Task ShouldPassAdditionalUtf8EncodedRequests(string data)
324326

325327
using var handler = NewHandler(
326328
pipe.Reader, outputHandler, receiver,
327-
Substitute.For<IRequestRouter<IHandlerDescriptor?>>(),
329+
Substitute.For<IRequestRouter<IHandlerDescriptor>>(),
328330
_loggerFactory, Substitute.For<IResponseRouter>(),
329331
Substitute.For<RequestInvoker>()
330332
);
@@ -361,7 +363,7 @@ public async Task Should_Parse_Logs(string name, Func<PipeReader> createPipeRead
361363

362364
var reader = createPipeReader();
363365
var receiver = new Receiver();
364-
var incomingRequestRouter = Substitute.For<IRequestRouter<IHandlerDescriptor?>>();
366+
var incomingRequestRouter = Substitute.For<IRequestRouter<IHandlerDescriptor>>();
365367
var outputHandler = Substitute.For<IOutputHandler>();
366368
var responseRouter = Substitute.For<IResponseRouter>();
367369
var requestInvoker = Substitute.For<RequestInvoker>();

test/JsonRpc.Tests/ResponseRouterTests.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using OmniSharp.Extensions.JsonRpc.Serialization;
1212
using Xunit;
1313

14+
#nullable disable
15+
1416
namespace JsonRpc.Tests
1517
{
1618
public class ResponseRouterTests
@@ -61,7 +63,7 @@ public async Task WorksWithUnitType()
6163
}
6264

6365
[Fact]
64-
public async Task WorksWithNotification()
66+
public void WorksWithNotification()
6567
{
6668
var outputHandler = Substitute.For<IOutputHandler>();
6769
var router = new ResponseRouter(new Lazy<IOutputHandler>(() => outputHandler), new JsonRpcSerializer(), new AssemblyScanningHandlerTypeDescriptorProvider(new [] { typeof(AssemblyScanningHandlerTypeDescriptorProvider).Assembly, typeof(HandlerResolverTests).Assembly }));

test/Lsp.Integration.Tests/DisableDefaultsTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ await TestHelper.DelayUntil(
9292
action.Received(1).Invoke(Arg.Any<DidChangeWorkspaceFoldersParams>());
9393
return true;
9494
}
95-
catch (ReceivedCallsException e)
95+
catch (ReceivedCallsException)
9696
{
9797
return false;
9898
}
@@ -144,7 +144,7 @@ await TestHelper.DelayUntil(
144144
action.Received(1).Invoke(Arg.Is<DidChangeConfigurationParams>(z => Equals(z.Settings, JValue.CreateNull())));
145145
return true;
146146
}
147-
catch (ReceivedCallsException e)
147+
catch (ReceivedCallsException)
148148
{
149149
return false;
150150
}

test/Lsp.Integration.Tests/ErroringHandlingTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
using Xunit;
1414
using Xunit.Abstractions;
1515

16+
#nullable disable
17+
1618
namespace Lsp.Integration.Tests
1719
{
1820
public class ErroringHandlingTests : LanguageProtocolTestBase

test/Lsp.Integration.Tests/ExecuteTypedCommandTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Xunit;
1919
using Xunit.Abstractions;
2020

21+
#nullable disable
2122

2223
namespace Lsp.Integration.Tests
2324
{

test/Lsp.Integration.Tests/ExtensionTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
using Xunit;
2121
using Xunit.Abstractions;
2222

23+
#nullable disable
24+
2325
namespace Lsp.Integration.Tests
2426
{
2527
public class ExtensionTests : LanguageProtocolTestBase

test/Lsp.Integration.Tests/FileOperationsTests.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@
1515
using Xunit;
1616
using Xunit.Abstractions;
1717

18+
#nullable disable
19+
1820
namespace Lsp.Integration.Tests
1921
{
2022
public class FileOperationsTests : LanguageProtocolTestBase
2123
{
2224
private readonly Action<DidCreateFilesParams> _didCreateFileHandler = Substitute.For<Action<DidCreateFilesParams>>();
2325

24-
private readonly Func<WillCreateFilesParams, Task<WorkspaceEdit?>> _willCreateFileHandler =
25-
Substitute.For<Func<WillCreateFilesParams, Task<WorkspaceEdit?>>>();
26+
private readonly Func<WillCreateFilesParams, Task<WorkspaceEdit>> _willCreateFileHandler =
27+
Substitute.For<Func<WillCreateFilesParams, Task<WorkspaceEdit>>>();
2628

2729
private readonly Action<DidRenameFilesParams> _didRenameFileHandler = Substitute.For<Action<DidRenameFilesParams>>();
2830

29-
private readonly Func<WillRenameFilesParams, Task<WorkspaceEdit?>> _willRenameFileHandler =
30-
Substitute.For<Func<WillRenameFilesParams, Task<WorkspaceEdit?>>>();
31+
private readonly Func<WillRenameFilesParams, Task<WorkspaceEdit>> _willRenameFileHandler =
32+
Substitute.For<Func<WillRenameFilesParams, Task<WorkspaceEdit>>>();
3133

3234
private readonly Action<DidDeleteFilesParams> _didDeleteFileHandler = Substitute.For<Action<DidDeleteFilesParams>>();
3335

34-
private readonly Func<WillDeleteFilesParams, Task<WorkspaceEdit?>> _willDeleteFileHandler =
35-
Substitute.For<Func<WillDeleteFilesParams, Task<WorkspaceEdit?>>>();
36+
private readonly Func<WillDeleteFilesParams, Task<WorkspaceEdit>> _willDeleteFileHandler =
37+
Substitute.For<Func<WillDeleteFilesParams, Task<WorkspaceEdit>>>();
3638

3739
public FileOperationsTests(ITestOutputHelper outputHelper) : base(new JsonRpcTestOptions().ConfigureForXUnit(outputHelper, LogEventLevel.Verbose))
3840
{

test/Lsp.Integration.Tests/Fixtures/DefaultClient.cs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using OmniSharp.Extensions.LanguageServer.Client;
33
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
44

5+
#nullable disable
6+
57
namespace Lsp.Integration.Tests.Fixtures
68
{
79
public sealed class DefaultClient : IConfigureLanguageClientOptions

0 commit comments

Comments
 (0)