diff --git a/CHANGELOG.md b/CHANGELOG.md
index ebacaafdeb..d3377fa246 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,14 +2,19 @@
All changes to the project will be documented in this file.
## [1.39.1]
+* Update Roslyn to 4.4.0 1.22369.1 (PR: [#2420](https://github.com/OmniSharp/omnisharp-roslyn/pull/2420))
+* Simplify some code (PR: [#2370](https://github.com/OmniSharp/omnisharp-roslyn/pull/2370))
+* Return meaningful error when pinned SDK version is not found. ([[omnisharp-vscode#5128](https://github.com/OmniSharp/omnisharp-vscode/issues/5128), PR: [#2403](https://github.com/OmniSharp/omnisharp-roslyn/pull/2403))
* Added support for `nullable` ([#2292](https://github.com/OmniSharp/omnisharp-roslyn/issues/2292), PR: [#2406](https://github.com/OmniSharp/omnisharp-roslyn/pull/2406))
+* Removed nuget versioning reference from OmniSharp.Abstractions ([#2410](https://github.com/OmniSharp/omnisharp-roslyn/issues/2410), PR: [#2414](https://github.com/OmniSharp/omnisharp-roslyn/pull/2414))
+* Bump Newtonsoft.Json to 13.0.1 (PR: [#2415](https://github.com/OmniSharp/omnisharp-roslyn/pull/2415))
## [1.39.0] - 2022-05-19
* Update Roslyn to 4.3.0-2.22267.5 (PR: [#2401](https://github.com/OmniSharp/omnisharp-roslyn/pull/2401))
-* Fixed run script for Mono ([OmniSharp/omnisharp-vscode#5181](https://github.com/OmniSharp/omnisharp-vscode/issues/5181), [OmniSharp/omnisharp-vscode#5179](https://github.com/OmniSharp/omnisharp-vscode/issues/5179), PR: [#2398](https://github.com/OmniSharp/omnisharp-roslyn/pull/2398))
+* Fixed run script for Mono ([omnisharp-vscode#5181](https://github.com/OmniSharp/omnisharp-vscode/issues/5181), [omnisharp-vscode#5179](https://github.com/OmniSharp/omnisharp-vscode/issues/5179), PR: [#2398](https://github.com/OmniSharp/omnisharp-roslyn/pull/2398))
* Fall back to /usr/lib/os-release if /etc/os-release doesn't exist (PR: [#2380](https://github.com/OmniSharp/omnisharp-roslyn/pull/2380))
* Added support for linux-musl-x64 and linux-musl-arm64 ([#2366](https://github.com/OmniSharp/omnisharp-roslyn/issues/2366), PR: [#2395](https://github.com/OmniSharp/omnisharp-roslyn/pull/2395))
-* Enable GoToDefinition for symbols in metadata documents ([OmniSharp/omnisharp-vscode#4818](https://github.com/OmniSharp/omnisharp-vscode/issues/4818), PR: [#2390](https://github.com/OmniSharp/omnisharp-roslyn/pull/2390))
+* Enable GoToDefinition for symbols in metadata documents ([omnisharp-vscode#4818](https://github.com/OmniSharp/omnisharp-vscode/issues/4818), PR: [#2390](https://github.com/OmniSharp/omnisharp-roslyn/pull/2390))
* Use human readable doc in lsp's signature help ([#2372](https://github.com/OmniSharp/omnisharp-roslyn/issues/2372), PR: [#2392](https://github.com/OmniSharp/omnisharp-roslyn/pull/2392))
* Add TextEdits support to InlayHints (PR: [#2385](https://github.com/OmniSharp/omnisharp-roslyn/pull/2385))
* Fix Equals of AutoCompleteResponse and simplify some code (PR: [#2362](https://github.com/OmniSharp/omnisharp-roslyn/pull/2362))
diff --git a/build/Packages.props b/build/Packages.props
index 12fca60087..b2b1ac5a66 100644
--- a/build/Packages.props
+++ b/build/Packages.props
@@ -7,7 +7,7 @@
17.2.0
17.0.0
6.3.0-preview.1.32
- 4.3.0-2.22267.5
+ 4.4.0-1.22369.1
2.4.1
diff --git a/global.json b/global.json
index 586ef8d4d9..909d8a8f3c 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,6 @@
{
"sdk": {
- "version": "7.0.100-preview.4.22252.9"
+ "version": "7.0.100-preview.4.22252.9",
+ "rollForward": "patch"
}
}
diff --git a/src/OmniSharp.Abstractions/Configuration.cs b/src/OmniSharp.Abstractions/Configuration.cs
index 6d5484c10c..9236ee4381 100644
--- a/src/OmniSharp.Abstractions/Configuration.cs
+++ b/src/OmniSharp.Abstractions/Configuration.cs
@@ -4,7 +4,7 @@ internal static class Configuration
{
public static bool ZeroBasedIndices = false;
- public const string RoslynVersion = "4.3.0.0";
+ public const string RoslynVersion = "4.4.0.0";
public const string RoslynPublicKeyToken = "31bf3856ad364e35";
public readonly static string RoslynFeatures = GetRoslynAssemblyFullName("Microsoft.CodeAnalysis.Features");
diff --git a/src/OmniSharp.Http.Driver/app.config b/src/OmniSharp.Http.Driver/app.config
index 24ab3d4192..de37867718 100644
--- a/src/OmniSharp.Http.Driver/app.config
+++ b/src/OmniSharp.Http.Driver/app.config
@@ -7,23 +7,23 @@
-
+
-
+
-
+
-
+
-
+
diff --git a/src/OmniSharp.LanguageServerProtocol/app.config b/src/OmniSharp.LanguageServerProtocol/app.config
index 991918fe41..b9268318f4 100644
--- a/src/OmniSharp.LanguageServerProtocol/app.config
+++ b/src/OmniSharp.LanguageServerProtocol/app.config
@@ -7,23 +7,23 @@
-
+
-
+
-
+
-
+
-
+
diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Async.cs b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Async.cs
index 9e6814f7cd..1543c7267e 100644
--- a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Async.cs
+++ b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Async.cs
@@ -28,14 +28,14 @@ internal static partial class CompletionListBuilder
TextSpan typedSpan,
bool expectingImportedItems, bool isSuggestionMode)
{
- var completionsBuilder = new List(completions.Items.Length);
+ var completionsBuilder = new List(completions.ItemsList.Count);
var seenUnimportedCompletions = false;
var commitCharacterRuleCache = new Dictionary, IReadOnlyList>();
var commitCharacterRuleBuilder = new HashSet();
- for (int i = 0; i < completions.Items.Length; i++)
+ for (int i = 0; i < completions.ItemsList.Count; i++)
{
- var completion = completions.Items[i];
+ var completion = completions.ItemsList[i];
string labelText = completion.DisplayTextPrefix + completion.DisplayText + completion.DisplayTextSuffix;
string? insertText;
string? filterText = null;
diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Sync.cs b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Sync.cs
index 087f7e3870..7c4982bbee 100644
--- a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Sync.cs
+++ b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionListBuilder_Sync.cs
@@ -35,29 +35,32 @@ internal static partial class CompletionListBuilder
bool expectingImportedItems,
bool isSuggestionMode)
{
- var completionsBuilder = new List(completions.Items.Length);
+ var completionsBuilder = new List(completions.ItemsList.Count);
var seenUnimportedCompletions = false;
var commitCharacterRuleCache = new Dictionary, IReadOnlyList>();
var commitCharacterRuleBuilder = new HashSet();
- var completionTasksAndProviderNames = completions.Items.SelectAsArray((document, completionService), (completion, arg) =>
+ var completionTasksAndProviderNamesBuilder = ImmutableArray.CreateBuilder<(Task?, string? providerName)>();
+ for (int i = 0; i < completions.ItemsList.Count; i++)
{
+ var completion = completions.ItemsList[i];
var providerName = completion.GetProviderName();
if (providerName is TypeImportCompletionProvider or
ExtensionMethodImportCompletionProvider)
{
- return (null, providerName);
+ completionTasksAndProviderNamesBuilder.Add((null, providerName));
}
else
{
- return ((Task?)arg.completionService.GetChangeAsync(arg.document, completion), providerName);
+ completionTasksAndProviderNamesBuilder.Add(((Task?)completionService.GetChangeAsync(document, completion), providerName));
}
- });
+ }
+ var completionTasksAndProviderNames = completionTasksAndProviderNamesBuilder.ToImmutable();
- for (int i = 0; i < completions.Items.Length; i++)
+ for (int i = 0; i < completions.ItemsList.Count; i++)
{
TextSpan changeSpan = typedSpan;
- var completion = completions.Items[i];
+ var completion = completions.ItemsList[i];
var insertTextFormat = InsertTextFormat.PlainText;
string labelText = completion.DisplayTextPrefix + completion.DisplayText + completion.DisplayTextSuffix;
List? additionalTextEdits = null;
diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs
index 5b685685de..5ff3d57078 100644
--- a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs
+++ b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs
@@ -94,17 +94,17 @@ public async Task Handle(CompletionRequest request, bool for
var completions = await OmniSharpCompletionService.GetCompletionsAsync(completionService, document, position, trigger, roles: null, options, CancellationToken.None);
_logger.LogTrace("Found {0} completions for {1}:{2},{3}",
- completions?.Items.IsDefaultOrEmpty != false ? 0 : completions.Items.Length,
+ completions.ItemsList.Count,
request.FileName,
request.Line,
request.Column);
- if (completions is null || completions.Items.Length == 0)
+ if (completions is null || completions.ItemsList.Count == 0)
{
return new CompletionResponse { Items = ImmutableArray.Empty };
}
- if (request.TriggerCharacter == ' ' && !completions.Items.Any(c =>
+ if (request.TriggerCharacter == ' ' && !completions.ItemsList.Any(c =>
{
var providerName = c.GetProviderName();
return providerName is CompletionListBuilder.OverrideCompletionProvider or
@@ -166,14 +166,14 @@ public async Task Handle(CompletionResolveRequest req
var index = request.Item.Data.Index;
if (request.Item is null
- || index >= completions.Items.Length
+ || index >= completions.ItemsList.Count
|| index < 0)
{
_logger.LogError("Received invalid completion resolve!");
return new CompletionResolveResponse { Item = request.Item };
}
- var lastCompletionItem = completions.Items[index];
+ var lastCompletionItem = completions.ItemsList[index];
if (lastCompletionItem.DisplayTextPrefix + lastCompletionItem.DisplayText + lastCompletionItem.DisplayTextSuffix != request.Item.Label)
{
_logger.LogError("Inconsistent completion data. Requested data on {0}, but found completion item {1}", request.Item.Label, lastCompletionItem.DisplayText);
@@ -234,7 +234,7 @@ public async Task Handle(CompletionAfterInsertReq
var index = request.Item.Data.Index;
if (request.Item is null
- || index >= completions.Items.Length
+ || index >= completions.ItemsList.Count
|| index < 0
|| request.Item.TextEdit is null)
{
@@ -242,7 +242,7 @@ public async Task Handle(CompletionAfterInsertReq
return new CompletionAfterInsertResponse();
}
- var lastCompletionItem = completions.Items[index];
+ var lastCompletionItem = completions.ItemsList[index];
if (lastCompletionItem.DisplayTextPrefix + lastCompletionItem.DisplayText + lastCompletionItem.DisplayTextSuffix != request.Item.Label)
{
_logger.LogError("Inconsistent completion data. Requested data on {0}, but found completion item {1}", request.Item.Label, lastCompletionItem.DisplayText);
diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs
index 6801c82b9c..f2f072a128 100644
--- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs
+++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs
@@ -184,13 +184,20 @@ private bool HasFix(CodeFixProvider codeFixProvider, string diagnosticId)
private async Task CollectRefactoringActions(Document document, TextSpan span, List codeActions)
{
+ var codeActionOptions = CodeActionOptionsFactory.Create(Options);
var availableRefactorings = OrderedCodeRefactoringProviders.Value;
foreach (var codeRefactoringProvider in availableRefactorings)
{
try
{
- var context = new CodeRefactoringContext(document, span, a => codeActions.Add(a), CancellationToken.None);
+ var context = OmniSharpCodeFixContextFactory.CreateCodeRefactoringContext(
+ document,
+ span,
+ (a, _) => codeActions.Add(a),
+ codeActionOptions,
+ CancellationToken.None);
+
await codeRefactoringProvider.ComputeRefactoringsAsync(context);
}
catch (Exception ex)
diff --git a/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs b/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs
index b35e7adeb8..eac20568b4 100644
--- a/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs
+++ b/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs
@@ -5,15 +5,13 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using ICSharpCode.Decompiler.Util;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp.Formatting;
using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.DocumentationComments;
using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Formatting;
-using Microsoft.CodeAnalysis.Formatting;
+using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Options;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.Extensions.Logging;
using OmniSharp.Extensions;
using OmniSharp.Models;
using OmniSharp.Options;
@@ -105,7 +103,7 @@ private static async Task FormatDocument(Document document, OmniSharpO
{
var spans = (textSpan != null) ? new[] { textSpan.Value } : null;
var formattingOtions = await GetFormattingOptionsAsync(document, omnisharpOptions);
- var newDocument = await OmniSharpFormatter.FormatAsync(document, spans, formattingOtions, CancellationToken.None);
+ var newDocument = await OmniSharpFormatter.FormatAsync(document, spans, formattingOtions, CancellationToken.None);
if (omnisharpOptions.FormattingOptions.OrganizeImports)
{
var organizeImportsOptions = await GetOrganizeImportsOptionsAsync(document, omnisharpOptions);
@@ -117,21 +115,29 @@ private static async Task FormatDocument(Document document, OmniSharpO
// If we are not using .editorconfig for formatting options then we can avoid any overhead of calculating document options.
internal static async ValueTask GetOrganizeImportsOptionsAsync(Document document, OmniSharpOptions omnisharpOptions)
- => omnisharpOptions.FormattingOptions.EnableEditorConfigSupport
- ? await OmniSharpOrganizeImportsOptionsWrapper.FromDocumentAsync(document, CancellationToken.None)
- : WrapOrganizeImportsOptions(omnisharpOptions.FormattingOptions);
+ {
+ var fallbackOptions = WrapOrganizeImportsOptions(omnisharpOptions.FormattingOptions);
+ return omnisharpOptions.FormattingOptions.EnableEditorConfigSupport
+ ? await OmniSharpOrganizeImportsOptionsWrapper.FromDocumentAsync(document, fallbackOptions, CancellationToken.None)
+ : fallbackOptions;
+ }
// If we are not using .editorconfig for formatting options then we can avoid any overhead of calculating document options.
internal static async ValueTask GetFormattingOptionsAsync(Document document, OmniSharpOptions omnisharpOptions)
- => omnisharpOptions.FormattingOptions.EnableEditorConfigSupport
- ? await OmniSharpSyntaxFormattingOptionsWrapper.FromDocumentAsync(document, CancellationToken.None)
- : WrapFormattingOptions(omnisharpOptions.FormattingOptions);
+ {
+ var fallbackOptions = CreateLineFormattingOptions(omnisharpOptions.FormattingOptions);
+ return omnisharpOptions.FormattingOptions.EnableEditorConfigSupport
+ ? await OmniSharpSyntaxFormattingOptionsWrapper.FromDocumentAsync(document, fallbackOptions, CancellationToken.None)
+ : WrapFormattingOptions(omnisharpOptions.FormattingOptions);
+ }
// If we are not using .editorconfig for formatting options then we can avoid any overhead of calculating document options.
internal static async ValueTask GetDocumentationCommentOptionsAsync(Document document, OmniSharpOptions omnisharpOptions)
- => omnisharpOptions.FormattingOptions.EnableEditorConfigSupport
- ? await OmniSharpDocumentationCommentOptionsWrapper.FromDocumentAsync(document, autoXmlDocCommentGeneration: true, CancellationToken.None)
- : WrapDocumentationCommentOptions(omnisharpOptions.FormattingOptions);
+ {
+ return omnisharpOptions.FormattingOptions.EnableEditorConfigSupport
+ ? await OmniSharpDocumentationCommentOptionsWrapper.FromDocumentAsync(document, autoXmlDocCommentGeneration: true, CancellationToken.None)
+ : WrapDocumentationCommentOptions(omnisharpOptions.FormattingOptions);
+ }
private static OmniSharpOrganizeImportsOptionsWrapper WrapOrganizeImportsOptions(OmniSharp.Options.FormattingOptions options)
=> new(
@@ -194,11 +200,16 @@ private static OmniSharpSyntaxFormattingOptionsWrapper WrapFormattingOptions(Omn
newLineForClausesInQuery: options.NewLineForClausesInQuery);
private static OmniSharpDocumentationCommentOptionsWrapper WrapDocumentationCommentOptions(OmniSharp.Options.FormattingOptions options)
- => new(
- autoXmlDocCommentGeneration: true,
- tabSize: options.TabSize,
- useTabs: options.UseTabs,
- newLine: options.NewLine);
+ => new(autoXmlDocCommentGeneration: true, CreateLineFormattingOptions(options));
+
+ private static OmniSharpLineFormattingOptions CreateLineFormattingOptions(OmniSharp.Options.FormattingOptions options)
+ => new()
+ {
+ IndentationSize = options.IndentationSize,
+ TabSize = options.TabSize,
+ UseTabs = options.UseTabs,
+ NewLine = options.NewLine,
+ };
internal static OmniSharpLabelPositionOptions LabelPositionOptionForStringValue(string value)
=> value.ToUpper() switch
diff --git a/src/OmniSharp.Roslyn/HostServicesAggregator.cs b/src/OmniSharp.Roslyn/HostServicesAggregator.cs
index bf09d808cc..709510c6d0 100644
--- a/src/OmniSharp.Roslyn/HostServicesAggregator.cs
+++ b/src/OmniSharp.Roslyn/HostServicesAggregator.cs
@@ -2,10 +2,15 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
+using System.Composition.Hosting;
+using System.Composition.Hosting.Core;
+using System.Linq;
using System.Reflection;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using OmniSharp.Options;
using OmniSharp.Services;
namespace OmniSharp
@@ -13,11 +18,14 @@ namespace OmniSharp
[Export]
public class HostServicesAggregator
{
- private ImmutableArray _assemblies;
+ private readonly ImmutableArray _assemblies;
+ private readonly IOptionsMonitor _options;
[ImportingConstructor]
public HostServicesAggregator(
- [ImportMany] IEnumerable hostServicesProviders, ILoggerFactory loggerFactory)
+ [ImportMany] IEnumerable hostServicesProviders,
+ ILoggerFactory loggerFactory,
+ IOptionsMonitor options = null)
{
var logger = loggerFactory.CreateLogger();
var builder = ImmutableHashSet.CreateBuilder();
@@ -54,11 +62,42 @@ public HostServicesAggregator(
builder.Add(typeof(OmniSharpSymbolRenamedCodeActionOperationFactoryWorkspaceService).Assembly);
_assemblies = builder.ToImmutableArray();
+ _options = options;
}
public HostServices CreateHostServices()
{
- return MefHostServices.Create(_assemblies);
+ var config = new ContainerConfiguration()
+ // We smuggle the OmniSharpOptions from the Host container into the workspace services
+ // container so that we can provide global option fallbacks for LineFormattingOptions.
+ .WithProvider(new MefValueProvider>(_options))
+ .WithAssemblies(_assemblies.Distinct());
+ return new MefHostServices(config.CreateContainer());
+ }
+
+ internal class MefValueProvider : ExportDescriptorProvider
+ {
+ private readonly T _item;
+ private readonly IDictionary _metadata;
+
+ public MefValueProvider(T item, IDictionary metadata = null)
+ {
+ _item = item;
+ _metadata = metadata;
+ }
+
+ public override IEnumerable GetExportDescriptors(CompositionContract contract, DependencyAccessor descriptorAccessor)
+ {
+ if (contract.ContractType == typeof(T))
+ {
+ yield return new ExportDescriptorPromise(
+ contract,
+ origin: string.Empty,
+ isShared: true,
+ () => Enumerable.Empty(),
+ deps => ExportDescriptor.Create((context, operation) => _item, _metadata ?? new Dictionary()));
+ }
+ }
}
}
}
diff --git a/src/OmniSharp.Roslyn/Utilities/CodeActionOptionsFactory.cs b/src/OmniSharp.Roslyn/Utilities/CodeActionOptionsFactory.cs
index 43a1ff2854..08887f1628 100644
--- a/src/OmniSharp.Roslyn/Utilities/CodeActionOptionsFactory.cs
+++ b/src/OmniSharp.Roslyn/Utilities/CodeActionOptionsFactory.cs
@@ -7,8 +7,10 @@ namespace OmniSharp.Roslyn.CodeActions
internal static class CodeActionOptionsFactory
{
public static OmniSharpCodeActionOptions Create(OmniSharpOptions options)
- => new(new OmniSharpImplementTypeOptions(
- (OmniSharpImplementTypeInsertionBehavior)options.ImplementTypeOptions.InsertionBehavior,
- (OmniSharpImplementTypePropertyGenerationBehavior)options.ImplementTypeOptions.PropertyGenerationBehavior));
+ => new OmniSharpCodeActionOptions(
+ new OmniSharpImplementTypeOptions(
+ (OmniSharpImplementTypeInsertionBehavior)options.ImplementTypeOptions.InsertionBehavior,
+ (OmniSharpImplementTypePropertyGenerationBehavior)options.ImplementTypeOptions.PropertyGenerationBehavior),
+ OmniSharpLineFormattingOptionsProvider.CreateFromOptions(options));
}
}
diff --git a/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs b/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs
index ecb60f5ee9..eed75d08ab 100644
--- a/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs
+++ b/src/OmniSharp.Roslyn/WorkspaceServices/ExtractClassWorkspaceService.cs
@@ -16,14 +16,16 @@ public ExtractClassWorkspaceService()
{
}
- public Task GetExtractClassOptionsAsync(Document document, INamedTypeSymbol originalType, ISymbol selectedMember)
+ public Task GetExtractClassOptionsAsync(Document document, INamedTypeSymbol originalType, ImmutableArray selectedMembers)
{
- var symbolsToUse = selectedMember == null ? originalType.GetMembers().Where(member => member switch
- {
- IMethodSymbol methodSymbol => methodSymbol.MethodKind == MethodKind.Ordinary,
- IFieldSymbol fieldSymbol => !fieldSymbol.IsImplicitlyDeclared,
- _ => member.Kind == SymbolKind.Property || member.Kind == SymbolKind.Event
- }) : new ISymbol[] { selectedMember };
+ var symbolsToUse = selectedMembers.IsEmpty
+ ? originalType.GetMembers().Where(member => member switch
+ {
+ IMethodSymbol methodSymbol => methodSymbol.MethodKind == MethodKind.Ordinary,
+ IFieldSymbol fieldSymbol => !fieldSymbol.IsImplicitlyDeclared,
+ _ => member.Kind == SymbolKind.Property || member.Kind == SymbolKind.Event
+ })
+ : selectedMembers;
var memberAnalysisResults = symbolsToUse.Select(m => new OmniSharpExtractClassMemberAnalysisResult(m, makeAbstract: false)).ToImmutableArray();
const string name = "NewBaseType";
diff --git a/src/OmniSharp.Roslyn/WorkspaceServices/OmniSharpLineFormattingOptionsProvider.cs b/src/OmniSharp.Roslyn/WorkspaceServices/OmniSharpLineFormattingOptionsProvider.cs
new file mode 100644
index 0000000000..f2442e65e9
--- /dev/null
+++ b/src/OmniSharp.Roslyn/WorkspaceServices/OmniSharpLineFormattingOptionsProvider.cs
@@ -0,0 +1,33 @@
+using System.Composition;
+using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Options;
+using Microsoft.Extensions.Options;
+using OmniSharp.Options;
+
+namespace OmniSharp
+{
+ [Export(typeof(IOmniSharpLineFormattingOptionsProvider)), Shared]
+ public class OmniSharpLineFormattingOptionsProvider : IOmniSharpLineFormattingOptionsProvider
+ {
+ private readonly IOptionsMonitor _options;
+
+ [ImportingConstructor]
+ public OmniSharpLineFormattingOptionsProvider(IOptionsMonitor options)
+ {
+ _options = options;
+ }
+
+ OmniSharpLineFormattingOptions IOmniSharpLineFormattingOptionsProvider.GetLineFormattingOptions()
+ => _options is null
+ ? new OmniSharpLineFormattingOptions()
+ : CreateFromOptions(_options.CurrentValue);
+
+ internal static OmniSharpLineFormattingOptions CreateFromOptions(OmniSharpOptions options)
+ => new()
+ {
+ IndentationSize = options.FormattingOptions.IndentationSize,
+ TabSize = options.FormattingOptions.TabSize,
+ UseTabs = options.FormattingOptions.UseTabs,
+ NewLine = options.FormattingOptions.NewLine,
+ };
+ }
+}
diff --git a/src/OmniSharp.Stdio.Driver/app.config b/src/OmniSharp.Stdio.Driver/app.config
index 24ab3d4192..de37867718 100644
--- a/src/OmniSharp.Stdio.Driver/app.config
+++ b/src/OmniSharp.Stdio.Driver/app.config
@@ -7,23 +7,23 @@
-
+
-
+
-
+
-
+
-
+
diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/EditorConfigFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/EditorConfigFacts.cs
index 11c2530901..39286de099 100644
--- a/tests/OmniSharp.Roslyn.CSharp.Tests/EditorConfigFacts.cs
+++ b/tests/OmniSharp.Roslyn.CSharp.Tests/EditorConfigFacts.cs
@@ -18,8 +18,8 @@ namespace OmniSharp.Roslyn.CSharp.Tests
{
public class EditorConfigFacts : AbstractTestFixture
{
- public EditorConfigFacts(ITestOutputHelper output)
- : base(output)
+ public EditorConfigFacts(ITestOutputHelper output, SharedOmniSharpHostFixture sharedOmniSharpHostFixture)
+ : base(output, sharedOmniSharpHostFixture)
{
}
diff --git a/tests/OmniSharp.Script.Tests/ScriptProjectProviderTests.cs b/tests/OmniSharp.Script.Tests/ScriptProjectProviderTests.cs
index c9d10f2dda..c4fda182e3 100644
--- a/tests/OmniSharp.Script.Tests/ScriptProjectProviderTests.cs
+++ b/tests/OmniSharp.Script.Tests/ScriptProjectProviderTests.cs
@@ -17,7 +17,7 @@ public void DefaultLanguageVersionShouldBeLatest()
var scriptProjectProvider = new ScriptProjectProvider(new ScriptOptions(), new OmniSharpEnvironment(), new LoggerFactory(), true, false);
var scriptProjectInfo = scriptProjectProvider.CreateProject("test.csx", Enumerable.Empty(), Path.GetTempPath(), typeof(CommandLineScriptGlobals));
Assert.Equal(LanguageVersion.Latest, ((CSharpParseOptions)scriptProjectInfo.ParseOptions).SpecifiedLanguageVersion);
- Assert.Equal(LanguageVersion.CSharp10, ((CSharpParseOptions)scriptProjectInfo.ParseOptions).LanguageVersion);
+ Assert.Equal(LanguageVersion.CSharp11, ((CSharpParseOptions)scriptProjectInfo.ParseOptions).LanguageVersion);
}
}
}
diff --git a/tests/TestUtility/TestHelpers.cs b/tests/TestUtility/TestHelpers.cs
index de7f6624b5..54bbd59ed9 100644
--- a/tests/TestUtility/TestHelpers.cs
+++ b/tests/TestUtility/TestHelpers.cs
@@ -97,8 +97,15 @@ public static IEnumerable AddProjectToWorkspace(OmniSharpWorkspace wo
return projectsIds;
}
+ private static ImmutableArray _references;
+
private static IEnumerable GetReferences()
{
+ if (!_references.IsDefaultOrEmpty)
+ {
+ return _references;
+ }
+
// This is a bit messy. Essentially, we need to add all assemblies that type forwarders might point to.
var assemblies = new[]
{
@@ -114,13 +121,14 @@ private static IEnumerable GetReferences()
#endif
};
- var references = assemblies
+ _references = assemblies
.Where(a => a != null)
.Select(a => a.Location)
.Distinct()
- .Select(l => MetadataReference.CreateFromFile(l));
+ .Select(l => MetadataReference.CreateFromFile(l))
+ .ToImmutableArray();
- return references;
+ return _references;
}
public static MSBuildInstance AddDotNetCoreToFakeInstance(this MSBuildInstance instance)
diff --git a/tests/app.config b/tests/app.config
index 71f57a112e..5b1948d89f 100644
--- a/tests/app.config
+++ b/tests/app.config
@@ -7,23 +7,23 @@
-
+
-
+
-
+
-
+
-
+