Skip to content

Added some additional nullable annotations #380

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
Oct 4, 2020
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
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ For more information about using the `DebugAdapterClient` / `DebugAdapterServer`
<!-- badges -->

<!-- history badges -->
| Azure Pipelines | GitHub Actions |
| --------------------------------------------------------- | --------------------------------- |
| [![azurepipelines-badge]][azurepipelines] | [![github-badge]][github] |
| Azure Pipelines | GitHub Actions |
| --------------- | -------------- |
| [![azurepipelines-badge]][azurepipelines] | [![github-badge]][github] |
| [![azurepipelines-history-badge]][azurepipelines-history] | [![github-history-badge]][github] |
<!-- history badges -->

<!-- nuget packages -->
| Package | NuGet |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| OmniSharp.Extensions.DebugAdapter | [![nuget-version-hefb6om79mfg-badge]![nuget-downloads-hefb6om79mfg-badge]][nuget-hefb6om79mfg] |
| OmniSharp.Extensions.DebugAdapter.Client | [![nuget-version-94qjnkon/cda-badge]![nuget-downloads-94qjnkon/cda-badge]][nuget-94qjnkon/cda] |
| OmniSharp.Extensions.DebugAdapter.Server | [![nuget-version-f/4jrt4grmdg-badge]![nuget-downloads-f/4jrt4grmdg-badge]][nuget-f/4jrt4grmdg] |
| OmniSharp.Extensions.DebugAdapter.Shared | [![nuget-version-2fkn0yzdbhmg-badge]![nuget-downloads-2fkn0yzdbhmg-badge]][nuget-2fkn0yzdbhmg] |
| OmniSharp.Extensions.DebugAdapter.Testing | [![nuget-version-jppuysmkpfcw-badge]![nuget-downloads-jppuysmkpfcw-badge]][nuget-jppuysmkpfcw] |
| OmniSharp.Extensions.JsonRpc | [![nuget-version-a1bmkwyotvkg-badge]![nuget-downloads-a1bmkwyotvkg-badge]][nuget-a1bmkwyotvkg] |
| OmniSharp.Extensions.JsonRpc.Testing | [![nuget-version-punkj7/efvjq-badge]![nuget-downloads-punkj7/efvjq-badge]][nuget-punkj7/efvjq] |
| OmniSharp.Extensions.LanguageClient | [![nuget-version-fclou9t/p2ba-badge]![nuget-downloads-fclou9t/p2ba-badge]][nuget-fclou9t/p2ba] |
| OmniSharp.Extensions.LanguageProtocol | [![nuget-version-vddj9t6jnirq-badge]![nuget-downloads-vddj9t6jnirq-badge]][nuget-vddj9t6jnirq] |
| Package | NuGet |
| ------- | ----- |
| OmniSharp.Extensions.DebugAdapter | [![nuget-version-hefb6om79mfg-badge]![nuget-downloads-hefb6om79mfg-badge]][nuget-hefb6om79mfg] |
| OmniSharp.Extensions.DebugAdapter.Client | [![nuget-version-94qjnkon/cda-badge]![nuget-downloads-94qjnkon/cda-badge]][nuget-94qjnkon/cda] |
| OmniSharp.Extensions.DebugAdapter.Server | [![nuget-version-f/4jrt4grmdg-badge]![nuget-downloads-f/4jrt4grmdg-badge]][nuget-f/4jrt4grmdg] |
| OmniSharp.Extensions.DebugAdapter.Shared | [![nuget-version-2fkn0yzdbhmg-badge]![nuget-downloads-2fkn0yzdbhmg-badge]][nuget-2fkn0yzdbhmg] |
| OmniSharp.Extensions.DebugAdapter.Testing | [![nuget-version-jppuysmkpfcw-badge]![nuget-downloads-jppuysmkpfcw-badge]][nuget-jppuysmkpfcw] |
| OmniSharp.Extensions.JsonRpc | [![nuget-version-a1bmkwyotvkg-badge]![nuget-downloads-a1bmkwyotvkg-badge]][nuget-a1bmkwyotvkg] |
| OmniSharp.Extensions.JsonRpc.Testing | [![nuget-version-punkj7/efvjq-badge]![nuget-downloads-punkj7/efvjq-badge]][nuget-punkj7/efvjq] |
| OmniSharp.Extensions.LanguageClient | [![nuget-version-fclou9t/p2ba-badge]![nuget-downloads-fclou9t/p2ba-badge]][nuget-fclou9t/p2ba] |
| OmniSharp.Extensions.LanguageProtocol | [![nuget-version-vddj9t6jnirq-badge]![nuget-downloads-vddj9t6jnirq-badge]][nuget-vddj9t6jnirq] |
| OmniSharp.Extensions.LanguageProtocol.Testing | [![nuget-version-md8c3c/bo/8g-badge]![nuget-downloads-md8c3c/bo/8g-badge]][nuget-md8c3c/bo/8g] |
| OmniSharp.Extensions.LanguageServer | [![nuget-version-fkxlzvrmzpbw-badge]![nuget-downloads-fkxlzvrmzpbw-badge]][nuget-fkxlzvrmzpbw] |
| OmniSharp.Extensions.LanguageServer.Shared | [![nuget-version-4htmykprzq1a-badge]![nuget-downloads-4htmykprzq1a-badge]][nuget-4htmykprzq1a] |
| OmniSharp.Extensions.LanguageServer | [![nuget-version-fkxlzvrmzpbw-badge]![nuget-downloads-fkxlzvrmzpbw-badge]][nuget-fkxlzvrmzpbw] |
| OmniSharp.Extensions.LanguageServer.Shared | [![nuget-version-4htmykprzq1a-badge]![nuget-downloads-4htmykprzq1a-badge]][nuget-4htmykprzq1a] |
<!-- nuget packages -->

## License
Expand Down Expand Up @@ -93,10 +93,10 @@ This project is supported by the [.NET Foundation](http://www.dotnetfoundation.o
[github-license-badge]: https://img.shields.io/github/license/OmniSharp/csharp-language-server-protocol.svg?style=flat "License"
[codecov]: https://codecov.io/gh/OmniSharp/csharp-language-server-protocol
[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"
[azurepipelines]: https://dev.azure.com/omnisharp/Build/_build/latest?definitionId=1&branchName=master
[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"
[azurepipelines-history]: https://dev.azure.com/omnisharp/Build/_build?definitionId=1&branchName=master
[azurepipelines-history-badge]: https://buildstats.info/azurepipelines/chart/omnisharp/Build/1?includeBuildsFromPullRequest=false "Azure Pipelines History"
[azurepipelines]: https://dev.azure.com/omnisharp/Builds/_build/latest?definitionId=1&branchName=master
[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"
[azurepipelines-history]: https://dev.azure.com/omnisharp/Builds/_build?definitionId=1&branchName=master
[azurepipelines-history-badge]: https://buildstats.info/azurepipelines/chart/omnisharp/Builds/1?includeBuildsFromPullRequest=false "Azure Pipelines History"
[github]: https://github.com/OmniSharp/csharp-language-server-protocol/actions?query=workflow%3Aci
[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"
[github-history-badge]: https://buildstats.info/github/chart/OmniSharp/csharp-language-server-protocol?includeBuildsFromPullRequest=false "GitHub Actions History"
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Configuration/ChainedConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Load() { }
/// <returns>The child keys.</returns>
public IEnumerable<string> GetChildKeys(
IEnumerable<string> earlierKeys,
string parentPath)
string? parentPath)
{
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
var children = section.GetChildren();
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Configuration/ChainedConfigurationSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
/// <summary>
/// The chained configuration.
/// </summary>
public IConfiguration Configuration { get; set; }
public IConfiguration Configuration { get; set; } = null!;

/// <summary>
/// Whether the chained configuration should be disposed when the
Expand Down
10 changes: 5 additions & 5 deletions src/Client/DefaultLanguageClientFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ internal class DefaultLanguageClientFacade : LanguageProtocolProxy, ILanguageCli
private readonly Lazy<IWorkspaceLanguageClient> _workspace;
private readonly Lazy<IHandlersManager> _handlersManager;
private readonly TextDocumentIdentifiers _textDocumentIdentifiers;
private readonly IInsanceHasStarted _insanceHasStarted;
private ILanguageClient _languageClient;
private readonly IInsanceHasStarted _instanceHasStarted;
private ILanguageClient? _languageClient;

public DefaultLanguageClientFacade(
IResponseRouter requestRouter,
Expand All @@ -34,7 +34,7 @@ public DefaultLanguageClientFacade(
Lazy<IWorkspaceLanguageClient> workspace,
Lazy<IHandlersManager> handlersManager,
TextDocumentIdentifiers textDocumentIdentifiers,
IInsanceHasStarted insanceHasStarted
IInsanceHasStarted instanceHasStarted
) : base(requestRouter, resolverContext, progressManager, languageProtocolSettings)
{
_textDocument = textDocument;
Expand All @@ -44,7 +44,7 @@ IInsanceHasStarted insanceHasStarted
_workspace = workspace;
_handlersManager = handlersManager;
_textDocumentIdentifiers = textDocumentIdentifiers;
_insanceHasStarted = insanceHasStarted;
_instanceHasStarted = instanceHasStarted;
}

public ITextDocumentLanguageClient TextDocument => _textDocument.Value;
Expand All @@ -58,7 +58,7 @@ public IDisposable Register(Action<ILanguageClientRegistry> registryAction)
var manager = new CompositeHandlersManager(_handlersManager.Value);
registryAction(new LangaugeClientRegistry(ResolverContext, manager, _textDocumentIdentifiers));
var result = manager.GetDisposable();
if (_insanceHasStarted.Started)
if (_instanceHasStarted.Started)
{
if (_languageClient == null) throw new NotSupportedException("Language client has not yet started... you shouldn't be here.");
LanguageClientHelpers.InitHandlers(_languageClient, result);
Expand Down
2 changes: 1 addition & 1 deletion src/Client/LanguageClientServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal static IContainer AddLanguageClientInternals(this IContainer container,

if (providedConfiguration != null)
{
builder.CustomAddConfiguration(providedConfiguration.ImplementationInstance as IConfiguration);
builder.CustomAddConfiguration((providedConfiguration.ImplementationInstance as IConfiguration)!);
}

//var didChangeConfigurationProvider = _.GetRequiredService<DidChangeConfigurationProvider>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Load() { }
/// <returns>The child keys.</returns>
public IEnumerable<string> GetChildKeys(
IEnumerable<string> earlierKeys,
string parentPath)
string? parentPath)
{
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
var children = section.GetChildren();
Expand Down
2 changes: 1 addition & 1 deletion src/Dap.Client/Configuration/ChainedConfigurationSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
/// <summary>
/// The chained configuration.
/// </summary>
public IConfiguration Configuration { get; set; }
public IConfiguration Configuration { get; set; } = null!;

/// <summary>
/// Whether the chained configuration should be disposed when the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal static IContainer AddDebugAdapterClientInternals(this IContainer contai

if (providedConfiguration != null)
{
builder.CustomAddConfiguration(providedConfiguration.ImplementationInstance as IConfiguration);
builder.CustomAddConfiguration((providedConfiguration.ImplementationInstance as IConfiguration)!);
}

return builder.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Load() { }
/// <returns>The child keys.</returns>
public IEnumerable<string> GetChildKeys(
IEnumerable<string> earlierKeys,
string parentPath)
string? parentPath)
{
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
var children = section.GetChildren();
Expand Down
2 changes: 1 addition & 1 deletion src/Dap.Server/Configuration/ChainedConfigurationSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
/// <summary>
/// The chained configuration.
/// </summary>
public IConfiguration Configuration { get; set; }
public IConfiguration Configuration { get; set; } = null!;

/// <summary>
/// Whether the chained configuration should be disposed when the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal static IContainer AddDebugAdapterServerInternals(this IContainer contai

if (providedConfiguration != null)
{
builder.CustomAddConfiguration(providedConfiguration.ImplementationInstance as IConfiguration);
builder.CustomAddConfiguration((providedConfiguration.ImplementationInstance as IConfiguration)!);
}

return builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc.Generators/GenerateHandlerMethodsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Task<RichGenerationResult> GenerateRichAsync(TransformationContext contex
{
var requestType = GetRequestType(symbol);
var responseType = GetResponseType(handlerInterface);
methods.AddRange(HandleRequest(handlerInterface, symbol, requestType, responseType, registry, additionalUsings));
methods.AddRange(HandleRequest(handlerInterface, symbol, requestType, responseType!, registry, additionalUsings));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/JsonRpc/NoopResponseRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public void SendNotification(IRequest request)

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

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

bool IResponseRouter.TryGetRequest(long id, [NotNullWhen(true)] out string method, [NotNullWhen(true)] out TaskCompletionSource<JToken> pendingTask)
{
method = default;
pendingTask = default;
method = default!;
pendingTask = default!;
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc/RequestRouterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static async Task InnerRoute(IServiceScopeFactory serviceScopeFactory, TDescript
context.Descriptor = descriptor;
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();

await HandleNotification(mediator, descriptor, @params ?? Activator.CreateInstance(descriptor.Params), token).ConfigureAwait(false);
await HandleNotification(mediator, descriptor, @params ?? Activator.CreateInstance(descriptor.Params!), token).ConfigureAwait(false);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/Protocol/DocumentUri.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static void _validateUri(DocumentUri ret, bool? strict)

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

// check if we write into a new string (by default we try to return the param)
if (res != null)
{
res ??= new StringBuilder();
res.Append(uriComponent[pos]);
}
res?.Append(uriComponent[pos]);
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions src/Protocol/LanguageProtocolDelegatingHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ CancellationToken cancellationToken

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

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

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

var subject = new AsyncSubject<TItem>();
// in the event nothing is emitted...
subject.OnNext(default);
subject.OnNext(default!);
_handler(request, subject, cancellationToken);
return await subject.Select(_factory).ToTask(cancellationToken).ConfigureAwait(false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Protocol/LanguageProtocolRpcOptionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public T AddTextDocumentIdentifier<TI>() where TI : ITextDocumentIdentifier

public ISerializer Serializer { get; set; } = new Serializer(ClientVersion.Lsp3);
internal bool AddDefaultLoggingProvider { get; set; }
internal Action<ILoggingBuilder> LoggingBuilderAction { get; set; } = _ => { };
internal Action<IConfigurationBuilder> ConfigurationBuilderAction { get; set; } = _ => { };
internal Action<ILoggingBuilder>? LoggingBuilderAction { get; set; } = _ => { };
internal Action<IConfigurationBuilder>? ConfigurationBuilderAction { get; set; } = _ => { };
}
}
2 changes: 1 addition & 1 deletion src/Protocol/Models/DocumentSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public DocumentSelector(params DocumentFilter[] items) : base(items)

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

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

public bool IsMatch(TextDocumentAttributes attributes) => this.Any(z => z.IsMatch(attributes));
Expand Down
4 changes: 2 additions & 2 deletions src/Protocol/Models/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ other is not null &&
Line == other.Line &&
Character == other.Character;

public int CompareTo(Position other)
public int CompareTo(Position? other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
var lineComparison = Line.CompareTo(other.Line);
return lineComparison != 0 ? lineComparison : Character.CompareTo(other.Character);
}

public int CompareTo(object obj)
public int CompareTo(object? obj)
{
if (ReferenceEquals(null, obj)) return 1;
if (ReferenceEquals(this, obj)) return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/Models/Proposals/ISemanticTokenResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public interface ISemanticTokenResult
/// send a delta.
/// </summary>
[Optional]
public string ResultId { get; set; }
public string? ResultId { get; set; }
}
}
6 changes: 3 additions & 3 deletions src/Protocol/Models/Proposals/SemanticTokensFullOrDelta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public SemanticTokensFullOrDelta(SemanticTokensFullOrDeltaPartialResult partialR

if (partialResult.IsDelta)
{
Delta = new SemanticTokensDelta(partialResult.Delta) {
Edits = partialResult.Delta.Edits
Delta = new SemanticTokensDelta(partialResult.Delta!) {
Edits = partialResult.Delta!.Edits
};
}

if (partialResult.IsFull)
{
Full = new SemanticTokens(partialResult.Full);
Full = new SemanticTokens(partialResult.Full!);
}
}

Expand Down
Loading