diff --git a/.editorconfig b/.editorconfig
index d22dc0e99..a3d8b54ab 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,4 +1,4 @@
-root=true
+root=true
[*]
charset=utf-8
indent_style=space
@@ -8,58 +8,56 @@ insert_final_newline=true
max_line_length=180
end_of_line=crlf
-[*.{cs,cshtml}]
-charset=utf-8
-indent_style=space
-indent_size=4
-insert_final_newline=true
-
-[*.{js,ts,vue}]
-indent_style=space
-indent_size=4
-insert_final_newline=true
-
-[*.{xml,yml,yaml}]
-indent_style=space
-indent_size=2
-insert_final_newline=true
-
-[*.json]
-indent_style=space
-indent_size=4
-insert_final_newline=true
-
-[*.{xml,csproj,props,targets}]
-indent_style=space
-
-[{*.har,*.inputactions,*.jsb2,*.jsb3,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}]
-indent_style=space
-indent_size=2
-
-[*.{appxmanifest,asax,ascx,aspx,build,cg,cginc,compute,cs,cshtml,dtd,fs,fsi,fsscript,fsx,hlsl,hlsli,hlslinc,master,ml,mli,nuspec,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
-indent_style=space
-indent_size=4
-tab_width=4
-
# Microsoft .NET properties
csharp_new_line_before_members_in_object_initializers=false
+csharp_new_line_before_open_brace=types,methods,properties,indexers,events,event_accessors,control_blocks,anonymous_types,object_collections,array_initializers,local_functions
csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
csharp_space_between_parentheses=expressions
-csharp_style_var_elsewhere=true:suggestion
-csharp_style_var_for_built_in_types=true:suggestion
-csharp_style_var_when_type_is_apparent=true:suggestion
+csharp_style_expression_bodied_accessors=true:suggestion
+csharp_style_expression_bodied_constructors=true:none
+csharp_style_expression_bodied_indexers=true:none
+csharp_style_expression_bodied_methods=true:none
+csharp_style_expression_bodied_operators=true:none
+csharp_style_expression_bodied_properties=true:suggestion
+csharp_style_var_elsewhere=true:warning
+csharp_style_var_for_built_in_types=true:warning
+csharp_style_var_when_type_is_apparent=true:warning
dotnet_style_parentheses_in_arithmetic_binary_operators=never_if_unnecessary:warning
dotnet_style_parentheses_in_other_binary_operators=never_if_unnecessary:warning
dotnet_style_parentheses_in_relational_binary_operators=never_if_unnecessary:warning
-dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion
-dotnet_style_predefined_type_for_member_access=true:suggestion
-dotnet_style_qualification_for_event=false:suggestion
-dotnet_style_qualification_for_field=false:suggestion
-dotnet_style_qualification_for_method=false:suggestion
-dotnet_style_qualification_for_property=false:suggestion
+dotnet_style_predefined_type_for_locals_parameters_members=true:error
+dotnet_style_predefined_type_for_member_access=true:error
+dotnet_style_qualification_for_event=false:warning
+dotnet_style_qualification_for_field=false:warning
+dotnet_style_qualification_for_method=false:warning
+dotnet_style_qualification_for_property=false:warning
dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestion
+# Sort using and Import directives with System.* appearing first
+dotnet_sort_system_directives_first=true
+# Suggest more modern language features when available
+dotnet_style_coalesce_expression=true:error
+dotnet_style_collection_initializer=true:suggestion
+dotnet_style_explicit_tuple_names=true:error
+dotnet_style_null_propagation=true:warning
+dotnet_style_object_initializer=true:warning
+
+# Naming Conventions:
+# Pascal Casing
+#dotnet_naming_symbols.method_and_property_symbols.applicable_kinds= method,property,enum
+#dotnet_naming_symbols.method_and_property_symbols.applicable_accessibilities = *
+#dotnet_naming_style.pascal_case_style.capitalization = pascal_case
+csharp_style_conditional_delegate_call=true:suggestion
+csharp_style_inlined_variable_declaration=true:error
+csharp_style_pattern_matching_over_as_with_null_check=true:error
+csharp_style_pattern_matching_over_is_with_cast_check=true:error
+csharp_style_throw_expression=true:suggestion
+csharp_new_line_before_catch=true
+csharp_new_line_before_else=true
+csharp_new_line_before_finally=true
+csharp_new_line_before_members_in_anonymous_types=true
# ReSharper properties
+resharper_accessor_declaration_braces=end_of_line
resharper_align_linq_query=true
resharper_align_multiline_argument=true
resharper_align_multiline_calls_chain=true
@@ -71,38 +69,46 @@ resharper_align_multline_type_parameter_constrains=true
resharper_align_multline_type_parameter_list=true
resharper_align_tuple_components=true
resharper_autodetect_indent_settings=true
+resharper_constructor_or_destructor_body=expression_body
+resharper_csharp_anonymous_method_declaration_braces=end_of_line
resharper_csharp_outdent_commas=true
resharper_csharp_outdent_dots=true
+resharper_csharp_space_within_parentheses=true
resharper_csharp_wrap_after_declaration_lpar=true
resharper_csharp_wrap_after_invocation_lpar=true
resharper_csharp_wrap_before_binary_opsign=true
resharper_csharp_wrap_before_declaration_rpar=true
resharper_csharp_wrap_before_invocation_rpar=true
+resharper_enforce_line_ending_style=true
+resharper_initializer_braces=end_of_line
resharper_int_align_switch_expressions=true
resharper_int_align_switch_sections=true
resharper_keep_existing_enum_arrangement=true
resharper_keep_existing_switch_expression_arrangement=false
resharper_max_initializer_elements_on_line=2
+resharper_method_or_operator_body=expression_body
resharper_outdent_binary_ops=true
resharper_place_comments_at_first_column=true
resharper_place_simple_enum_on_single_line=true
resharper_space_around_arrow_op=true
resharper_space_within_single_line_array_initializer_braces=true
+resharper_use_heuristics_for_body_style=false
resharper_use_indent_from_vs=false
resharper_wrap_lines=true
+resharper_xmldoc_allow_far_alignment=true
resharper_xmldoc_attribute_style=on_single_line
+resharper_xmldoc_indent_text=ZeroIndent
+resharper_xmldoc_max_blank_lines_between_tags=1
resharper_xmldoc_pi_attribute_style=on_single_line
resharper_xmldoc_space_after_last_pi_attribute=true
# ReSharper inspection severities
resharper_annotate_can_be_null_parameter_highlighting=warning
resharper_annotate_can_be_null_type_member_highlighting=warning
-resharper_arrange_redundant_parentheses_highlighting=hint
-resharper_arrange_this_qualifier_highlighting=hint
-resharper_arrange_type_member_modifiers_highlighting=hint
-resharper_arrange_type_modifiers_highlighting=hint
-resharper_built_in_type_reference_style_for_member_access_highlighting=hint
-resharper_built_in_type_reference_style_highlighting=hint
+resharper_arrange_missing_parentheses_highlighting=warning
+resharper_arrange_this_qualifier_highlighting=warning
+resharper_built_in_type_reference_style_for_member_access_highlighting=error
+resharper_built_in_type_reference_style_highlighting=error
resharper_enforce_do_while_statement_braces_highlighting=warning
resharper_enforce_fixed_statement_braces_highlighting=warning
resharper_enforce_foreach_statement_braces_highlighting=warning
@@ -111,59 +117,47 @@ resharper_enforce_if_statement_braces_highlighting=warning
resharper_enforce_lock_statement_braces_highlighting=warning
resharper_enforce_using_statement_braces_highlighting=warning
resharper_enforce_while_statement_braces_highlighting=warning
-resharper_redundant_base_qualifier_highlighting=warning
resharper_redundant_default_member_initializer_highlighting=hint
resharper_remove_redundant_braces_highlighting=warning
-resharper_suggest_var_or_type_built_in_types_highlighting=hint
-resharper_suggest_var_or_type_elsewhere_highlighting=hint
-resharper_suggest_var_or_type_simple_types_highlighting=hint
+resharper_suggest_var_or_type_built_in_types_highlighting=warning
+resharper_suggest_var_or_type_elsewhere_highlighting=warning
+resharper_suggest_var_or_type_simple_types_highlighting=warning
resharper_unnecessary_whitespace_highlighting=warning
resharper_use_null_propagation_when_possible_highlighting=suggestion
resharper_web_config_module_not_resolved_highlighting=warning
resharper_web_config_type_not_resolved_highlighting=warning
resharper_web_config_wrong_module_highlighting=warning
-[*.{cs,vb}]
-# Sort using and Import directives with System.* appearing first
-dotnet_sort_system_directives_first=true
-# Avoid "this." and "Me." if not necessary
-dotnet_style_qualification_for_event=false:warning
-dotnet_style_qualification_for_field=false:warning
-dotnet_style_qualification_for_method=false:warning
-dotnet_style_qualification_for_property=false:warning
-# Use language keywords instead of framework type names for type references
-dotnet_style_predefined_type_for_locals_parameters_members=true:error
-dotnet_style_predefined_type_for_member_access=true:error
-# Suggest more modern language features when available
-dotnet_style_coalesce_expression=true:error
-dotnet_style_collection_initializer=true:suggestion
-dotnet_style_explicit_tuple_names=true:error
-dotnet_style_null_propagation=true:warning
-dotnet_style_object_initializer=true:warning
-# Naming Conventions:
-# Pascal Casing
-#dotnet_naming_symbols.method_and_property_symbols.applicable_kinds= method,property,enum
-#dotnet_naming_symbols.method_and_property_symbols.applicable_accessibilities = *
-#dotnet_naming_style.pascal_case_style.capitalization = pascal_case
+[*.{cs,cshtml}]
+charset=utf-8
+indent_style=space
+indent_size=4
+insert_final_newline=true
-[*.cs]
-csharp_style_conditional_delegate_call=true:suggestion
-csharp_style_expression_bodied_accessors=true:suggestion
-csharp_style_expression_bodied_constructors=true:none
-csharp_style_expression_bodied_indexers=true:none
-csharp_style_expression_bodied_methods=true:none
-csharp_style_expression_bodied_operators=true:none
-csharp_style_expression_bodied_properties=true:suggestion
-csharp_style_inlined_variable_declaration=true:error
-csharp_style_pattern_matching_over_as_with_null_check=true:error
-csharp_style_pattern_matching_over_is_with_cast_check=true:error
-csharp_style_throw_expression=true:suggestion
-csharp_style_var_elsewhere=true:warning
-csharp_style_var_for_built_in_types=true:warning
-csharp_style_var_when_type_is_apparent=true:error
-csharp_new_line_before_catch=true
-csharp_new_line_before_else=true
-csharp_new_line_before_finally=true
-csharp_new_line_before_members_in_anonymous_types=true
-csharp_new_line_before_open_brace=types,methods,properties,indexers,events,event_accessors,control_blocks,anonymous_types,object_collections,array_initializers,local_functions
+[*.{js,ts,vue}]
+indent_style=space
+indent_size=4
+insert_final_newline=true
+
+[*.{xml,yml,yaml}]
+indent_style=space
+indent_size=2
+insert_final_newline=true
+
+[*.json]
+indent_style=space
+indent_size=4
+insert_final_newline=true
+
+[*.{xml,csproj,props,targets}]
+indent_style=space
+
+[{*.har,*.inputactions,*.jsb2,*.jsb3,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}]
+indent_style=space
+indent_size=2
+
+[*.{appxmanifest,asax,ascx,aspx,build,cg,cginc,compute,cs,cshtml,dtd,fs,fsi,fsscript,fsx,hlsl,hlsli,hlslinc,master,ml,mli,nuspec,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
+indent_style=space
+indent_size=4
+tab_width=4
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 3897e5cbf..13063fddf 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -3,6 +3,7 @@
+
@@ -45,4 +46,4 @@
-
\ No newline at end of file
+
diff --git a/README.md b/README.md
index 7ad40ab94..33100a9de 100644
--- a/README.md
+++ b/README.md
@@ -43,27 +43,27 @@ For more information about using the `DebugAdapterClient` / `DebugAdapterServer`
-| 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] |
-| 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] |
## License
@@ -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"
diff --git a/sample/SampleServer/DidChangeWatchedFilesHandler.cs b/sample/SampleServer/DidChangeWatchedFilesHandler.cs
index f3ecdffa9..320569019 100644
--- a/sample/SampleServer/DidChangeWatchedFilesHandler.cs
+++ b/sample/SampleServer/DidChangeWatchedFilesHandler.cs
@@ -9,12 +9,12 @@ namespace SampleServer
{
internal class DidChangeWatchedFilesHandler : IDidChangeWatchedFilesHandler
{
- private DidChangeWatchedFilesCapability _capability;
-
public DidChangeWatchedFilesRegistrationOptions GetRegistrationOptions() => new DidChangeWatchedFilesRegistrationOptions();
public Task Handle(DidChangeWatchedFilesParams request, CancellationToken cancellationToken) => Unit.Task;
- public void SetCapability(DidChangeWatchedFilesCapability capability) => _capability = capability;
+ public void SetCapability(DidChangeWatchedFilesCapability capability)
+ {
+ }
}
}
diff --git a/sample/SampleServer/FoldingRangeHandler.cs b/sample/SampleServer/FoldingRangeHandler.cs
index 1742c8b95..94423c29c 100644
--- a/sample/SampleServer/FoldingRangeHandler.cs
+++ b/sample/SampleServer/FoldingRangeHandler.cs
@@ -8,8 +8,6 @@ namespace SampleServer
{
internal class FoldingRangeHandler : IFoldingRangeHandler
{
- private FoldingRangeCapability _capability;
-
public FoldingRangeRegistrationOptions GetRegistrationOptions() =>
new FoldingRangeRegistrationOptions {
DocumentSelector = DocumentSelector.ForLanguage("csharp")
@@ -31,6 +29,8 @@ CancellationToken cancellationToken
)
);
- public void SetCapability(FoldingRangeCapability capability) => _capability = capability;
+ public void SetCapability(FoldingRangeCapability capability)
+ {
+ }
}
}
diff --git a/src/Client/Configuration/ChainedConfigurationProvider.cs b/src/Client/Configuration/ChainedConfigurationProvider.cs
index 1a310f5e2..609276795 100644
--- a/src/Client/Configuration/ChainedConfigurationProvider.cs
+++ b/src/Client/Configuration/ChainedConfigurationProvider.cs
@@ -72,7 +72,7 @@ public void Load() { }
/// The child keys.
public IEnumerable GetChildKeys(
IEnumerable earlierKeys,
- string parentPath)
+ string? parentPath)
{
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
var children = section.GetChildren();
diff --git a/src/Client/Configuration/ChainedConfigurationSource.cs b/src/Client/Configuration/ChainedConfigurationSource.cs
index 9e553c651..c247a8f94 100644
--- a/src/Client/Configuration/ChainedConfigurationSource.cs
+++ b/src/Client/Configuration/ChainedConfigurationSource.cs
@@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
///
/// The chained configuration.
///
- public IConfiguration Configuration { get; set; }
+ public IConfiguration Configuration { get; set; } = null!;
///
/// Whether the chained configuration should be disposed when the
diff --git a/src/Client/DefaultLanguageClientFacade.cs b/src/Client/DefaultLanguageClientFacade.cs
index 8edee7461..3493a9f52 100644
--- a/src/Client/DefaultLanguageClientFacade.cs
+++ b/src/Client/DefaultLanguageClientFacade.cs
@@ -20,7 +20,7 @@ internal class DefaultLanguageClientFacade : LanguageProtocolProxy, ILanguageCli
private readonly Lazy _handlersManager;
private readonly TextDocumentIdentifiers _textDocumentIdentifiers;
private readonly IInsanceHasStarted _insanceHasStarted;
- private ILanguageClient _languageClient;
+ private ILanguageClient? _languageClient;
public DefaultLanguageClientFacade(
IResponseRouter requestRouter,
diff --git a/src/Client/LangaugeClientRegistry.cs b/src/Client/LangaugeClientRegistry.cs
index c798c415d..f77d32db4 100644
--- a/src/Client/LangaugeClientRegistry.cs
+++ b/src/Client/LangaugeClientRegistry.cs
@@ -1,4 +1,3 @@
-using System;
using DryIoc;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
diff --git a/src/Client/LanguageClient.cs b/src/Client/LanguageClient.cs
index 35a4b8c75..631a97483 100644
--- a/src/Client/LanguageClient.cs
+++ b/src/Client/LanguageClient.cs
@@ -23,6 +23,7 @@
using OmniSharp.Extensions.LanguageServer.Protocol.Progress;
using OmniSharp.Extensions.LanguageServer.Protocol.Workspace;
using OmniSharp.Extensions.LanguageServer.Shared;
+// ReSharper disable SuspiciousTypeConversion.Global
namespace OmniSharp.Extensions.LanguageServer.Client
{
@@ -51,29 +52,29 @@ public class LanguageClient : JsonRpcServerBase, ILanguageClient
// private readonly ILanguageClientConfiguration _configuration;
private readonly IEnumerable _capabilities;
- private readonly object _initializationOptions;
- private readonly DocumentUri _rootUri;
+ private readonly object? _initializationOptions;
+ private readonly DocumentUri? _rootUri;
private readonly InitializeTrace _trace;
private readonly ClientCapabilities _clientCapabilities;
private readonly LanguageProtocolSettingsBag _settingsBag;
private readonly int? _concurrency;
private readonly IResolverContext _resolverContext;
- internal static IContainer CreateContainer(LanguageClientOptions options, IServiceProvider outerServiceProvider) =>
+ internal static IContainer CreateContainer(LanguageClientOptions options, IServiceProvider? outerServiceProvider) =>
JsonRpcServerContainer.Create(outerServiceProvider)
.AddLanguageClientInternals(options, outerServiceProvider);
public static LanguageClient Create(LanguageClientOptions options) => Create(options, null);
public static LanguageClient Create(Action optionsAction) => Create(optionsAction, null);
- public static LanguageClient Create(Action optionsAction, IServiceProvider outerServiceProvider)
+ public static LanguageClient Create(Action optionsAction, IServiceProvider? outerServiceProvider)
{
var options = new LanguageClientOptions();
optionsAction(options);
return Create(options, outerServiceProvider);
}
- public static LanguageClient Create(LanguageClientOptions options, IServiceProvider outerServiceProvider) =>
+ public static LanguageClient Create(LanguageClientOptions options, IServiceProvider? outerServiceProvider) =>
CreateContainer(options, outerServiceProvider).Resolve();
public static Task From(LanguageClientOptions options) => From(options, null, CancellationToken.None);
@@ -81,20 +82,20 @@ public static LanguageClient Create(LanguageClientOptions options, IServiceProvi
public static Task From(LanguageClientOptions options, CancellationToken cancellationToken) => From(options, null, cancellationToken);
public static Task From(Action optionsAction, CancellationToken cancellationToken) => From(optionsAction, null, cancellationToken);
- public static Task From(LanguageClientOptions options, IServiceProvider outerServiceProvider) =>
+ public static Task From(LanguageClientOptions options, IServiceProvider? outerServiceProvider) =>
From(options, outerServiceProvider, CancellationToken.None);
- public static Task From(Action optionsAction, IServiceProvider outerServiceProvider) =>
+ public static Task From(Action optionsAction, IServiceProvider? outerServiceProvider) =>
From(optionsAction, outerServiceProvider, CancellationToken.None);
- public static Task From(Action optionsAction, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
+ public static Task From(Action optionsAction, IServiceProvider? outerServiceProvider, CancellationToken cancellationToken)
{
var options = new LanguageClientOptions();
optionsAction(options);
return From(options, outerServiceProvider, cancellationToken);
}
- public static async Task From(LanguageClientOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
+ public static async Task From(LanguageClientOptions options, IServiceProvider? outerServiceProvider, CancellationToken cancellationToken)
{
var server = Create(options, outerServiceProvider);
await server.Initialize(cancellationToken).ConfigureAwait(false);
@@ -214,10 +215,10 @@ public async Task Initialize(CancellationToken token)
Trace = _trace,
ClientInfo = _clientInfo,
Capabilities = _clientCapabilities,
- RootUri = _rootUri,
- RootPath = _rootUri?.GetFileSystemPath(),
+ RootUri = _rootUri!,
+ RootPath = _rootUri?.GetFileSystemPath() ?? string.Empty,
WorkspaceFolders = new Container(WorkspaceFoldersManager.CurrentWorkspaceFolders),
- InitializationOptions = _initializationOptions
+ InitializationOptions = _initializationOptions!
};
var capabilitiesObject = new JObject();
@@ -369,11 +370,11 @@ public async Task Shutdown()
_connection.Dispose();
}
- private Supports UseOrTryAndFindCapability(Supports supports) where T : class
+ private Supports UseOrTryAndFindCapability(Supports supports) where T : class?
{
var value = supports.IsSupported
? supports.Value
- : _capabilities.OfType().FirstOrDefault();
+ : _capabilities.OfType().FirstOrDefault()!;
if (value is IDynamicCapability dynamicCapability)
{
dynamicCapability.DynamicRegistration = _collection.ContainsHandler(typeof(IRegisterCapabilityHandler));
@@ -384,18 +385,17 @@ private Supports UseOrTryAndFindCapability(Supports supports) where T :
public IObservable Start => _initializeComplete.AsObservable();
- bool IResponseRouter.TryGetRequest(long id, [NotNullWhen(true)] out string method, [NotNullWhen(true)] out TaskCompletionSource pendingTask) => _responseRouter.TryGetRequest(id, out method, out pendingTask);
+ bool IResponseRouter.TryGetRequest(long id, [NotNullWhen(true)] out string method, [NotNullWhen(true)]out TaskCompletionSource pendingTask) =>
+ _responseRouter.TryGetRequest(id, out method, out pendingTask);
public Task WasStarted => _initializeComplete.ToTask();
public void Dispose()
{
- _connection?.Dispose();
- _disposable?.Dispose();
+ _connection.Dispose();
+ _disposable.Dispose();
}
- public IDictionary Experimental { get; } = new Dictionary();
-
public IDisposable Register(Action registryAction)
{
var manager = new CompositeHandlersManager(_collection);
diff --git a/src/Client/LanguageClientOptions.cs b/src/Client/LanguageClientOptions.cs
index c087ad1b1..ba77406c8 100644
--- a/src/Client/LanguageClientOptions.cs
+++ b/src/Client/LanguageClientOptions.cs
@@ -25,118 +25,116 @@ public LanguageClientOptions()
TextDocument = new TextDocumentClientCapabilities()
};
- public ClientInfo ClientInfo { get; set; }
- public DocumentUri RootUri { get; set; }
+ public ClientInfo? ClientInfo { get; set; }
+ public DocumentUri? RootUri { get; set; }
public bool WorkspaceFolders { get; set; } = true;
public bool DynamicRegistration { get; set; } = true;
public bool ProgressTokens { get; set; } = true;
public string RootPath
{
- get => RootUri.GetFileSystemPath();
+ get => RootUri?.GetFileSystemPath() ?? string.Empty;
set => RootUri = DocumentUri.FromFileSystemPath(value);
}
public InitializeTrace Trace { get; set; }
- public object InitializationOptions { get; set; }
+ public object? InitializationOptions { get; set; }
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions? options) =>
AddHandler(method, handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions? options) =>
AddHandler(method, handlerFunc, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandlers(params IJsonRpcHandler[] handlers) => AddHandlers(handlers);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions? options) =>
AddHandler(handlerFunc, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(IJsonRpcHandler handler, JsonRpcHandlerOptions options) => AddHandler(handler, options);
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(IJsonRpcHandler handler, JsonRpcHandlerOptions? options) => AddHandler(handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerOptions options) => AddHandler(options);
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerOptions? options) => AddHandler(options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, JsonRpcHandlerOptions? options) =>
AddHandler(method, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(Type type, JsonRpcHandlerOptions options) => AddHandler(type, options);
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(Type type, JsonRpcHandlerOptions? options) => AddHandler(type, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, Type type, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, Type type, JsonRpcHandlerOptions? options) =>
AddHandler(method, type, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.AddHandlerLink(string fromMethod, string toMethod) =>
AddHandlerLink(fromMethod, toMethod);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonRequest(string method, Func> handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonRequest(string method, Func> handler, JsonRpcHandlerOptions? options) =>
OnJsonRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnJsonRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.
- OnRequest(string method, Func> handler, JsonRpcHandlerOptions options) => OnRequest(method, handler, options);
+ OnRequest(string method, Func> handler, JsonRpcHandlerOptions? options) => OnRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.OnRequest(string method, Func handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.OnRequest(string method, Func handler, JsonRpcHandlerOptions? options) =>
OnRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func handler, JsonRpcHandlerOptions options
+ string method, Func handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func handler, JsonRpcHandlerOptions options
+ string method, Func handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(
- string method, Action handler, JsonRpcHandlerOptions options
+ string method, Action handler, JsonRpcHandlerOptions? options
) => OnNotification(method, handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonNotification(string method, Action handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonNotification(string method, Action handler, JsonRpcHandlerOptions? options) =>
OnJsonNotification(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonNotification(
- string method, Func handler, JsonRpcHandlerOptions options
+ string method, Func handler, JsonRpcHandlerOptions? options
) => OnJsonNotification(method, handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonNotification(string method, Func handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonNotification(string method, Func handler, JsonRpcHandlerOptions? options) =>
OnJsonNotification(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnJsonNotification(
- string method, Action handler, JsonRpcHandlerOptions options
+ string method, Action handler, JsonRpcHandlerOptions? options
) => OnJsonNotification(method, handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(string method, Action handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(string method, Action handler, JsonRpcHandlerOptions? options) =>
OnNotification(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(
- string method, Func handler, JsonRpcHandlerOptions options
+ string method, Func handler, JsonRpcHandlerOptions? options
) => OnNotification(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.
- OnNotification(string method, Func handler, JsonRpcHandlerOptions options) => OnNotification(method, handler, options);
+ OnNotification(string method, Func handler, JsonRpcHandlerOptions? options) => OnNotification(method, handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(string method, Action handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(string method, Action handler, JsonRpcHandlerOptions? options) =>
OnNotification(method, handler, options);
ILanguageClientRegistry IJsonRpcHandlerRegistry.
- OnNotification(string method, Func handler, JsonRpcHandlerOptions options) => OnNotification(method, handler, options);
+ OnNotification(string method, Func handler, JsonRpcHandlerOptions? options) => OnNotification(method, handler, options);
- ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(string method, Func handler, JsonRpcHandlerOptions options) =>
+ ILanguageClientRegistry IJsonRpcHandlerRegistry.OnNotification(string method, Func handler, JsonRpcHandlerOptions? options) =>
OnNotification(method, handler, options);
-
- public override IRequestProcessIdentifier RequestProcessIdentifier { get; set; }
}
}
diff --git a/src/Client/LanguageClientRegistrationManager.cs b/src/Client/LanguageClientRegistrationManager.cs
index 4493a4bf1..cef084a2b 100644
--- a/src/Client/LanguageClientRegistrationManager.cs
+++ b/src/Client/LanguageClientRegistrationManager.cs
@@ -30,7 +30,8 @@ internal class LanguageClientRegistrationManager : IRegisterCapabilityHandler, I
public LanguageClientRegistrationManager(
ISerializer serializer,
ILspHandlerTypeDescriptorProvider handlerTypeDescriptorProvider,
- ILogger logger)
+ ILogger logger
+ )
{
_serializer = serializer;
_handlerTypeDescriptorProvider = handlerTypeDescriptorProvider;
@@ -77,44 +78,41 @@ public void RegisterCapabilities(ServerCapabilities serverCapabilities)
continue;
}
- if (string.IsNullOrWhiteSpace(registrationOptions.Id))
+ if (registrationOptions.Id != null)
{
- registrationOptions.Id = Guid.NewGuid().ToString();
+ var reg = new Registration {
+ Id = registrationOptions.Id,
+ Method = method,
+ RegisterOptions = registrationOptions
+ };
+ _registrations.AddOrUpdate(registrationOptions.Id, x => reg, (a, b) => reg);
}
-
- var reg = new Registration {
- Id = registrationOptions.Id,
- Method = method,
- RegisterOptions = registrationOptions
- };
- _registrations.AddOrUpdate(registrationOptions.Id, x => reg, (a, b) => reg);
}
- if (serverCapabilities.Workspace == null)
- {
- _registrationSubject.OnNext(_registrations.Values);
- return;
- }
-
- foreach (var registrationOptions in LspHandlerDescriptorHelpers.GetStaticRegistrationOptions(
- serverCapabilities
- .Workspace
- ))
+ if (serverCapabilities.Workspace != null)
{
- var method = _handlerTypeDescriptorProvider.GetMethodForRegistrationOptions(registrationOptions);
- if (method == null)
+ foreach (var registrationOptions in LspHandlerDescriptorHelpers.GetStaticRegistrationOptions(serverCapabilities.Workspace))
{
- // TODO: Log this
- continue;
+ var method = _handlerTypeDescriptorProvider.GetMethodForRegistrationOptions(registrationOptions);
+ if (method == null)
+ {
+ _logger.LogWarning("Unable to find method for given {@RegistrationOptions}", registrationOptions);
+ continue;
+ }
+
+ if (registrationOptions.Id != null)
+ {
+ var reg = new Registration {
+ Id = registrationOptions.Id,
+ Method = method,
+ RegisterOptions = registrationOptions
+ };
+ _registrations.AddOrUpdate(registrationOptions.Id, x => reg, (a, b) => reg);
+ }
}
-
- var reg = new Registration {
- Id = registrationOptions.Id,
- Method = method,
- RegisterOptions = registrationOptions
- };
- _registrations.AddOrUpdate(registrationOptions.Id, x => reg, (a, b) => reg);
}
+
+ _registrationSubject.OnNext(_registrations.Values);
}
private void Register(params Registration[] registrations)
@@ -163,7 +161,7 @@ public IEnumerable GetRegistrationsMatchingSelector(DocumentSelect
z.HasScheme ? z.Scheme :
z.HasPattern ? z.Pattern : string.Empty, (a, b) => a
)
- .Any(x => x.HasLanguage || x.HasPattern || x.HasScheme)
+ .Any(y => y.HasLanguage || y.HasPattern || y.HasScheme)
);
public void Dispose() => _registrationSubject.Dispose();
diff --git a/src/Client/LanguageClientResolver.cs b/src/Client/LanguageClientResolver.cs
index 3370a6f1d..3a428d008 100644
--- a/src/Client/LanguageClientResolver.cs
+++ b/src/Client/LanguageClientResolver.cs
@@ -8,10 +8,10 @@ namespace OmniSharp.Extensions.LanguageServer.Client
public class LanguageClientResolver : IDisposable
{
private readonly IOptionsMonitor _monitor;
- private readonly IServiceProvider _outerServiceProvider;
+ private readonly IServiceProvider? _outerServiceProvider;
private readonly ConcurrentDictionary _clients = new ConcurrentDictionary();
- public LanguageClientResolver(IOptionsMonitor monitor, IServiceProvider outerServiceProvider)
+ public LanguageClientResolver(IOptionsMonitor monitor, IServiceProvider? outerServiceProvider)
{
_monitor = monitor;
_outerServiceProvider = outerServiceProvider;
diff --git a/src/Client/LanguageClientServiceCollectionExtensions.cs b/src/Client/LanguageClientServiceCollectionExtensions.cs
index 59f647db8..7fec5fc1d 100644
--- a/src/Client/LanguageClientServiceCollectionExtensions.cs
+++ b/src/Client/LanguageClientServiceCollectionExtensions.cs
@@ -7,7 +7,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
-using Microsoft.Extensions.Primitives;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.LanguageServer.Client.Configuration;
using OmniSharp.Extensions.LanguageServer.Protocol.Client;
@@ -19,7 +18,7 @@ namespace OmniSharp.Extensions.LanguageServer.Client
{
public static class LanguageClientServiceCollectionExtensions
{
- internal static IContainer AddLanguageClientInternals(this IContainer container, LanguageClientOptions options, IServiceProvider outerServiceProvider)
+ internal static IContainer AddLanguageClientInternals(this IContainer container, LanguageClientOptions options, IServiceProvider? outerServiceProvider)
{
container = container.AddLanguageProtocolInternals(options);
@@ -29,13 +28,15 @@ internal static IContainer AddLanguageClientInternals(this IContainer container,
nonPublicServiceTypes: true,
ifAlreadyRegistered: IfAlreadyRegistered.Keep
);
- if (options.OnUnhandledException != null)
+ if (!EqualityComparer.Default.Equals( options.OnUnhandledException, default))
{
container.RegisterInstance(options.OnUnhandledException);
}
else
{
+#pragma warning disable 4014
container.RegisterDelegate(_ => new OnUnhandledExceptionHandler(e => _.GetRequiredService().Shutdown()), Reuse.Singleton);
+#pragma warning restore 4014
}
container.RegisterMany(serviceTypeCondition: type => type.Name.Contains(nameof(TextDocumentLanguageClient)), reuse: Reuse.Singleton);
@@ -58,10 +59,11 @@ internal static IContainer AddLanguageClientInternals(this IContainer container,
container.RegisterInstance(
options.ClientInfo ?? new ClientInfo {
- Name = Assembly.GetEntryAssembly()?.GetName().Name,
+ Name = Assembly.GetEntryAssembly()?.GetName().ToString() ?? string.Empty,
Version = Assembly.GetEntryAssembly()?.GetCustomAttribute()
?.InformationalVersion ??
Assembly.GetEntryAssembly()?.GetCustomAttribute()?.Version
+ ?? string.Empty
}
);
@@ -77,7 +79,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();
@@ -99,10 +101,10 @@ internal static IContainer AddLanguageClientInternals(this IContainer container,
return container;
}
- public static IServiceCollection AddLanguageClient(this IServiceCollection services, Action configureOptions = null) =>
+ public static IServiceCollection AddLanguageClient(this IServiceCollection services, Action? configureOptions = null) =>
AddLanguageClient(services, Options.DefaultName, configureOptions);
- public static IServiceCollection AddLanguageClient(this IServiceCollection services, string name, Action configureOptions = null)
+ public static IServiceCollection AddLanguageClient(this IServiceCollection services, string name, Action? configureOptions = null)
{
// If we get called multiple times we're going to remove the default server
// and force consumers to use the resolver.
diff --git a/src/Client/LanguageClientWorkspaceFoldersManager.cs b/src/Client/LanguageClientWorkspaceFoldersManager.cs
index efd59e76e..88730e8da 100644
--- a/src/Client/LanguageClientWorkspaceFoldersManager.cs
+++ b/src/Client/LanguageClientWorkspaceFoldersManager.cs
@@ -32,9 +32,9 @@ public LanguageClientWorkspaceFoldersManager(IWorkspaceLanguageClient client, IE
}
}
- Task> IRequestHandler>.
+ Task?> IRequestHandler?>.
Handle(WorkspaceFolderParams request, CancellationToken cancellationToken) =>
- Task.FromResult(new Container(_workspaceFolders.Values));
+ Task.FromResult< Container?>(new Container(_workspaceFolders.Values));
public void Add(DocumentUri uri, string name) => Add(new WorkspaceFolder { Name = name, Uri = uri });
@@ -96,6 +96,6 @@ public void Remove(IEnumerable items)
public IEnumerable CurrentWorkspaceFolders => _workspaceFolders.Values;
- public void Dispose() => _workspaceFoldersSubject?.Dispose();
+ public void Dispose() => _workspaceFoldersSubject.Dispose();
}
}
diff --git a/src/Client/LspClientReceiver.cs b/src/Client/LspClientReceiver.cs
index 360af0c1f..6839825c2 100644
--- a/src/Client/LspClientReceiver.cs
+++ b/src/Client/LspClientReceiver.cs
@@ -29,8 +29,7 @@ public override (IEnumerable results, bool hasResponse) GetRequests(JToke
var (results, hasResponse) = base.GetRequests(container);
foreach (var item in results)
{
- if (item.IsRequest &&
- _handlerTypeDescriptorProvider.IsMethodName(item.Request.Method, typeof(IShowMessageRequestHandler)))
+ if (item.IsRequest && _handlerTypeDescriptorProvider.IsMethodName(item.Request!.Method, typeof(IShowMessageRequestHandler)))
{
newResults.Add(item);
}
@@ -40,7 +39,7 @@ public override (IEnumerable results, bool hasResponse) GetRequests(JToke
}
else if (item.IsNotification &&
_handlerTypeDescriptorProvider.IsMethodName(
- item.Notification.Method,
+ item.Notification!.Method,
typeof(IShowMessageHandler),
typeof(ILogMessageHandler),
typeof(ITelemetryEventHandler)
diff --git a/src/Dap.Client/Configuration/ChainedConfigurationProvider.cs b/src/Dap.Client/Configuration/ChainedConfigurationProvider.cs
index 2afad36c9..c454a2b32 100644
--- a/src/Dap.Client/Configuration/ChainedConfigurationProvider.cs
+++ b/src/Dap.Client/Configuration/ChainedConfigurationProvider.cs
@@ -72,7 +72,7 @@ public void Load() { }
/// The child keys.
public IEnumerable GetChildKeys(
IEnumerable earlierKeys,
- string parentPath)
+ string? parentPath)
{
IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath);
var children = section.GetChildren();
diff --git a/src/Dap.Client/Configuration/ChainedConfigurationSource.cs b/src/Dap.Client/Configuration/ChainedConfigurationSource.cs
index 61b55434e..6fca77a5d 100644
--- a/src/Dap.Client/Configuration/ChainedConfigurationSource.cs
+++ b/src/Dap.Client/Configuration/ChainedConfigurationSource.cs
@@ -13,7 +13,7 @@ internal class ChainedConfigurationSource : IConfigurationSource
///
/// The chained configuration.
///
- public IConfiguration Configuration { get; set; }
+ public IConfiguration Configuration { get; set; } = null!;
///
/// Whether the chained configuration should be disposed when the
diff --git a/src/Dap.Client/DebugAdapterClient.cs b/src/Dap.Client/DebugAdapterClient.cs
index f27ece049..1abf25bc1 100644
--- a/src/Dap.Client/DebugAdapterClient.cs
+++ b/src/Dap.Client/DebugAdapterClient.cs
@@ -15,6 +15,7 @@
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
using OmniSharp.Extensions.DebugAdapter.Shared;
using OmniSharp.Extensions.JsonRpc;
+// ReSharper disable SuspiciousTypeConversion.Global
namespace OmniSharp.Extensions.DebugAdapter.Client
{
@@ -36,21 +37,21 @@ public class DebugAdapterClient : JsonRpcServerBase, IDebugAdapterClient, IDebug
private readonly ISubject _initializedComplete = new AsyncSubject();
private readonly int? _concurrency;
- internal static IContainer CreateContainer(DebugAdapterClientOptions options, IServiceProvider outerServiceProvider) =>
+ internal static IContainer CreateContainer(DebugAdapterClientOptions options, IServiceProvider? outerServiceProvider) =>
JsonRpcServerContainer.Create(outerServiceProvider)
.AddDebugAdapterClientInternals(options, outerServiceProvider);
public static DebugAdapterClient Create(DebugAdapterClientOptions options) => Create(options, null);
public static DebugAdapterClient Create(Action optionsAction) => Create(optionsAction, null);
- public static DebugAdapterClient Create(Action optionsAction, IServiceProvider outerServiceProvider)
+ public static DebugAdapterClient Create(Action optionsAction, IServiceProvider? outerServiceProvider)
{
var options = new DebugAdapterClientOptions();
optionsAction(options);
return Create(options, outerServiceProvider);
}
- public static DebugAdapterClient Create(DebugAdapterClientOptions options, IServiceProvider outerServiceProvider) =>
+ public static DebugAdapterClient Create(DebugAdapterClientOptions options, IServiceProvider? outerServiceProvider) =>
CreateContainer(options, outerServiceProvider).Resolve();
public static Task From(DebugAdapterClientOptions options) => From(options, null, CancellationToken.None);
@@ -60,20 +61,20 @@ public static DebugAdapterClient Create(DebugAdapterClientOptions options, IServ
public static Task From(Action optionsAction, CancellationToken cancellationToken) =>
From(optionsAction, null, cancellationToken);
- public static Task From(DebugAdapterClientOptions options, IServiceProvider outerServiceProvider) =>
+ public static Task From(DebugAdapterClientOptions options, IServiceProvider? outerServiceProvider) =>
From(options, outerServiceProvider, CancellationToken.None);
- public static Task From(Action optionsAction, IServiceProvider outerServiceProvider) =>
+ public static Task From(Action optionsAction, IServiceProvider? outerServiceProvider) =>
From(optionsAction, outerServiceProvider, CancellationToken.None);
- public static Task From(Action optionsAction, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
+ public static Task From(Action optionsAction, IServiceProvider? outerServiceProvider, CancellationToken cancellationToken)
{
var options = new DebugAdapterClientOptions();
optionsAction(options);
return From(options, outerServiceProvider, cancellationToken);
}
- public static async Task From(DebugAdapterClientOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
+ public static async Task From(DebugAdapterClientOptions options, IServiceProvider? outerServiceProvider, CancellationToken cancellationToken)
{
var server = Create(options, outerServiceProvider);
await server.Initialize(cancellationToken).ConfigureAwait(false);
@@ -160,19 +161,21 @@ await DebugAdapterEventingHelper.Run(
_instanceHasStarted.Started = true;
}
- async Task IRequestHandler.Handle(InitializedEvent request, CancellationToken cancellationToken)
+ Task IRequestHandler.Handle(InitializedEvent request, CancellationToken cancellationToken)
{
_initializedComplete.OnNext(request);
_initializedComplete.OnCompleted();
- return Unit.Value;
+ return Unit.Task;
}
private void RegisterCapabilities(InitializeRequestArguments capabilities)
{
- capabilities.SupportsRunInTerminalRequest ??= _collection.ContainsHandler(typeof(IRunInTerminalHandler));
- capabilities.SupportsProgressReporting ??= _collection.ContainsHandler(typeof(IProgressStartHandler)) &&
- _collection.ContainsHandler(typeof(IProgressUpdateHandler)) &&
- _collection.ContainsHandler(typeof(IProgressEndHandler));
+ capabilities.SupportsRunInTerminalRequest = capabilities.SupportsRunInTerminalRequest || _collection.ContainsHandler(typeof(IRunInTerminalHandler));
+ capabilities.SupportsProgressReporting = capabilities.SupportsProgressReporting ||
+ _collection.ContainsHandler(typeof(IProgressStartHandler)) &&
+ _collection.ContainsHandler(typeof(IProgressUpdateHandler)) &&
+ _collection.ContainsHandler(typeof(IProgressEndHandler))
+ ;
}
public InitializeRequestArguments ClientSettings
@@ -191,8 +194,8 @@ public InitializeResponse ServerSettings
public void Dispose()
{
- _disposable?.Dispose();
- _connection?.Dispose();
+ _disposable.Dispose();
+ _connection.Dispose();
}
object IServiceProvider.GetService(Type serviceType) => _serviceProvider.GetService(serviceType);
diff --git a/src/Dap.Client/DebugAdapterClientOptions.cs b/src/Dap.Client/DebugAdapterClientOptions.cs
index 2bc2f6b3d..027c89750 100644
--- a/src/Dap.Client/DebugAdapterClientOptions.cs
+++ b/src/Dap.Client/DebugAdapterClientOptions.cs
@@ -15,123 +15,124 @@ public class DebugAdapterClientOptions : DebugAdapterRpcOptionsBase.AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options) =>
+
+ public string? ClientId { get; set; }
+ public string? ClientName { get; set; }
+ public string AdapterId { get; set; } = null!;
+ public string? Locale { get; set; }
+ public bool LinesStartAt1 { get; set; }
+ public bool ColumnsStartAt1 { get; set; }
+ public string? PathFormat { get; set; }
+ public bool SupportsVariableType { get; set; }
+ public bool SupportsVariablePaging { get; set; }
+ public bool SupportsRunInTerminalRequest { get; set; }
+ public bool SupportsMemoryReferences { get; set; }
+ public bool SupportsProgressReporting { get; set; }
+
+ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions? options) =>
AddHandler(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.
- AddHandler(string method, JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options) => AddHandler(method, handlerFunc, options);
+ AddHandler(string method, JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions? options) => AddHandler(method, handlerFunc, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandlers(params IJsonRpcHandler[] handlers) => AddHandlers(handlers);
- IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options) =>
+ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions? options) =>
AddHandler(handlerFunc, options);
- IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(IJsonRpcHandler handler, JsonRpcHandlerOptions options) =>
+ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(IJsonRpcHandler handler, JsonRpcHandlerOptions? options) =>
AddHandler(handler, options);
- IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerOptions options) => AddHandler(options);
+ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(JsonRpcHandlerOptions? options) => AddHandler(options);
- IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, JsonRpcHandlerOptions options) =>
+ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, JsonRpcHandlerOptions? options) =>
AddHandler(method, options);
- IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(Type type, JsonRpcHandlerOptions options) => AddHandler(type, options);
+ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(Type type, JsonRpcHandlerOptions? options) => AddHandler(type, options);
- IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, Type type, JsonRpcHandlerOptions options) =>
+ IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandler(string method, Type type, JsonRpcHandlerOptions? options) =>
AddHandler(method, type, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.AddHandlerLink(string fromMethod, string toMethod) =>
AddHandlerLink(fromMethod, toMethod);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.OnJsonRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnJsonRequest(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.OnJsonRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnJsonRequest(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry.OnRequest(
- string method, Func> handler, JsonRpcHandlerOptions options
+ string method, Func> handler, JsonRpcHandlerOptions? options
) => OnRequest(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry