Skip to content

Commit ca8e186

Browse files
Added some additional nullable annotations
1 parent 9cebed1 commit ca8e186

39 files changed

+97
-89
lines changed

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

src/Protocol/Models/Proposals/SemanticTokensFullOrDeltaPartialResult.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics.CodeAnalysis;
23
using Newtonsoft.Json;
34
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters;
45

src/Protocol/Models/TextDocumentIdentifier.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override bool Equals(object? obj)
4242

4343
public static implicit operator TextDocumentIdentifier(string uri) => new TextDocumentIdentifier { Uri = uri };
4444

45-
private string DebuggerDisplay => Uri?.ToString()!;
45+
private string DebuggerDisplay => Uri.ToString()!;
4646

4747
/// <inheritdoc />
4848
public override string ToString() => DebuggerDisplay;

src/Protocol/Progress/IProgressManager.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ IRequestProgressObservable<TItem, TResult> MonitorUntil<TItem, TResult>(
2222
IRequestProgressObservable<IEnumerable<TItem>, TResponse> MonitorUntil<TResponse, TItem>(
2323
IPartialItemsRequest<TResponse, TItem> request, Func<IEnumerable<TItem>, TResponse> factory, CancellationToken cancellationToken
2424
)
25-
where TResponse : IEnumerable<TItem>;
25+
where TResponse : IEnumerable<TItem>?;
2626

2727
IRequestProgressObservable<TItem> MonitorUntil<TItem>(IPartialItemsRequest<Container<TItem>, TItem> request, CancellationToken cancellationToken);
2828

2929
IProgressObserver<T> For<T>(ProgressToken token, CancellationToken cancellationToken);
3030
IProgressObserver<TItem> For<TResponse, TItem>(IPartialItemRequest<TResponse, TItem> request, CancellationToken cancellationToken);
3131

3232
IProgressObserver<IEnumerable<TItem>> For<TResponse, TItem>(IPartialItemsRequest<TResponse, TItem> request, CancellationToken cancellationToken)
33-
where TResponse : IEnumerable<TItem>;
33+
where TResponse : IEnumerable<TItem>?;
3434
}
3535
}

src/Protocol/Progress/ProgressManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public IProgressObserver<TItem> For<TResponse, TItem>(IPartialItemRequest<TRespo
179179
}
180180

181181
public IProgressObserver<IEnumerable<TItem>> For<TResponse, TItem>(IPartialItemsRequest<TResponse, TItem> request, CancellationToken cancellationToken)
182-
where TResponse : IEnumerable<TItem>
182+
where TResponse : IEnumerable<TItem>?
183183
{
184184
if (request.PartialResultToken == null) return ProgressObserver<IEnumerable<TItem>>.Noop;
185185
if (_activeObservers.TryGetValue(request.PartialResultToken, out var o) && o is IProgressObserver<IEnumerable<TItem>> observer)

src/Protocol/Serialization/Converters/ProgressTokenConverter.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
namespace OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters
66
{
7-
internal class ProgressTokenConverter : JsonConverter<ProgressToken>
7+
internal class ProgressTokenConverter : JsonConverter<ProgressToken?>
88
{
9-
public override void WriteJson(JsonWriter writer, ProgressToken value, JsonSerializer serializer)
9+
public override void WriteJson(JsonWriter writer, ProgressToken? value, JsonSerializer serializer)
1010
{
1111
if (value.IsLong) serializer.Serialize(writer, value.Long);
1212
else if (value.IsString) serializer.Serialize(writer, value.String);
1313
else writer.WriteNull();
1414
}
1515

16-
public override ProgressToken ReadJson(JsonReader reader, Type objectType, ProgressToken existingValue, bool hasExistingValue, JsonSerializer serializer)
16+
public override ProgressToken? ReadJson(JsonReader reader, Type objectType, ProgressToken? existingValue, bool hasExistingValue, JsonSerializer serializer)
1717
{
1818
if (reader.TokenType == JsonToken.Integer)
1919
{

src/Protocol/Serialization/Converters/RangeOrPlaceholderRangeConverter.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
namespace OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters
88
{
9-
internal class RangeOrPlaceholderRangeConverter : JsonConverter<RangeOrPlaceholderRange>
9+
internal class RangeOrPlaceholderRangeConverter : JsonConverter<RangeOrPlaceholderRange?>
1010
{
11-
public override void WriteJson(JsonWriter writer, RangeOrPlaceholderRange value, JsonSerializer serializer)
11+
public override void WriteJson(JsonWriter writer, RangeOrPlaceholderRange? value, JsonSerializer serializer)
1212
{
13-
if (value.IsRange)
13+
if (value?.IsRange == true)
1414
{
1515
serializer.Serialize(writer, value.Range);
1616
}
17-
else if (value.IsPlaceholderRange)
17+
else if (value?.IsPlaceholderRange == true)
1818
{
1919
serializer.Serialize(writer, value.PlaceholderRange);
2020
}
@@ -24,13 +24,13 @@ public override void WriteJson(JsonWriter writer, RangeOrPlaceholderRange value,
2424
}
2525
}
2626

27-
public override RangeOrPlaceholderRange ReadJson(
28-
JsonReader reader, Type objectType, RangeOrPlaceholderRange existingValue, bool hasExistingValue, JsonSerializer serializer
27+
public override RangeOrPlaceholderRange? ReadJson(
28+
JsonReader reader, Type objectType, RangeOrPlaceholderRange? existingValue, bool hasExistingValue, JsonSerializer serializer
2929
)
3030
{
3131
if (reader.TokenType is JsonToken.StartObject)
3232
{
33-
var obj = JToken.ReadFrom(reader) as JObject;
33+
var obj = (JToken.ReadFrom(reader) as JObject)!;
3434
return obj.ContainsKey("placeholder")
3535
? new RangeOrPlaceholderRange(obj.ToObject<PlaceholderRange>())
3636
: new RangeOrPlaceholderRange(obj.ToObject<Range>());

0 commit comments

Comments
 (0)