This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +52
-28
lines changed
GitHub.VisualStudio/Views/GitHubPane Expand file tree Collapse file tree 5 files changed +52
-28
lines changed Original file line number Diff line number Diff line change @@ -20,14 +20,12 @@ public class ViewViewModelFactory : IViewViewModelFactory
2020
2121 [ ImportingConstructor ]
2222 public ViewViewModelFactory (
23- IGitHubServiceProvider serviceProvider ,
24- ICompositionService cc )
23+ IGitHubServiceProvider serviceProvider )
2524 {
2625 this . serviceProvider = serviceProvider ;
27- cc . SatisfyImportsOnce ( this ) ;
2826 }
2927
30- [ ImportMany ( AllowRecomposition = true ) ]
28+ [ ImportMany ]
3129 IEnumerable < ExportFactory < FrameworkElement , IViewModelMetadata > > Views { get ; set ; }
3230
3331 /// <inheritdoc/>
@@ -45,7 +43,7 @@ public FrameworkElement CreateView<TViewModel>() where TViewModel : IViewModel
4543 /// <inheritdoc/>
4644 public FrameworkElement CreateView ( Type viewModel )
4745 {
48- var f = Views . FirstOrDefault ( x => x . Metadata . ViewModelType . Contains ( viewModel ) ) ;
46+ var f = Views . FirstOrDefault ( x => x . Metadata . ViewModelType . Contains ( viewModel . FullName ) ) ;
4947 return f ? . CreateExport ( ) . Value ;
5048 }
5149 }
Original file line number Diff line number Diff line change @@ -402,8 +402,8 @@ static async Task<bool> IsValidRepository(ISimpleApiClient client)
402402
403403 static Regex CreateRoute ( string route )
404404 {
405- // Build RegEx from route (:foo to named group (?<foo>[a-z0-9 ]+)).
406- var routeFormat = new Regex ( "(:([a-z]+))\\ b" ) . Replace ( route , "(?<$2>[a-z0-9 ]+)" ) ;
405+ // Build RegEx from route (:foo to named group (?<foo>[\w_.- ]+)).
406+ var routeFormat = new Regex ( "(:([a-z]+))\\ b" ) . Replace ( route , @ "(?<$2>[\w_.- ]+)") ;
407407 return new Regex ( routeFormat , RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
408408 }
409409 }
Original file line number Diff line number Diff line change @@ -32,15 +32,17 @@ public enum LinkType
3232 /// </summary>
3333 [ MetadataAttribute ]
3434 [ AttributeUsage ( AttributeTargets . Class , AllowMultiple = true ) ]
35+ [ SuppressMessage ( "Microsoft.Design" , "CA1019:DefineAccessorsForAttributeArguments" ,
36+ Justification = "Store string rather than Type as metadata" ) ]
3537 public sealed class ExportViewForAttribute : ExportAttribute
3638 {
3739 public ExportViewForAttribute ( Type viewModelType )
3840 : base ( typeof ( FrameworkElement ) )
3941 {
40- ViewModelType = viewModelType ;
42+ ViewModelType = viewModelType . FullName ;
4143 }
4244
43- public Type ViewModelType { get ; }
45+ public string ViewModelType { get ; }
4446 }
4547
4648 /// <summary>
@@ -69,7 +71,7 @@ public ExportMenuAttribute() : base(typeof(IMenuHandler))
6971 public interface IViewModelMetadata
7072 {
7173 [ SuppressMessage ( "Microsoft.Performance" , "CA1819:PropertiesShouldNotReturnArrays" ) ]
72- Type [ ] ViewModelType { get ; }
74+ string [ ] ViewModelType { get ; }
7375 }
7476
7577 /// <summary>
Original file line number Diff line number Diff line change @@ -21,28 +21,42 @@ static RegistryKey OpenGitKey(string path)
2121
2222 internal static IEnumerable < ILocalRepositoryModel > PokeTheRegistryForRepositoryList ( )
2323 {
24- using ( var key = OpenGitKey ( "Repositories" ) )
24+ var key = OpenGitKey ( "Repositories" ) ;
25+
26+ if ( key != null )
2527 {
26- return key . GetSubKeyNames ( ) . Select ( x =>
28+ using ( key )
2729 {
28- using ( var subkey = key . OpenSubKey ( x ) )
30+ return key . GetSubKeyNames ( ) . Select ( x =>
2931 {
30- try
31- {
32- var path = subkey ? . GetValue ( "Path" ) as string ;
33- if ( path != null && Directory . Exists ( path ) )
34- return new LocalRepositoryModel ( path ) ;
35- }
36- catch ( Exception )
32+ var subkey = key . OpenSubKey ( x ) ;
33+
34+ if ( subkey != null )
3735 {
38- // no sense spamming the log, the registry might have ton of stale things we don't care about
36+ using ( subkey )
37+ {
38+ try
39+ {
40+ var path = subkey ? . GetValue ( "Path" ) as string ;
41+ if ( path != null && Directory . Exists ( path ) )
42+ return new LocalRepositoryModel ( path ) ;
43+ }
44+ catch ( Exception )
45+ {
46+ // no sense spamming the log, the registry might have ton of stale things we don't care about
47+ }
48+
49+ }
3950 }
51+
4052 return null ;
41- }
42- } )
43- . Where ( x => x != null )
44- . ToList ( ) ;
53+ } )
54+ . Where ( x => x != null )
55+ . ToList ( ) ;
56+ }
4557 }
58+
59+ return new ILocalRepositoryModel [ 0 ] ;
4660 }
4761
4862 internal static string PokeTheRegistryForLocalClonePath ( )
Original file line number Diff line number Diff line change 317317 <ui : OcticonImage .Style>
318318 <Style TargetType =" ui:OcticonImage" BasedOn =" {StaticResource OcticonImage}" >
319319 <Style .Triggers>
320- <DataTrigger Binding =" {Binding Status}" Value =" Removed" >
320+ <MultiDataTrigger >
321+ <MultiDataTrigger .Conditions>
322+ <Condition Binding =" {Binding Status}" Value =" Removed" />
323+ <Condition Binding =" {Binding RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}, Path=IsSelected}" Value =" False" />
324+ </MultiDataTrigger .Conditions>
321325 <Setter Property =" Foreground" Value =" {DynamicResource GitHubDeletedFileIconBrush}" />
322- </DataTrigger >
326+ </MultiDataTrigger >
323327 </Style .Triggers>
324328 </Style >
325329 </ui : OcticonImage .Style>
329333 <Style TargetType =" TextBlock" >
330334 <Style .Triggers>
331335 <DataTrigger Binding =" {Binding Status}" Value =" Removed" >
332- <Setter Property =" Foreground" Value =" {DynamicResource GitHubDeletedFileBrush}" />
333336 <Setter Property =" TextDecorations" Value =" Strikethrough" />
334337 </DataTrigger >
338+ <MultiDataTrigger >
339+ <MultiDataTrigger .Conditions>
340+ <Condition Binding =" {Binding Status}" Value =" Removed" />
341+ <Condition Binding =" {Binding RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}, Path=IsSelected}" Value =" False" />
342+ </MultiDataTrigger .Conditions>
343+ <Setter Property =" Foreground" Value =" {DynamicResource GitHubDeletedFileBrush}" />
344+ </MultiDataTrigger >
335345 </Style .Triggers>
336346 </Style >
337347 </TextBlock .Style>
You can’t perform that action at this time.
0 commit comments