Skip to content

Commit ee04c9a

Browse files
Added some additional nullable annotations (#380)
* Added some additional nullable annotations * fixed compiler error * fixed bug in identifier
1 parent 9cebed1 commit ee04c9a

40 files changed

+118
-110
lines changed

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,27 @@ For more information about using the `DebugAdapterClient` / `DebugAdapterServer`
4343
<!-- badges -->
4444

4545
<!-- history badges -->
46-
| Azure Pipelines | GitHub Actions |
47-
| --------------------------------------------------------- | --------------------------------- |
48-
| [![azurepipelines-badge]][azurepipelines] | [![github-badge]][github] |
46+
| Azure Pipelines | GitHub Actions |
47+
| --------------- | -------------- |
48+
| [![azurepipelines-badge]][azurepipelines] | [![github-badge]][github] |
4949
| [![azurepipelines-history-badge]][azurepipelines-history] | [![github-history-badge]][github] |
5050
<!-- history badges -->
5151

5252
<!-- nuget packages -->
53-
| Package | NuGet |
54-
| --------------------------------------------- | ---------------------------------------------------------------------------------------------- |
55-
| OmniSharp.Extensions.DebugAdapter | [![nuget-version-hefb6om79mfg-badge]![nuget-downloads-hefb6om79mfg-badge]][nuget-hefb6om79mfg] |
56-
| OmniSharp.Extensions.DebugAdapter.Client | [![nuget-version-94qjnkon/cda-badge]![nuget-downloads-94qjnkon/cda-badge]][nuget-94qjnkon/cda] |
57-
| OmniSharp.Extensions.DebugAdapter.Server | [![nuget-version-f/4jrt4grmdg-badge]![nuget-downloads-f/4jrt4grmdg-badge]][nuget-f/4jrt4grmdg] |
58-
| OmniSharp.Extensions.DebugAdapter.Shared | [![nuget-version-2fkn0yzdbhmg-badge]![nuget-downloads-2fkn0yzdbhmg-badge]][nuget-2fkn0yzdbhmg] |
59-
| OmniSharp.Extensions.DebugAdapter.Testing | [![nuget-version-jppuysmkpfcw-badge]![nuget-downloads-jppuysmkpfcw-badge]][nuget-jppuysmkpfcw] |
60-
| OmniSharp.Extensions.JsonRpc | [![nuget-version-a1bmkwyotvkg-badge]![nuget-downloads-a1bmkwyotvkg-badge]][nuget-a1bmkwyotvkg] |
61-
| OmniSharp.Extensions.JsonRpc.Testing | [![nuget-version-punkj7/efvjq-badge]![nuget-downloads-punkj7/efvjq-badge]][nuget-punkj7/efvjq] |
62-
| OmniSharp.Extensions.LanguageClient | [![nuget-version-fclou9t/p2ba-badge]![nuget-downloads-fclou9t/p2ba-badge]][nuget-fclou9t/p2ba] |
63-
| OmniSharp.Extensions.LanguageProtocol | [![nuget-version-vddj9t6jnirq-badge]![nuget-downloads-vddj9t6jnirq-badge]][nuget-vddj9t6jnirq] |
53+
| Package | NuGet |
54+
| ------- | ----- |
55+
| OmniSharp.Extensions.DebugAdapter | [![nuget-version-hefb6om79mfg-badge]![nuget-downloads-hefb6om79mfg-badge]][nuget-hefb6om79mfg] |
56+
| OmniSharp.Extensions.DebugAdapter.Client | [![nuget-version-94qjnkon/cda-badge]![nuget-downloads-94qjnkon/cda-badge]][nuget-94qjnkon/cda] |
57+
| OmniSharp.Extensions.DebugAdapter.Server | [![nuget-version-f/4jrt4grmdg-badge]![nuget-downloads-f/4jrt4grmdg-badge]][nuget-f/4jrt4grmdg] |
58+
| OmniSharp.Extensions.DebugAdapter.Shared | [![nuget-version-2fkn0yzdbhmg-badge]![nuget-downloads-2fkn0yzdbhmg-badge]][nuget-2fkn0yzdbhmg] |
59+
| OmniSharp.Extensions.DebugAdapter.Testing | [![nuget-version-jppuysmkpfcw-badge]![nuget-downloads-jppuysmkpfcw-badge]][nuget-jppuysmkpfcw] |
60+
| OmniSharp.Extensions.JsonRpc | [![nuget-version-a1bmkwyotvkg-badge]![nuget-downloads-a1bmkwyotvkg-badge]][nuget-a1bmkwyotvkg] |
61+
| OmniSharp.Extensions.JsonRpc.Testing | [![nuget-version-punkj7/efvjq-badge]![nuget-downloads-punkj7/efvjq-badge]][nuget-punkj7/efvjq] |
62+
| OmniSharp.Extensions.LanguageClient | [![nuget-version-fclou9t/p2ba-badge]![nuget-downloads-fclou9t/p2ba-badge]][nuget-fclou9t/p2ba] |
63+
| OmniSharp.Extensions.LanguageProtocol | [![nuget-version-vddj9t6jnirq-badge]![nuget-downloads-vddj9t6jnirq-badge]][nuget-vddj9t6jnirq] |
6464
| OmniSharp.Extensions.LanguageProtocol.Testing | [![nuget-version-md8c3c/bo/8g-badge]![nuget-downloads-md8c3c/bo/8g-badge]][nuget-md8c3c/bo/8g] |
65-
| OmniSharp.Extensions.LanguageServer | [![nuget-version-fkxlzvrmzpbw-badge]![nuget-downloads-fkxlzvrmzpbw-badge]][nuget-fkxlzvrmzpbw] |
66-
| OmniSharp.Extensions.LanguageServer.Shared | [![nuget-version-4htmykprzq1a-badge]![nuget-downloads-4htmykprzq1a-badge]][nuget-4htmykprzq1a] |
65+
| OmniSharp.Extensions.LanguageServer | [![nuget-version-fkxlzvrmzpbw-badge]![nuget-downloads-fkxlzvrmzpbw-badge]][nuget-fkxlzvrmzpbw] |
66+
| OmniSharp.Extensions.LanguageServer.Shared | [![nuget-version-4htmykprzq1a-badge]![nuget-downloads-4htmykprzq1a-badge]][nuget-4htmykprzq1a] |
6767
<!-- nuget packages -->
6868

6969
## License
@@ -93,10 +93,10 @@ This project is supported by the [.NET Foundation](http://www.dotnetfoundation.o
9393
[github-license-badge]: https://img.shields.io/github/license/OmniSharp/csharp-language-server-protocol.svg?style=flat "License"
9494
[codecov]: https://codecov.io/gh/OmniSharp/csharp-language-server-protocol
9595
[codecov-badge]: https://img.shields.io/codecov/c/github/OmniSharp/csharp-language-server-protocol.svg?color=E03997&label=codecov&logo=codecov&logoColor=E03997&style=flat "Code Coverage"
96-
[azurepipelines]: https://dev.azure.com/omnisharp/Build/_build/latest?definitionId=1&branchName=master
97-
[azurepipelines-badge]: https://img.shields.io/azure-devops/build/omnisharp/Build/1.svg?color=98C6FF&label=azure%20pipelines&logo=azuredevops&logoColor=98C6FF&style=flat "Azure Pipelines Status"
98-
[azurepipelines-history]: https://dev.azure.com/omnisharp/Build/_build?definitionId=1&branchName=master
99-
[azurepipelines-history-badge]: https://buildstats.info/azurepipelines/chart/omnisharp/Build/1?includeBuildsFromPullRequest=false "Azure Pipelines History"
96+
[azurepipelines]: https://dev.azure.com/omnisharp/Builds/_build/latest?definitionId=1&branchName=master
97+
[azurepipelines-badge]: https://img.shields.io/azure-devops/build/omnisharp/Builds/1.svg?color=98C6FF&label=azure%20pipelines&logo=azuredevops&logoColor=98C6FF&style=flat "Azure Pipelines Status"
98+
[azurepipelines-history]: https://dev.azure.com/omnisharp/Builds/_build?definitionId=1&branchName=master
99+
[azurepipelines-history-badge]: https://buildstats.info/azurepipelines/chart/omnisharp/Builds/1?includeBuildsFromPullRequest=false "Azure Pipelines History"
100100
[github]: https://github.com/OmniSharp/csharp-language-server-protocol/actions?query=workflow%3Aci
101101
[github-badge]: https://img.shields.io/github/workflow/status/OmniSharp/csharp-language-server-protocol/ci.svg?label=github&logo=github&color=b845fc&logoColor=b845fc&style=flat "GitHub Actions Status"
102102
[github-history-badge]: https://buildstats.info/github/chart/OmniSharp/csharp-language-server-protocol?includeBuildsFromPullRequest=false "GitHub Actions History"

src/Client/Configuration/ChainedConfigurationProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void Load() { }
7272
/// <returns>The child keys.</returns>
7373
public IEnumerable<string> GetChildKeys(
7474
IEnumerable<string> earlierKeys,
75-
string parentPath)
75+
string? parentPath)
7676
{
7777
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
7878
var children = section.GetChildren();

src/Client/Configuration/ChainedConfigurationSource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
1313
/// <summary>
1414
/// The chained configuration.
1515
/// </summary>
16-
public IConfiguration Configuration { get; set; }
16+
public IConfiguration Configuration { get; set; } = null!;
1717

1818
/// <summary>
1919
/// Whether the chained configuration should be disposed when the

src/Client/DefaultLanguageClientFacade.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ internal class DefaultLanguageClientFacade : LanguageProtocolProxy, ILanguageCli
1919
private readonly Lazy<IWorkspaceLanguageClient> _workspace;
2020
private readonly Lazy<IHandlersManager> _handlersManager;
2121
private readonly TextDocumentIdentifiers _textDocumentIdentifiers;
22-
private readonly IInsanceHasStarted _insanceHasStarted;
23-
private ILanguageClient _languageClient;
22+
private readonly IInsanceHasStarted _instanceHasStarted;
23+
private ILanguageClient? _languageClient;
2424

2525
public DefaultLanguageClientFacade(
2626
IResponseRouter requestRouter,
@@ -34,7 +34,7 @@ public DefaultLanguageClientFacade(
3434
Lazy<IWorkspaceLanguageClient> workspace,
3535
Lazy<IHandlersManager> handlersManager,
3636
TextDocumentIdentifiers textDocumentIdentifiers,
37-
IInsanceHasStarted insanceHasStarted
37+
IInsanceHasStarted instanceHasStarted
3838
) : base(requestRouter, resolverContext, progressManager, languageProtocolSettings)
3939
{
4040
_textDocument = textDocument;
@@ -44,7 +44,7 @@ IInsanceHasStarted insanceHasStarted
4444
_workspace = workspace;
4545
_handlersManager = handlersManager;
4646
_textDocumentIdentifiers = textDocumentIdentifiers;
47-
_insanceHasStarted = insanceHasStarted;
47+
_instanceHasStarted = instanceHasStarted;
4848
}
4949

5050
public ITextDocumentLanguageClient TextDocument => _textDocument.Value;
@@ -58,7 +58,7 @@ public IDisposable Register(Action<ILanguageClientRegistry> registryAction)
5858
var manager = new CompositeHandlersManager(_handlersManager.Value);
5959
registryAction(new LangaugeClientRegistry(ResolverContext, manager, _textDocumentIdentifiers));
6060
var result = manager.GetDisposable();
61-
if (_insanceHasStarted.Started)
61+
if (_instanceHasStarted.Started)
6262
{
6363
if (_languageClient == null) throw new NotSupportedException("Language client has not yet started... you shouldn't be here.");
6464
LanguageClientHelpers.InitHandlers(_languageClient, result);

src/Client/LanguageClientServiceCollectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ internal static IContainer AddLanguageClientInternals(this IContainer container,
8080

8181
if (providedConfiguration != null)
8282
{
83-
builder.CustomAddConfiguration(providedConfiguration.ImplementationInstance as IConfiguration);
83+
builder.CustomAddConfiguration((providedConfiguration.ImplementationInstance as IConfiguration)!);
8484
}
8585

8686
//var didChangeConfigurationProvider = _.GetRequiredService<DidChangeConfigurationProvider>();

src/Dap.Client/Configuration/ChainedConfigurationProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void Load() { }
7272
/// <returns>The child keys.</returns>
7373
public IEnumerable<string> GetChildKeys(
7474
IEnumerable<string> earlierKeys,
75-
string parentPath)
75+
string? parentPath)
7676
{
7777
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
7878
var children = section.GetChildren();

src/Dap.Client/Configuration/ChainedConfigurationSource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
1313
/// <summary>
1414
/// The chained configuration.
1515
/// </summary>
16-
public IConfiguration Configuration { get; set; }
16+
public IConfiguration Configuration { get; set; } = null!;
1717

1818
/// <summary>
1919
/// Whether the chained configuration should be disposed when the

src/Dap.Client/DebugAdapterClientServiceCollectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ internal static IContainer AddDebugAdapterClientInternals(this IContainer contai
7575

7676
if (providedConfiguration != null)
7777
{
78-
builder.CustomAddConfiguration(providedConfiguration.ImplementationInstance as IConfiguration);
78+
builder.CustomAddConfiguration((providedConfiguration.ImplementationInstance as IConfiguration)!);
7979
}
8080

8181
return builder.Build();

src/Dap.Server/Configuration/ChainedConfigurationProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void Load() { }
7272
/// <returns>The child keys.</returns>
7373
public IEnumerable<string> GetChildKeys(
7474
IEnumerable<string> earlierKeys,
75-
string parentPath)
75+
string? parentPath)
7676
{
7777
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
7878
var children = section.GetChildren();

src/Dap.Server/Configuration/ChainedConfigurationSource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
1313
/// <summary>
1414
/// The chained configuration.
1515
/// </summary>
16-
public IConfiguration Configuration { get; set; }
16+
public IConfiguration Configuration { get; set; } = null!;
1717

1818
/// <summary>
1919
/// Whether the chained configuration should be disposed when the

src/Dap.Server/DebugAdapterServerServiceCollectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal static IContainer AddDebugAdapterServerInternals(this IContainer contai
5959

6060
if (providedConfiguration != null)
6161
{
62-
builder.CustomAddConfiguration(providedConfiguration.ImplementationInstance as IConfiguration);
62+
builder.CustomAddConfiguration((providedConfiguration.ImplementationInstance as IConfiguration)!);
6363
}
6464

6565
return builder.Build();

src/JsonRpc.Generators/GenerateHandlerMethodsGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Task<RichGenerationResult> GenerateRichAsync(TransformationContext contex
4949
{
5050
var requestType = GetRequestType(symbol);
5151
var responseType = GetResponseType(handlerInterface);
52-
methods.AddRange(HandleRequest(handlerInterface, symbol, requestType, responseType, registry, additionalUsings));
52+
methods.AddRange(HandleRequest(handlerInterface, symbol, requestType, responseType!, registry, additionalUsings));
5353
}
5454
}
5555

src/JsonRpc/NoopResponseRouter.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public void SendNotification(IRequest request)
3333

3434
public IResponseRouterReturns SendRequest(string method) => new Impl();
3535

36-
public Task<TResponse> SendRequest<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken) => Task.FromResult<TResponse>(default);
36+
public Task<TResponse> SendRequest<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken) => Task.FromResult<TResponse>(default!);
3737

3838
bool IResponseRouter.TryGetRequest(long id, [NotNullWhen(true)] out string method, [NotNullWhen(true)] out TaskCompletionSource<JToken> pendingTask)
3939
{
40-
method = default;
41-
pendingTask = default;
40+
method = default!;
41+
pendingTask = default!;
4242
return false;
4343
}
4444

src/JsonRpc/RequestRouterBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static async Task InnerRoute(IServiceScopeFactory serviceScopeFactory, TDescript
6464
context.Descriptor = descriptor;
6565
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
6666

67-
await HandleNotification(mediator, descriptor, @params ?? Activator.CreateInstance(descriptor.Params), token).ConfigureAwait(false);
67+
await HandleNotification(mediator, descriptor, @params ?? Activator.CreateInstance(descriptor.Params!), token).ConfigureAwait(false);
6868
}
6969
}
7070

src/Protocol/DocumentUri.Internal.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private static void _validateUri(DocumentUri ret, bool? strict)
3939

4040
// scheme, https://tools.ietf.org/html/rfc3986#section-3.1
4141
// ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
42-
if (!string.IsNullOrWhiteSpace(ret.Scheme) && !SchemePattern.IsMatch(ret.Scheme))
42+
if (!string.IsNullOrWhiteSpace(ret.Scheme) && !SchemePattern.IsMatch(ret.Scheme!))
4343
{
4444
throw new UriFormatException("Scheme contains illegal characters.");
4545
}
@@ -170,11 +170,7 @@ private static string EncodeUriComponentFast(string uriComponent, bool allowSlas
170170
}
171171

172172
// check if we write into a new string (by default we try to return the param)
173-
if (res != null)
174-
{
175-
res ??= new StringBuilder();
176-
res.Append(uriComponent[pos]);
177-
}
173+
res?.Append(uriComponent[pos]);
178174
}
179175
else
180176
{

src/Protocol/LanguageProtocolDelegatingHandlers.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ CancellationToken cancellationToken
401401

402402
var subject = new AsyncSubject<TItem>();
403403
// in the event nothing is emitted...
404-
subject.OnNext(default);
404+
subject.OnNext(default!);
405405
_handler(request, subject, _capability, cancellationToken);
406406
return await subject.Select(_factory).ToTask(cancellationToken).ConfigureAwait(false);
407407
}
@@ -471,7 +471,7 @@ async Task<TResponse> IRequestHandler<TParams, TResponse>.Handle(TParams request
471471

472472
var subject = new AsyncSubject<TItem>();
473473
// in the event nothing is emitted...
474-
subject.OnNext(default);
474+
subject.OnNext(default!);
475475
_handler(request, subject, cancellationToken);
476476
return await subject.Select(_factory).ToTask(cancellationToken).ConfigureAwait(false);
477477
}
@@ -533,7 +533,7 @@ async Task<TResponse> IRequestHandler<TParams, TResponse>.Handle(TParams request
533533

534534
var subject = new AsyncSubject<TItem>();
535535
// in the event nothing is emitted...
536-
subject.OnNext(default);
536+
subject.OnNext(default!);
537537
_handler(request, _capability, subject, cancellationToken);
538538
return await subject.Select(_factory).ToTask(cancellationToken).ConfigureAwait(false);
539539
}
@@ -591,7 +591,7 @@ async Task<TResponse> IRequestHandler<TParams, TResponse>.Handle(TParams request
591591

592592
var subject = new AsyncSubject<TItem>();
593593
// in the event nothing is emitted...
594-
subject.OnNext(default);
594+
subject.OnNext(default!);
595595
_handler(request, subject, cancellationToken);
596596
return await subject.Select(_factory).ToTask(cancellationToken).ConfigureAwait(false);
597597
}

src/Protocol/LanguageProtocolRpcOptionsBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public T AddTextDocumentIdentifier<TI>() where TI : ITextDocumentIdentifier
3535

3636
public ISerializer Serializer { get; set; } = new Serializer(ClientVersion.Lsp3);
3737
internal bool AddDefaultLoggingProvider { get; set; }
38-
internal Action<ILoggingBuilder> LoggingBuilderAction { get; set; } = _ => { };
39-
internal Action<IConfigurationBuilder> ConfigurationBuilderAction { get; set; } = _ => { };
38+
internal Action<ILoggingBuilder>? LoggingBuilderAction { get; set; } = _ => { };
39+
internal Action<IConfigurationBuilder>? ConfigurationBuilderAction { get; set; } = _ => { };
4040
}
4141
}

src/Protocol/Models/DocumentSelector.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public DocumentSelector(params DocumentFilter[] items) : base(items)
3030

3131
public static implicit operator DocumentSelector(List<DocumentFilter> items) => new DocumentSelector(items);
3232

33-
public static implicit operator string(DocumentSelector documentSelector) =>
33+
public static implicit operator string(DocumentSelector? documentSelector) =>
3434
documentSelector is not null ? string.Join(", ", documentSelector.Select(x => (string) x)) : string.Empty;
3535

3636
public bool IsMatch(TextDocumentAttributes attributes) => this.Any(z => z.IsMatch(attributes));

src/Protocol/Models/Position.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ other is not null &&
3434
Line == other.Line &&
3535
Character == other.Character;
3636

37-
public int CompareTo(Position other)
37+
public int CompareTo(Position? other)
3838
{
3939
if (ReferenceEquals(this, other)) return 0;
4040
if (ReferenceEquals(null, other)) return 1;
4141
var lineComparison = Line.CompareTo(other.Line);
4242
return lineComparison != 0 ? lineComparison : Character.CompareTo(other.Character);
4343
}
4444

45-
public int CompareTo(object obj)
45+
public int CompareTo(object? obj)
4646
{
4747
if (ReferenceEquals(null, obj)) return 1;
4848
if (ReferenceEquals(this, obj)) return 0;

src/Protocol/Models/Proposals/ISemanticTokenResult.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public interface ISemanticTokenResult
1313
/// send a delta.
1414
/// </summary>
1515
[Optional]
16-
public string ResultId { get; set; }
16+
public string? ResultId { get; set; }
1717
}
1818
}

src/Protocol/Models/Proposals/SemanticTokensFullOrDelta.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public SemanticTokensFullOrDelta(SemanticTokensFullOrDeltaPartialResult partialR
2727

2828
if (partialResult.IsDelta)
2929
{
30-
Delta = new SemanticTokensDelta(partialResult.Delta) {
31-
Edits = partialResult.Delta.Edits
30+
Delta = new SemanticTokensDelta(partialResult.Delta!) {
31+
Edits = partialResult.Delta!.Edits
3232
};
3333
}
3434

3535
if (partialResult.IsFull)
3636
{
37-
Full = new SemanticTokens(partialResult.Full);
37+
Full = new SemanticTokens(partialResult.Full!);
3838
}
3939
}
4040

0 commit comments

Comments
 (0)