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
Conversation
|
||
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"; |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@JieCarolHu , Thanks for the fast fix here. Can you also paste what the UI looks like |
There was a problem hiding this 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" |
There was a problem hiding this comment.
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:
- Disable the IDE feature which is causing this whitespace to be removed when the file is edited and/or saved
- When committing changes to Git, commit the changes on a line-by-line basis while manually avoiding the lines which only have whitespace changes
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
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" />
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ Is this possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you pls elaborate?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 + " "; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}" > |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}"> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
@JieCarolHu here is the fwlink: https://go.microsoft.com/fwlink/?linkid=866541 |
There was a problem hiding this 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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
@JieCarolHu How does it look if we make the window smaller so it wraps? |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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=" "/> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
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.
There was a problem hiding this 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=" "/> |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@JieCarolHu this needs to retarget 15.6.x branch and Ask mode template to be filled |
@jinujoseph for ask mode (now rebased onto dev15.6.x) |
@Pilchie for ask mode approval |
Approved - thanks! |
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