Skip to content

Commit

Permalink
Merge pull request #34267 from dotnet/merges/dev16.0-to-dev16.0-vs-deps
Browse files Browse the repository at this point in the history
Merge dev16.0 to dev16.0-vs-deps
  • Loading branch information
dotnet-automerge-bot authored Mar 20, 2019
2 parents 620cadb + 1101524 commit 1deafee
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 42 deletions.
3 changes: 0 additions & 3 deletions src/Tools/ILAsm/IlAsmDeploy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
<TargetLatestRuntimePatch>false</TargetLatestRuntimePatch>
<SelfContained>true</SelfContained>

<!-- Do not build again when publishing -->
<NoBuild>true</NoBuild>

<PublishDir>$(ArtifactsDir)tools\ILAsm\$(Configuration)\</PublishDir>
</PropertyGroup>

Expand Down
39 changes: 32 additions & 7 deletions src/VisualStudio/Core/Impl/Options/AbstractOptionPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ internal abstract class AbstractOptionPage : UIElementDialogPage
{
private static IOptionService s_optionService;
private static OptionStore s_optionStore;
private static bool s_needsLoadOnNextActivate = true;
private static bool s_needsToUpdateOptionStore = true;

private bool _needsLoadOnNextActivate = true;

protected abstract AbstractOptionPageControl CreateOptionPage(IServiceProvider serviceProvider, OptionStore optionStore);

Expand Down Expand Up @@ -50,16 +52,22 @@ protected override void OnActivate(System.ComponentModel.CancelEventArgs e)
{
EnsureOptionPageCreated();

if (s_needsLoadOnNextActivate)
if (s_needsToUpdateOptionStore)
{
// Reset the option store to the current state of the options.
s_optionStore.SetOptions(s_optionService.GetOptions());
s_optionStore.SetRegisteredOptions(s_optionService.GetRegisteredOptions());

s_needsLoadOnNextActivate = false;
s_needsToUpdateOptionStore = false;
}

pageControl.LoadSettings();
if (_needsLoadOnNextActivate)
{
// For pages that don't use option bindings we need to load setting changes.
pageControl.OnLoad();

_needsLoadOnNextActivate = false;
}
}

public override void LoadSettingsFromStorage()
Expand All @@ -81,19 +89,36 @@ public override void LoadSettingsFromStorage()
// they may have been changed programmatically. Therefore, we'll set a flag so we load
// next time

s_needsLoadOnNextActivate = pageControl != null;
// When pageControl is null we know that Activation has not happened for this page.
// We only need to update the OptionStore after a cancel or close click (2).
s_needsToUpdateOptionStore = pageControl != null;

// For pages that don't use option bindings we need to load settings when it is
// activated next.
_needsLoadOnNextActivate = true;
}

public override void SaveSettingsToStorage()
{
EnsureOptionPageCreated();

// Allow page controls to perist their settings to the option store before updating the
// option service.
pageControl.OnSave();

// Save the changes that were accumulated in the option store.
s_optionService.SetOptions(s_optionStore.GetOptions());
var oldOptions = s_optionService.GetOptions();
var newOptions = s_optionStore.GetOptions();
s_optionService.SetOptions(newOptions);
OptionLogger.Log(oldOptions, newOptions);

// Make sure we load the next time a page is activated, in case that options changed
// programmatically between now and the next time the page is activated
s_needsLoadOnNextActivate = true;
s_needsToUpdateOptionStore = true;

// For pages that don't use option bindings we need to load settings when it is
// activated next.
_needsLoadOnNextActivate = true;
}

protected override void OnClosed(EventArgs e)
Expand Down
13 changes: 2 additions & 11 deletions src/VisualStudio/Core/Impl/Options/AbstractOptionPageControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,16 @@ protected void BindToFullSolutionAnalysisOption(CheckBox checkbox, string langua
_bindingExpressions.Add(bindingExpression);
}

internal virtual void LoadSettings()
internal virtual void OnLoad()
{
foreach (var bindingExpression in _bindingExpressions)
{
bindingExpression.UpdateTarget();
}
}

internal virtual void SaveSettings()
internal virtual void OnSave()
{
foreach (var bindingExpression in _bindingExpressions)
{
if (!bindingExpression.IsDirty)
{
continue;
}

bindingExpression.UpdateSource();
}
}

internal virtual void Close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void Options_PreviewKeyDown(object sender, KeyEventArgs e)
}
}

internal override void LoadSettings()
internal override void OnLoad()
{
this.ViewModel = _createViewModel(OptionStore, _serviceProvider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void Options_PreviewKeyDown(object sender, KeyEventArgs e)
}
}

internal override void LoadSettings()
internal override void OnLoad()
{
this.ViewModel = _createViewModel(this.OptionStore, _serviceProvider);

Expand Down
10 changes: 3 additions & 7 deletions src/VisualStudio/Core/Impl/Options/OptionStore.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Options;

Expand Down Expand Up @@ -28,27 +30,21 @@ public OptionStore(OptionSet optionSet, IEnumerable<IOption> registeredOptions)

public void SetOption(OptionKey optionKey, object value)
{
var oldOptions = _optionSet;
_optionSet = _optionSet.WithChangedOption(optionKey, value);
OptionLogger.Log(oldOptions, _optionSet);

OnOptionChanged(optionKey);
}

public void SetOption<T>(Option<T> option, T value)
{
var oldOptions = _optionSet;
_optionSet = _optionSet.WithChangedOption(option, value);
OptionLogger.Log(oldOptions, _optionSet);

OnOptionChanged(new OptionKey(option));
}

public void SetOption<T>(PerLanguageOption<T> option, string language, T value)
{
var oldOptionSet = _optionSet;
_optionSet = _optionSet.WithChangedOption(option, language, value);
OptionLogger.Log(oldOptionSet, _optionSet);

OnOptionChanged(new OptionKey(option, language));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal NamingStyleOptionPageControl(OptionStore optionStore, INotificationServ
_notificationService = notificationService;

InitializeComponent();
LoadSettings();
OnLoad();
}

private NamingStyleOptionPageViewModel.NamingRuleViewModel CreateItemWithNoSelections()
Expand Down Expand Up @@ -139,7 +139,7 @@ private void SetFocusToSelectedRow()
}
}

internal override void SaveSettings()
internal override void OnSave()
{
var symbolSpecifications = ArrayBuilder<SymbolSpecification>.GetInstance();
var namingRules = ArrayBuilder<SerializableNamingRule>.GetInstance();
Expand Down Expand Up @@ -177,15 +177,12 @@ internal override void SaveSettings()
namingStyles.ToImmutableAndFree(),
namingRules.ToImmutableAndFree());

var oldOptions = OptionStore.GetOptions();
var newOptions = oldOptions.WithChangedOption(SimplificationOptions.NamingPreferences, _languageName, info);
OptionStore.SetOptions(newOptions);
OptionLogger.Log(oldOptions, newOptions);
OptionStore.SetOption(SimplificationOptions.NamingPreferences, _languageName, info);
}

internal override void LoadSettings()
internal override void OnLoad()
{
base.LoadSettings();
base.OnLoad();

var preferences = OptionStore.GetOption(SimplificationOptions.NamingPreferences, _languageName);
if (preferences == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class IterationDataAttribute : DataAttribute
{
public IterationDataAttribute(int iterations = 100)
{
Iterations = 100;
Iterations = iterations;
}

public int Iterations { get; }
Expand Down
7 changes: 4 additions & 3 deletions src/Workspaces/Core/Portable/Workspace/TextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ public static Document GetOpenDocumentInCurrentContextWithChanges(this SourceTex
{
if (Workspace.TryGetWorkspace(text.Container, out var workspace))
{
var solution = workspace.CurrentSolution;
var id = workspace.GetDocumentIdInCurrentContext(text.Container);
if (id == null || !workspace.CurrentSolution.ContainsDocument(id))
if (id == null || !solution.ContainsDocument(id))
{
return null;
}

var sol = workspace.CurrentSolution.WithDocumentText(id, text, PreservationMode.PreserveIdentity);
return sol.GetDocument(id);
return solution.WithDocumentText(id, text, PreservationMode.PreserveIdentity)
.GetDocument(id);
}

return null;
Expand Down

0 comments on commit 1deafee

Please sign in to comment.