Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix NGEN By Moving EditorSettings Back To Workspaces Layer #8282

Merged
merged 3 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using Microsoft.Extensions.Internal;

namespace Microsoft.CodeAnalysis.Razor.Editor;

public sealed class EditorSettings : IEquatable<EditorSettings>
{
public static readonly EditorSettings Default = new(indentWithTabs: false, indentSize: 4);

public EditorSettings(bool indentWithTabs, int indentSize)
{
if (indentSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(indentSize));
}

IndentWithTabs = indentWithTabs;
IndentSize = indentSize;
}

public bool IndentWithTabs { get; }

public int IndentSize { get; }

public bool Equals(EditorSettings? other)
=> other is not null &&
IndentWithTabs == other.IndentWithTabs &&
IndentSize == other.IndentSize;

public override bool Equals(object? other)
{
return Equals(other as EditorSettings);
}

public override int GetHashCode()
{
var combiner = HashCodeCombiner.Start();
combiner.Add(IndentWithTabs);
combiner.Add(IndentSize);

return combiner.CombinedHash;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;

namespace Microsoft.CodeAnalysis.Razor.Editor;

public sealed class EditorSettingsChangedEventArgs : EventArgs
{
public EditorSettingsChangedEventArgs(EditorSettings settings)
{
if (settings is null)
{
throw new ArgumentNullException(nameof(settings));
}

Settings = settings;
}

public EditorSettings Settings { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

namespace Microsoft.VisualStudio.Editor.Razor;

internal abstract class EditorSettingsChangedTrigger
{
public abstract void Initialize(EditorSettingsManager editorSettingsManager);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using Microsoft.CodeAnalysis.Razor.Editor;
using Microsoft.Extensions.Internal;

namespace Microsoft.VisualStudio.Editor.Razor;

Expand All @@ -15,57 +14,3 @@ public abstract class EditorSettingsManager

public abstract void Update(EditorSettings updateSettings);
}

public sealed class EditorSettingsChangedEventArgs : EventArgs
{
public EditorSettingsChangedEventArgs(EditorSettings settings)
{
if (settings is null)
{
throw new ArgumentNullException(nameof(settings));
}

Settings = settings;
}

public EditorSettings Settings { get; }
}

public sealed class EditorSettings : IEquatable<EditorSettings>
ryzngard marked this conversation as resolved.
Show resolved Hide resolved
{
public static readonly EditorSettings Default = new(indentWithTabs: false, indentSize: 4);

public EditorSettings(bool indentWithTabs, int indentSize)
{
if (indentSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(indentSize));
}

IndentWithTabs = indentWithTabs;
IndentSize = indentSize;
}

public bool IndentWithTabs { get; }

public int IndentSize { get; }

public bool Equals(EditorSettings? other)
=> other is not null &&
IndentWithTabs == other.IndentWithTabs &&
IndentSize == other.IndentSize;

public override bool Equals(object? other)
{
return Equals(other as EditorSettings);
}

public override int GetHashCode()
{
var combiner = HashCodeCombiner.Start();
combiner.Add(IndentWithTabs);
combiner.Add(IndentSize);

return combiner.CombinedHash;
}
}