Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Controls/src/Xaml/XamlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembl
if (s_xmlnsDefinitions == null)
GatherXmlnsDefinitionAndXmlnsPrefixAttributes(currentAssembly);

IEnumerable<Type> types = xmlType.GetTypeReferences(
var types = xmlType.GetTypeReferences(
s_xmlnsDefinitions,
currentAssembly?.FullName,
(typeInfo) =>
Expand All @@ -426,12 +426,13 @@ public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembl
return t;
return null;
},
expandToExtension);
expandToExtension).Distinct().ToList();

var typeArguments = xmlType.TypeArguments;
exception = null;

if (!types.Any())

if (types.Count == 0)
{
// This covers the scenario where the AppDomain's loaded
// assemblies might have changed since this method was first
Expand All @@ -445,13 +446,13 @@ public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembl
}
}

if (types.Distinct().Skip(1).Any())
if (types.Count > 1)
{
exception = new XamlParseException($"Ambiguous type '{xmlType.Name}' in xmlns '{xmlType.NamespaceUri}'", xmlInfo);
return null;
}

var type = types.Distinct().FirstOrDefault();
var type = types.Count == 1 ? types[0] : null;

if (type != null && typeArguments != null)
{
Expand Down
Loading