Skip to content
Permalink
Browse files

Fix #1436: Do not crash on unknown assembly reference.

  • Loading branch information...
siegfriedpammer committed Mar 1, 2019
1 parent ab16a77 commit 1170249b1fcd63de6cfd3094b63971d733cfa9e2
@@ -1,4 +1,4 @@
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cc="clr-namespace:ILSpy.BamlDecompiler.Tests.Cases">
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cc="clr-namespace:ILSpy.BamlDecompiler.Tests.Cases" xmlns:unk="clr-namespace:A;assembly=Unknown">
<cc:CustomControl Grid.Row="0" Tag="{}{}{Test}" CustomName="Custom1">
<FrameworkElement.Style>
<Style />
@@ -36,11 +36,11 @@ public NamespaceMap(string prefix, IModule asm, string xmlNs)

public NamespaceMap(string prefix, IModule asm, string xmlNs, string clrNs) {
XmlnsPrefix = prefix;
Assembly = asm ?? throw new ArgumentNullException(nameof(asm));
Assembly = asm;
XMLNamespace = xmlNs;
CLRNamespace = clrNs;
}

public override string ToString() => $"{XmlnsPrefix}:[{Assembly.Name}|{CLRNamespace ?? XMLNamespace}]";
public override string ToString() => $"{XmlnsPrefix}:[{Assembly?.Name}|{CLRNamespace ?? XMLNamespace}]";
}
}
@@ -37,7 +37,7 @@ internal class XmlnsScope : List<NamespaceMap> {

public string LookupXmlns(IModule asm, string clrNs) {
foreach (var ns in this) {
if (asm.FullAssemblyName == ns.Assembly.FullAssemblyName && ns.CLRNamespace == clrNs)
if (asm.FullAssemblyName == ns.Assembly?.FullAssemblyName && ns.CLRNamespace == clrNs)
return ns.XMLNamespace;
}

@@ -103,14 +103,14 @@ internal class XmlnsDictionary {

public string LookupXmlns(IModule asm, string clrNs) {
foreach (var map in piMappings) {
if (asm.FullAssemblyName == map.Value.Assembly.FullAssemblyName && map.Value.CLRNamespace == clrNs)
if (asm.FullAssemblyName == map.Value.Assembly?.FullAssemblyName && map.Value.CLRNamespace == clrNs)
return map.Key;
}

var scope = CurrentScope;
while (scope != null) {
foreach (var ns in scope) {
if (asm.FullAssemblyName == ns.Assembly.FullAssemblyName && ns.CLRNamespace == clrNs)
if (asm.FullAssemblyName == ns.Assembly?.FullAssemblyName && ns.CLRNamespace == clrNs)
return ns.XMLNamespace;
}

0 comments on commit 1170249

Please sign in to comment.
You can’t perform that action at this time.