Skip to content

SerializableOptionSet and IOptionService cleanup#61839

Merged
tmat merged 14 commits intodotnet:mainfrom
tmat:SerializableOptionSet
Jun 16, 2022
Merged

SerializableOptionSet and IOptionService cleanup#61839
tmat merged 14 commits intodotnet:mainfrom
tmat:SerializableOptionSet

Conversation

@tmat
Copy link
Copy Markdown
Member

@tmat tmat commented Jun 12, 2022

Remove code that's no longer needed.

Recommended to review commit by commit.

@ghost ghost added the Area-IDE label Jun 12, 2022
@tmat tmat force-pushed the SerializableOptionSet branch from 8e0b751 to 9b54569 Compare June 13, 2022 19:50
@tmat tmat changed the title Serializable option set SerializableOptionSet and IOptionService cleanup Jun 14, 2022
@tmat tmat marked this pull request as ready for review June 14, 2022 00:59
@tmat tmat requested review from a team as code owners June 14, 2022 00:59
/// character. The position provided is the position of the caret in the document after
/// the character been inserted into the document.
/// </summary>
[Obsolete("Use the other overload")]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No longer used by Razor.

ValidateOrganizeImportsOptions(await Formatter.GetOrganizeImportsOptionsAsync(csDocumentWithUpdatedOptions, CancellationToken.None));
ValidateOrganizeImportsOptions(await Formatter.GetOrganizeImportsOptionsAsync(vbDocumentWithUpdatedOptions, CancellationToken.None));

static OptionSet GetOptionSetWithChangedPublicOptions(OptionSet options)
Copy link
Copy Markdown
Member Author

@tmat tmat Jun 14, 2022

Choose a reason for hiding this comment

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

namespace Microsoft.CodeAnalysis.UnitTests
{
internal static class TestOptionService
{
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Methods moved to src/Workspaces/CoreTest/WorkspaceServiceTests/GlobalOptionServiceTests.cs

_changedOptionKeysNonSerializable.Add(optionKey));
_globalOptions,
_values.SetItem(optionKey, value),
_changedOptionKeys.Add(optionKey));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The uses of _values and _changedOptionKeys was a little confusing to me at first. Am wondering if it would make sense to store a single map of changedKey:changedValue (assuming of course that the _globalOptions.GetOption doesn't have perf concerns).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, so I was being careful here. _globalOptions.GetOption is locking and reading/writing option value to persisters. I think the reason why we have separate _changedOptionKeys is that the _values serve as a cache for options that are read from the global options but not changed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also a bit unclear to me. consider doc'ing more.

Debug.Fail($"Failed to deserialize: {name}-{feature}-{isPerLanguage}-{language}");
return null;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this makes me so happy

}
}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove :) (i can't suggest an edit for some reason).

/// Gets force computed serializable options snapshot with prefetched values for the registered options applicable to the given <paramref name="languages"/> by quering the option persisters.
/// </summary>
SerializableOptionSet GetSerializableOptionsSnapshot(ImmutableHashSet<string> languages, IOptionService optionService);
SerializableOptionSet GetOptions(IOptionService optionService);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

might be good to have a doc comment on this.

WorkspaceOptionSet workspaceOptionSet,
ImmutableDictionary<OptionKey, object?> values,
ImmutableHashSet<OptionKey> changedOptionKeysSerializable,
ImmutableHashSet<OptionKey> changedOptionKeysNonSerializable)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's the current use case for changedOptionKeysNonSerializable? how does that work? (feel free to not have an answer... i'm just still uncertain about those guys).


return Comparer.Default.Compare(x.GetHashCode(), y.GetHashCode());
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this hte best PR ever.

/// It contains prepopulated fetched option values for all serializable options and values, and delegates to <see cref="WorkspaceOptionSet"/> for non-serializable values.
/// It ensures a contract that values are immutable from this instance once observed.
/// </summary>
internal sealed partial class SerializableOptionSet : OptionSet
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

consider adding doc comment back that explains what the purpose o fthis type actualy is.

private readonly ImmutableHashSet<OptionKey> _changedOptionKeysNonSerializable;
private ImmutableDictionary<OptionKey, object?> _values;

private readonly ImmutableHashSet<OptionKey> _changedOptionKeys;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

def doc.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Overall fantastic. Def have some calrifying questions, and requests for docs. Anything we expect to be a long lived type in our repo, i'd like some docs on. If there are other types we expect are going to go away shortly, then we don't need to doc, but i'd like clarity on which fall into that bucket and if we're going to tackle them soon.

Thanks!

@tmat tmat force-pushed the SerializableOptionSet branch from 78e13b9 to 7421dd7 Compare June 16, 2022 00:53
@tmat tmat enabled auto-merge (squash) June 16, 2022 00:53
@tmat tmat force-pushed the SerializableOptionSet branch from 7421dd7 to ca61166 Compare June 16, 2022 05:33
@tmat tmat disabled auto-merge June 16, 2022 22:08
@tmat
Copy link
Copy Markdown
Member Author

tmat commented Jun 16, 2022

/azp run

@tmat tmat enabled auto-merge (squash) June 16, 2022 22:19
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@tmat tmat merged commit 2f9faa0 into dotnet:main Jun 16, 2022
@ghost ghost added this to the Next milestone Jun 16, 2022
@tmat tmat deleted the SerializableOptionSet branch June 17, 2022 03:55
chsienki added a commit to chsienki/roslyn that referenced this pull request Jun 23, 2022
@RikkiGibson RikkiGibson modified the milestones: Next, 17.3 P3 Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants