Skip to content

Selectively persist the commandline to temporary storage #78441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ private bool ReparseCommandLineIfChanged_NoLock(ImmutableArray<string> arguments

_commandLineChecksum = checksum;

ReparseCommandLine_NoLock(arguments);

// Dispose the existing stored command-line and then persist the new one so we can
// recover it later. Only bother persisting things if we have a non-empty string.
// recover it later. Only bother persisting things if we have a non-empty string
// and there is an effective ruleset (as that ends up adding RuleSetFile_UpdatedOnDisk
// as an event handler which is the only consumer of _commandLineStorageHandle)

_commandLineStorageHandle = null;
if (!arguments.IsEmpty)
if (!arguments.IsEmpty && GetEffectiveRulesetFilePath() != null)
{
using var stream = SerializableBytes.CreateWritableStream();
using var writer = new StreamWriter(stream);
Expand All @@ -86,7 +90,6 @@ private bool ReparseCommandLineIfChanged_NoLock(ImmutableArray<string> arguments
_commandLineStorageHandle = _temporaryStorageService.WriteToTemporaryStorage(stream, CancellationToken.None);
}

ReparseCommandLine_NoLock(arguments);
return true;
}

Expand Down Expand Up @@ -173,9 +176,12 @@ public CommandLineArguments GetParsedCommandLineArguments()
return _commandLineArgumentsForCommandLine;
}

private string? GetEffectiveRulesetFilePath()
=> ExplicitRuleSetFilePath ?? _commandLineArgumentsForCommandLine.RuleSetPath;

private void UpdateProjectOptions_NoLock()
{
var effectiveRuleSetPath = ExplicitRuleSetFilePath ?? _commandLineArgumentsForCommandLine.RuleSetPath;
var effectiveRuleSetPath = GetEffectiveRulesetFilePath();

if (_ruleSetFile?.Target.Value.FilePath != effectiveRuleSetPath)
{
Expand Down
Loading