Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Conversation

@Neme12
Copy link
Contributor

@Neme12 Neme12 commented Jun 16, 2018

Fixes #1745

Before:
image

After:
image

image

<DependentUpon>RepositoryRecloneView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\GitHubPane\DirectoryIsExpandedToImageMonikerConverter.cs" />
<Compile Include="Views\GitHubPane\FileNameToImageMonikerConverter.cs" />
Copy link
Contributor Author

@Neme12 Neme12 Jun 16, 2018

Choose a reason for hiding this comment

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

Where would be an appropriate place for these converters? I noticed there is a folder with some converters in GitHub.UI but that project doesn't have a lot of dependencies on VS itself (which these do). Also these aren't really general purpose converters like the other ones seem to be, they're made specifically for one view. But this isn't a good place either (I assume). Where should I put them?

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I think that where you've put them is the best place for them: as you say they're tied to a particular view, so it makes sense to put the converters alongside. Not sure if anyone else things differently though?

We need to change the color of the file icon when the file is deleted, but applying the style
to OcticonImage directly borks the designer (see #1410). Work around this by applying the color
to a parent control and let the foreground be inherited by the icon.
-->
Copy link
Contributor Author

@Neme12 Neme12 Jun 16, 2018

Choose a reason for hiding this comment

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

I noticed this used to gray out the icon if the item was deleted. This can't really be done with arbitrary colored icons. I tried replacing the color change with reduced opacity, but it didn't look very good in my opinion. And the built-in team explorer view doesn't do anything like that either (it's only the text that is grayed out, not the icon). Is it OK to remove this?

Before:
image

After:
image
(icon is the same for deleted and normal files)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's fine with me!

xmlns:theming="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Imaging"
Background="{DynamicResource GitHubVsToolWindowBackground}"
Foreground="{DynamicResource GitHubVsWindowText}"
theming:ImageThemingUtilities.ImageBackgroundColor="{Binding RelativeSource={RelativeSource Self}, Path=Background.Color}"
Copy link
Contributor Author

@Neme12 Neme12 Jun 16, 2018

Choose a reason for hiding this comment

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

This is important to ensure that the icons have the right background in all themes. Transparent doesn't work (it seems to behave almost the same as white). This has to be the real background color, that's why it's all the way up here where the actual background is set.

If this was set to Transparent, it would look like this on a dark theme:
image

Correct behavior:
image

Copy link
Contributor

@grokys grokys Jul 20, 2018

Choose a reason for hiding this comment

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

Just ran into this on the PR review authoring view. I've tried moving this property to PullRequestFilesView and it seems to work fine. What am I missing?

Ignore me, you're right.

@Neme12
Copy link
Contributor Author

Neme12 commented Jun 16, 2018

Note that this also shows any custom icons correctly. For example after installing this extension, which adds many new file icons to solution explorer:
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileIcons

we can see all of them in the PR view:
image
In this case the icon for .editorconfig is actually provided by the extension and not part of Visual Studio (the icon for .gitignore is mapped by the extension too but the image itself comes from VS in KnownMonikers).

@Neme12
Copy link
Contributor Author

Neme12 commented Jun 16, 2018

I'm not sure what's failing in CI. Can someone help please? Everything is building for me locally.

@grokys
Copy link
Contributor

grokys commented Jun 17, 2018

@Neme12 just popping in to say thanks so much for this! This looks excellent; it's something I've been wanting to do for ages but it was just never high enough priority for me.

I think the reason that CI is failing is that CI is building on VS2015 and you're using a C#7 feature here. Up until recently VS2017 was having problems with the extension, it now works however so we're (at least I'm) hoping to move to 2017 soon.

I'll give this a proper review on Monday, but it looks great from a first glance!

@Neme12
Copy link
Contributor Author

Neme12 commented Jun 17, 2018

@grokys Thanks. Please consider adding <LangVersion>6</LangVersion> to the project file. It will prevent contributors from using newer language features and set a standard for everyone, no matter which version of VS they happen to be using. On top of that, it will also prevent the IDE from offering suggestions or refactorings for features that can't be used.

Doing this is always a good idea even if you move to VS 2017 so that there's never confusion about which language version we're using - whether it be C# 6, 7.0, 7.1, 7.2 or 7.3.

edit: I made a PR: #1746

@Neme12
Copy link
Contributor Author

Neme12 commented Jun 17, 2018

There's another error in CI:

error CA1812: Microsoft.Performance : 'DirectoryIsExpandedToImageMonikerConverter' is an internal class that is apparently never instantiated.

This is incorrect. The class is used from XAML :-/

Neme12 added 2 commits June 17, 2018 12:45
From the doc:
Parses a moniker string. The moniker can be of the form "{guid};id" or the name of a well-known moniker (e.g. "KnownMonikers.FolderClosed")
@Neme12
Copy link
Contributor Author

Neme12 commented Jun 17, 2018

I was able to simplify this further and find the proper way to do this when I stumbled upon IVsImageService2 by looking through APIs in intellisense 😄

Copy link
Contributor

@grokys grokys left a comment

Choose a reason for hiding this comment

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

Thanks @Neme12, this is really excellent! Really makes for a much better experience.

Everything here looks 👍 to me: going to wait a little so other team members can take a look, but this looks good to go to me!

{
// In design mode, imageService will be null
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
return default(ImageMoniker);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, we could just check if imageService is null and return KnownMonikers.Document as a fallback, even though it should never be null when running inside VS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What we return doesn't matter because these icons can't be shown in the designer anyway

@Neme12
Copy link
Contributor Author

Neme12 commented Jun 18, 2018

Sorry for so many merge commits. I didn't notice that you added a merge commit in my branch and just used the regular sync feature in VS, so that created another one. Now I saw this message with "This branch is out-of-date with the base branch" which I've never seen before and was curious about what it does 😄 So that's another merge commit... But interestingly, that message is still there and didn't go away. Could that be a bug?

@grokys
Copy link
Contributor

grokys commented Jun 18, 2018

No, it's probably just that another PR was merged in the meantime. Don't worry about the merge commits, they're pretty much a fact of life ;)

@grokys
Copy link
Contributor

grokys commented Jun 18, 2018

@meaghanlewis this looks good to me. If you could take a look and it looks good to you I think we should merge asap

@meaghanlewis
Copy link
Contributor

This looks great to me! Thanks @Neme12 🎉

@meaghanlewis meaghanlewis merged commit 0c5e175 into github:master Jun 18, 2018
@Neme12 Neme12 deleted the icons branch June 18, 2018 17:44
@Neme12
Copy link
Contributor Author

Neme12 commented Jun 18, 2018

Note: When writing code, I was often wondering if there is any preferred code style for this repository that I should use. For example: would you prefer to be explicit about access modifiers (private, internal) or omit them? are braces required? can I use expression bodied methods? are there any naming conventions for const fields? should System directives come first when sorting? string.IsNullOrEmpty vs String.IsNullOrEmpty?

If there are any standard conventions for these, it would be nice to codify them inside .editorconfig so that contributors can be aware of them, obide by them if necessary and the IDE can help them do the right thing. If there are any concerns about setting a hard rule, these could be set to a "suggestion" (not a warning). The same could be done for naming styles. Even if the severity is set to none (it's not a suggestion, warning or an error if you get this wrong) it can still be helpful because the IDE will generate code based on this preferred style when using refactorings.

But given that there were no comments on the style I chose, I'm wondering if it's maybe not considered that important in this codebase and everyone is free to use the style they prefer? (or did I just get everything right? 😄) If that's the case, doing this might not bring that much value after all. I don't know the preferences, so that's why I'm asking and suggesting ideas. 🎉 What do you think? Would that be a good fit for this repo?

@jcansdale
Copy link
Collaborator

jcansdale commented Jun 19, 2018

@Neme12 This would be an excellent fit for this repo! It's just a question of carving out the time. If you're up for driving it in #1750, that would be great. 😄

Could you add a list of questions that would need answering? I'm not very familiar with .editorconfig files (not sure about the rest of the team).

grokys added a commit that referenced this pull request Jul 20, 2018
See #1744 (comment) for information on why this needs to be done here and not in `PullRequestFilesView`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants