Skip to content

Commit

Permalink
Fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitz committed Nov 7, 2019
1 parent 9e36553 commit 784fa7a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion 2017.Standard/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
<Costura CreateTemporaryAssemblies="true" />
</Weavers>
2 changes: 1 addition & 1 deletion 2017/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
<Costura CreateTemporaryAssemblies="true" />
</Weavers>
2 changes: 1 addition & 1 deletion 2019.Standard/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
<Costura CreateTemporaryAssemblies="true" />
</Weavers>
2 changes: 1 addition & 1 deletion 2019/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
<Costura CreateTemporaryAssemblies="true" />
</Weavers>
17 changes: 12 additions & 5 deletions Shared/Models/VisualizerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class VisualizerData {
public bool CanSelectLexer { get; }
public bool CanSelectParser { get; }

private static readonly string[] loadErrorExceptions = new[] {
"Microsoft.Xaml.Behaviors.Wpf"
};

public VisualizerData(object o, Config config) {
if (config is null) { throw new ArgumentNullException(nameof(config)); }

Expand All @@ -36,14 +40,17 @@ T createInstance<T>(string typename, object[] args = null) =>
types = AppDomain.CurrentDomain.GetAssemblies()
.Where(x => x != GetType().Assembly)
.SelectMany(x => {
try {
return x.GetTypes();
var ret = Empty<Type>();
if (!x.FullName.StartsWithAny(loadErrorExceptions)) {
try {
ret = x.GetTypes();
#pragma warning disable CA1031 // Do not catch general exception types
} catch {
} catch {
#pragma warning restore CA1031 // Do not catch general exception types
AssemblyLoadErrors.Add(x.FullName);
return Empty<Type>();
AssemblyLoadErrors.Add(x.FullName);
}
}
return ret;
})
.Where(x => !x.IsAbstract)
.ToArray();
Expand Down
1 change: 1 addition & 0 deletions Shared/Util/Extensions/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ public static string ToCSharpLiteral(this string input, bool withQuotationMarks
}

public static bool ContainsAny(this string s, params string[] testStrings) => testStrings.Any(x => s.Contains(x));
public static bool StartsWithAny(this string s, params string[] testStrings) => testStrings.Any(x => s.StartsWith(x, StringComparison.InvariantCulture));
}
}
2 changes: 1 addition & 1 deletion Shared/ViewModels/VisualizerDataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public RelayCommand ChangeSelection {
if (changeSelection == null) {
changeSelection = new RelayCommand(sender => {
updateSelection(sender);
var firstSelected = Tokens.FirstOrDefault(x => x.IsSelected);
var firstSelected = Tokens?.FirstOrDefault(x => x.IsSelected);
if (TokensGrid is null || firstSelected is null) { return; }
TokensGrid.ScrollIntoView(firstSelected);
});
Expand Down

0 comments on commit 784fa7a

Please sign in to comment.