Skip to content
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

Allow OmniSharp to provide ImplementType Options #75312

Merged
merged 6 commits into from
Dec 19, 2024

Conversation

JoeRobich
Copy link
Member

@JoeRobich JoeRobich commented Oct 1, 2024

This should allow OmniSharp to provide ImplementType Options at the workspace level. Something similar to their CSharpFormattingWorkspaceOptionsProvider. Will be inserted into O# as part of OmniSharp/omnisharp-roslyn#2642

@JoeRobich JoeRobich requested a review from tmat October 1, 2024 08:44
@JoeRobich JoeRobich requested a review from a team as a code owner October 1, 2024 08:44
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 1, 2024
@JoeRobich
Copy link
Member Author

@tmat Could you take a look? You know this area better than most.

@JoeRobich JoeRobich force-pushed the dev/jorobich/update-o#-ea branch from bbc2cf4 to 8f1a5c6 Compare December 18, 2024 09:39
Copy link
Member Author

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmat I updated based on your suggestions. Please review.

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests" />
<!--
⚠ ONLY OMNISHARP ASSEMBLIES MAY BE ADDED HERE ⚠
-->
<InternalsVisibleTo Include="OmniSharp.Host" Key="$(OmniSharpKey)" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O# keeps the workspace options updated in this assembly.


namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Options;

internal sealed record class OmniSharpEditorConfigOptions
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the time being these are the only fallback options that have matching O# options

var oldFallbackOptions = oldSolution.FallbackAnalyzerOptions;
oldFallbackOptions.TryGetValue(LanguageNames.CSharp, out var csharpFallbackOptions);

var changedOptions = DetermineChangedOptions(csharpFallbackOptions, editorConfigOptions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to determine changed options? Why not set all the O# options unconditionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that simplifies a lot. Thanks!

@JoeRobich
Copy link
Member Author

@tmat updated! Thanks


namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Options;

using Workspace = CodeAnalysis.Workspace;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workspace conflicts because there is a Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Workspace namespace.

@JoeRobich JoeRobich merged commit d4b570f into main Dec 19, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Dec 19, 2024
{
var configName = option.Definition.ConfigName;
var configValue = option.Definition.Serializer.Serialize(value);
builder.Add(configName, configValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not replace the value if it already exists?

static void AddOption<T>(
PerLanguageOption2<T> option,
T value,
ImmutableDictionary<string, string>.Builder builder)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can make this function non-static and remove builder param.

JoeRobich added a commit that referenced this pull request Dec 20, 2024
@JoeRobich JoeRobich deleted the dev/jorobich/update-o#-ea branch December 20, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants