Skip to content
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

Add a link to Tools>Options>…>Code Style to link to EditorConfig documentation. Bug#23513 #24279

Merged
merged 7 commits into from Jan 18, 2018

Conversation

JieCarolHu
Copy link
Contributor

@JieCarolHu JieCarolHu commented Jan 17, 2018

Fixes : #23513

Customer scenario

Add a link to EditorConfig documentation in Tools>Options>…>Code Style

Bugs this fixes

#23513

Workarounds, if any

Not needed

Risk

low risk because it only adds a hyper link the code style page

Performance impact

Low perf impact because no extra allocations/no complexity changes

Is this a regression from a previous update?

No

Root cause analysis

Not needed.

How was the bug found?

Not applicable

Test documentation updated?

Not needed

@JieCarolHu JieCarolHu added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jan 17, 2018
@JieCarolHu JieCarolHu requested a review from a team as a code owner January 17, 2018 04:05

namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
{
internal partial class GridOptionPreviewControl : AbstractOptionPageControl
{
private static string useEditorConfigUrl = "https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference";
Copy link
Contributor

Choose a reason for hiding this comment

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

@kuhlenh should we create a fwklink instead here ?

Copy link
Member

Choose a reason for hiding this comment

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

Or an aka.ms link. Correct: no harcoding URLs though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@jinujoseph
Copy link
Contributor

jinujoseph commented Jan 17, 2018

@JieCarolHu , Thanks for the fast fix here. Can you also paste what the UI looks like

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

Since this is a control/UI change, can you include a screenshot showing the result of the change? I also have a few questions in the diff.

@@ -5,7 +5,7 @@
xmlns:converters="clr-namespace:Microsoft.VisualStudio.LanguageServices.Implementation.Options.Converters"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Copy link
Member

Choose a reason for hiding this comment

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

💡 Try to avoid changes to unrelated lines in the file. Either of the following approaches is acceptable:

  1. Disable the IDE feature which is causing this whitespace to be removed when the file is edited and/or saved
  2. When committing changes to Git, commit the changes on a line-by-line basis while manually avoiding the lines which only have whitespace changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any option in Visual Studio to disable the auto removing trailing whitespace, maybe we should build one? ;)
https://social.msdn.microsoft.com/Forums/vstudio/en-US/3c2eb7a1-3ddc-4b67-8105-ee30ab7661d2/how-to-prevent-visual-studio-from-removing-all-trailing-whitespaces?forum=vcgeneral

I figured out if I append ?w=1 at the end of the GitHub url, it does not show the whitespace change. check out this: https://github.com/dotnet/roslyn/pull/24279/files?w=1

@@ -35,12 +35,18 @@
<converters:MarginConverter x:Key="MarginConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
Copy link
Member

Choose a reason for hiding this comment

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

💡 The height for this row should (probably) be automatically determined based on the row content.

<RowDefinition Height="Auto" />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -29,6 +40,17 @@ internal partial class GridOptionPreviewControl : AbstractOptionPageControl
_createViewModel = createViewModel;
}

private void LearnMoreHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
if (e.Uri == null)
Copy link
Member

Choose a reason for hiding this comment

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

❔ Is this possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could you pls elaborate?

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for e.Uri to be null? It seems like this is an unnecessary null check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I searched through the Roslyn solution code base, and it looks like we always check if the uri is null before calling BrowserHelper.StartBrowser(uri). And I prefer to do unnecessary check than the possibility of running into NullReferenceException later..

internal AbstractOptionPreviewViewModel ViewModel;
private readonly IServiceProvider _serviceProvider;
private readonly Func<OptionSet, IServiceProvider, AbstractOptionPreviewViewModel> _createViewModel;

// to leave a space between the end of sentence and "learn more" link
public static string CodeStylePageHeader => ServicesVSResources.Code_style_header_use_editor_config + " ";
Copy link
Member

Choose a reason for hiding this comment

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

💡 Add the space in the view, not here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="{x:Static local:GridOptionPreviewControl.CodeStylePageHeader}" >
Copy link
Member

Choose a reason for hiding this comment

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

💭 I would have expected the text to be set using the following as a child element, before the hyperlink:

<Run Text="..."/>

❓ Does this need TextWrapping="Wrap" for cases where the dialog is not wide enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="{x:Static local:GridOptionPreviewControl.CodeStylePageHeader}" >
<Hyperlink RequestNavigate="LearnMoreHyperlink_RequestNavigate" NavigateUri="{x:Static local:GridOptionPreviewControl.CodeStylePageHeaderLearnMoreUri}">
Copy link
Member

Choose a reason for hiding this comment

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

💡 You should be able to use Margin="2,0" on either the Hyperlink or the nested TextBlock element to add the space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added after the CodeStylePageHeader text
Hyperlink does not support Margin; if I add Margin to TextBlock, then I can see the hyperlink underline actually starts with an empty space
image

// to leave a space between the end of sentence and "learn more" link
public static string CodeStylePageHeader => ServicesVSResources.Code_style_header_use_editor_config + " ";
public static string CodeStylePageHeaderLearnMoreText => ServicesVSResources.Learn_more;
public static Uri CodeStylePageHeaderLearnMoreUri = new Uri(useEditorConfigUrl);
Copy link
Member

Choose a reason for hiding this comment

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

💡 Place fields above properties

💡 This field can be made readonly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

internal AbstractOptionPreviewViewModel ViewModel;
private readonly IServiceProvider _serviceProvider;
private readonly Func<OptionSet, IServiceProvider, AbstractOptionPreviewViewModel> _createViewModel;

// to leave a space between the end of sentence and "learn more" link
public static string CodeStylePageHeader => ServicesVSResources.Code_style_header_use_editor_config + " ";
public static string CodeStylePageHeaderLearnMoreText => ServicesVSResources.Learn_more;
Copy link
Member

Choose a reason for hiding this comment

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

❓ In our normal pattern to create wrapper properties for text like this? It seems easier to simply bind the control directly to ServicesVSResources.Learn_more.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think there was some screwy problem if you did it directly. @dpoeschl might remember?

@kuhlenh
Copy link

kuhlenh commented Jan 17, 2018

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Requesting changes to ensure the link is replaced with either a fwlink or aka.ms link.

@@ -1015,4 +1015,7 @@ I agree to all of the foregoing:</value>
<data name="Decompiler_Legal_Notice_Title" xml:space="preserve">
<value>Decompiler Legal Notice</value>
</data>
</root>
<data name="Code_style_header_use_editor_config" xml:space="preserve">
<value>The settings configured here only apply to your machine. To configure these settings to travel with your solution, use EditorConfig.</value>
Copy link
Member

Choose a reason for hiding this comment

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

".editorconfig files"? (with the dot). People who know what the file is might understand this better then, as right now it's less obvious that's the mechanism being used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

are you talking about the text? I will wait @kuhlenh to comment on this.

Copy link

Choose a reason for hiding this comment

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

Good call Jason. I think that sounds better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
{
internal partial class GridOptionPreviewControl : AbstractOptionPageControl
{
private static string useEditorConfigUrl = "https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference";
Copy link
Member

Choose a reason for hiding this comment

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

Or an aka.ms link. Correct: no harcoding URLs though.


namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
{
internal partial class GridOptionPreviewControl : AbstractOptionPageControl
{
private static string useEditorConfigUrl = "https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference";
Copy link
Member

Choose a reason for hiding this comment

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

const so that way it can't be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

internal AbstractOptionPreviewViewModel ViewModel;
private readonly IServiceProvider _serviceProvider;
private readonly Func<OptionSet, IServiceProvider, AbstractOptionPreviewViewModel> _createViewModel;

// to leave a space between the end of sentence and "learn more" link
public static string CodeStylePageHeader => ServicesVSResources.Code_style_header_use_editor_config + " ";
public static string CodeStylePageHeaderLearnMoreText => ServicesVSResources.Learn_more;
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think there was some screwy problem if you did it directly. @dpoeschl might remember?

@jasonmalinowski
Copy link
Member

@JieCarolHu How does it look if we make the window smaller so it wraps?

@JieCarolHu
Copy link
Contributor Author

JieCarolHu commented Jan 18, 2018

Screenshots
image
image

@JieCarolHu JieCarolHu removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jan 18, 2018
@sharwell sharwell requested a review from kuhlenh January 18, 2018 19:04
Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

❔ Can you provide the second screenshot showing the layout of the dialog when wrapping is required to fit the first sentence?

using Microsoft.CodeAnalysis.Options;
using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities;
Copy link
Member

Choose a reason for hiding this comment

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

💡 Can you make sure that the added items are all used (remove unused usings)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -29,6 +40,17 @@ internal partial class GridOptionPreviewControl : AbstractOptionPageControl
_createViewModel = createViewModel;
}

private void LearnMoreHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
if (e.Uri == null)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for e.Uri to be null? It seems like this is an unnecessary null check.

<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap">
<Run Text="{x:Static local:GridOptionPreviewControl.CodeStylePageHeader}"/>
<Run Text=" "/>
Copy link
Member

Choose a reason for hiding this comment

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

❕ Can you get a second reviewer to confirm that this is an acceptable alternative to setting the Margin property on the Learn More text box to provide the spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jasonmalinowski could you take a look at this? Thanks

Copy link
Member

Choose a reason for hiding this comment

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

Doing a space this way is what I'd prefer actually since I think it's a better semantic representation of "what we want". Imagine you're a screen reader processing this. The space it'll know is a space and is a word break.

Copy link
Member

Choose a reason for hiding this comment

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

@jasonmalinowski Thanks, I was just asking since it differed from another instance of a similar feature in the project. 👍

Copy link
Member

Choose a reason for hiding this comment

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

@sharwell I wouldn't assume in this case that one had a reason for it.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Looks good to me modulo the nit about const variable naming.

<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap">
<Run Text="{x:Static local:GridOptionPreviewControl.CodeStylePageHeader}"/>
<Run Text=" "/>
Copy link
Member

Choose a reason for hiding this comment

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

Doing a space this way is what I'd prefer actually since I think it's a better semantic representation of "what we want". Imagine you're a screen reader processing this. The space it'll know is a space and is a word break.


namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options
{
internal partial class GridOptionPreviewControl : AbstractOptionPageControl
{
private const string useEditorConfigUrl = "https://go.microsoft.com/fwlink/?linkid=866541";
Copy link
Member

Choose a reason for hiding this comment

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

Nit: const variables should be PascalCased.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@jinujoseph
Copy link
Contributor

@JieCarolHu this needs to retarget 15.6.x branch and Ask mode template to be filled

@sharwell sharwell changed the base branch from master to dev15.6.x January 18, 2018 22:07
@sharwell
Copy link
Member

@jinujoseph for ask mode (now rebased onto dev15.6.x)

@sharwell sharwell added this to the 15.6 milestone Jan 18, 2018
@jinujoseph
Copy link
Contributor

@Pilchie for ask mode approval

@Pilchie
Copy link
Member

Pilchie commented Jan 18, 2018

Approved - thanks!

@JieCarolHu JieCarolHu merged commit 5a9c469 into dotnet:dev15.6.x Jan 18, 2018
@JieCarolHu JieCarolHu deleted the bug23513 branch January 18, 2018 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants