Skip to content

Commit

Permalink
Add views for naming styles
Browse files Browse the repository at this point in the history
This adds a new tab for the naming style options that were exposed via services in a previous commit
  • Loading branch information
jmarolf committed Dec 2, 2021
1 parent 682a9df commit a773abe
Show file tree
Hide file tree
Showing 26 changed files with 818 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ internal static class CodeStyle
public const string Location = Prefix + CodeStylePrefix + "location";
}

internal static class NamingStyle
{
private const string NamingStylePrefix = "namingstyle.";
public const string Type = Prefix + NamingStylePrefix + "type";
public const string Style = Prefix + NamingStylePrefix + "style";
public const string Severity = Prefix + NamingStylePrefix + "severityname";
public const string Location = Prefix + NamingStylePrefix + "location";
}

internal static class Whitespace
{
private const string FormattingPrefix = "whitespace.";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.ComponentModel.Composition;
using System.Windows;
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Data;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.ColumnDefinitions
{
using static Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.Common.ColumnDefinitions.NamingStyle;

[Export(typeof(ITableColumnDefinition))]
[Name(Location)]
internal class NamingStylesLocationColumnDefinition : TableColumnDefinitionBase
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public NamingStylesLocationColumnDefinition()
{
}

public override string Name => Location;
public override string DisplayName => ServicesVSResources.Location;
public override double MinWidth => 350;
public override bool DefaultVisible => true;
public override bool IsFilterable => true;
public override bool IsSortable => true;

public override bool TryCreateColumnContent(
ITableEntryHandle entry,
bool singleColumnView,
out FrameworkElement? content)
{
if (!entry.TryGetValue(Location, out NamingStyleSetting setting))
{
content = null;
return false;
}

var viewModel = new NamingStylesLocationViewModel(setting);
var control = new NamingStylesLocationControl(viewModel);
content = control;
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.ComponentModel.Composition;
using System.Windows;
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Data;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.ColumnDefinitions
{
using static Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.Common.ColumnDefinitions.NamingStyle;

[Export(typeof(ITableColumnDefinition))]
[Name(Severity)]
internal class NamingStylesSeverityColumnDefinition : TableColumnDefinitionBase
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public NamingStylesSeverityColumnDefinition()
{
}

public override string Name => Severity;
public override string DisplayName => ServicesVSResources.Severity;
public override bool IsFilterable => false;
public override bool IsSortable => false;
public override double MinWidth => 120;

public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement? content)
{
if (!entry.TryGetValue(Severity, out NamingStyleSetting setting))
{
content = null;
return false;
}

var viewModel = new NamingStylesSeverityViewModel(setting);
var control = new NamingStylesSeverityControl(viewModel);
content = control;
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.ComponentModel.Composition;
using System.Windows;
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Data;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.ColumnDefinitions
{
using static Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.Common.ColumnDefinitions.NamingStyle;

[Export(typeof(ITableColumnDefinition))]
[Name(Style)]
internal class NamingStylesStyleColumnDefinition : TableColumnDefinitionBase
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public NamingStylesStyleColumnDefinition()
{
}

public override string Name => Style;
public override string DisplayName => ServicesVSResources.Naming_Style;
public override bool IsFilterable => true;
public override bool IsSortable => true;
public override double MinWidth => 350;

public override bool TryCreateColumnContent(ITableEntryHandle entry, bool singleColumnView, out FrameworkElement? content)
{
if (!entry.TryGetValue(Style, out NamingStyleSetting setting))
{
content = null;
return false;
}

var viewModel = new NamingStylesStyleViewModel(setting);
var control = new NamingStylesStyleControl(viewModel);
content = control;
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.ComponentModel.Composition;
using System.Windows;
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Data;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.ColumnDefinitions
{
using static Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.Common.ColumnDefinitions.NamingStyle;

[Export(typeof(ITableColumnDefinition))]
[Name(Type)]
internal class NamingStylesTypeColumnDefinition : TableColumnDefinitionBase
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public NamingStylesTypeColumnDefinition()
{
}

public override string Name => Type;
public override string DisplayName => ServicesVSResources.Type;
public override bool IsFilterable => true;
public override bool IsSortable => true;
public override double MinWidth => 350;

public override bool TryCreateColumnContent(
ITableEntryHandle entry,
bool singleColumnView,
out FrameworkElement? content)
{
if (!entry.TryGetValue(Type, out NamingStyleSetting setting))
{
content = null;
return false;
}

var viewModel = new NamingStylesTypeViewModel(setting);
var control = new NamingStylesTypeControl(viewModel);
content = control;
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<UserControl x:Class="Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.NamingStylesLocationControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:namingStyleViewModel="clr-namespace:Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel"
d:DataContext="{d:DesignInstance Type=namingStyleViewModel:NamingStylesLocationViewModel}"
mc:Ignorable="d"
x:ClassModifier="internal">
<Grid x:Name="RootGrid">
<Label x:Name="NamingStyleLocationLabel"
Content="{Binding LocationValue}"
ToolTip="{Binding LocationToolTip}"
AutomationProperties.Name="{Binding LocationAutomationName}" />
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows.Controls;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View
{
/// <summary>
/// Interaction logic for NamingStylesLocationControl.xaml
/// </summary>
internal partial class NamingStylesLocationControl : UserControl
{
public NamingStylesLocationControl(NamingStylesLocationViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<UserControl x:Class="Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.NamingStylesSeverityControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:namingStyleViewModel="clr-namespace:Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel"
d:DataContext="{d:DesignInstance Type=namingStyleViewModel:NamingStylesSeverityViewModel}"
mc:Ignorable="d"
x:ClassModifier="internal">
<Grid x:Name="RootGrid">
<ComboBox x:Name="SeverityComboBox"
ItemsSource="{Binding Severities}"
SelectedValue="{Binding SelectedSeverityValue}"
ToolTip="{Binding SeverityToolTip}"
AutomationProperties.Name="{Binding SeverityAutomationName}"
SelectionChanged="SeverityComboBox_SelectionChanged" />
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows.Controls;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View
{
/// <summary>
/// Interaction logic for NamingStylesSeverityControl.xaml
/// </summary>
internal partial class NamingStylesSeverityControl : UserControl
{
private readonly NamingStylesSeverityViewModel _viewModel;

public NamingStylesSeverityControl(NamingStylesSeverityViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
DataContext = viewModel;
}

private void SeverityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
=> _viewModel.SelectionChanged(SeverityComboBox.SelectedIndex);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<UserControl x:Class="Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.NamingStylesStyleControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:namingStyleViewModel="clr-namespace:Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel"
d:DataContext="{d:DesignInstance Type=namingStyleViewModel:NamingStylesStyleViewModel}"
mc:Ignorable="d"
x:ClassModifier="internal">
<Grid x:Name="RootGrid">
<ComboBox x:Name="StyleComboBox"
ItemsSource="{Binding StyleValues}"
SelectedValue="{Binding SelectedStyleValue}"
ToolTip="{Binding StyleToolTip}"
AutomationProperties.Name="{Binding StyleAutomationName}"
SelectionChanged="StyleComboBox_SelectionChanged"/>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows.Controls;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View
{
/// <summary>
/// Interaction logic for NamingStylesStyleControl.xaml
/// </summary>
internal partial class NamingStylesStyleControl : UserControl
{
private readonly NamingStylesStyleViewModel _viewModel;

public NamingStylesStyleControl(NamingStylesStyleViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
DataContext = viewModel;
}

private void StyleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
=> _viewModel.SelectionChanged(StyleComboBox.SelectedIndex);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<UserControl x:Class="Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View.NamingStylesTypeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:namingStyleViewModel="clr-namespace:Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel"
d:DataContext="{d:DesignInstance Type=namingStyleViewModel:NamingStylesTypeViewModel}"
mc:Ignorable="d"
x:ClassModifier="internal">
<Grid x:Name="RootGrid">
<Label x:Name="NamingStyleTypeLabel"
Content="{Binding TypeValue}"
ToolTip="{Binding TypeToolTip}"
AutomationProperties.Name="{Binding TypeAutomationName}" />
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows.Controls;
using Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.ViewModel;

namespace Microsoft.VisualStudio.LanguageServices.EditorConfigSettings.NamingStyle.View
{
/// <summary>
/// Interaction logic for NamingStylesTypeControl.xaml
/// </summary>
internal partial class NamingStylesTypeControl : UserControl
{
public NamingStylesTypeControl(NamingStylesTypeViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
}
}
}
Loading

0 comments on commit a773abe

Please sign in to comment.