Skip to content
Merged
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -1988,30 +1988,26 @@ private bool HasDescendantsWith(XamlObjectDefinition xamlObjectDefinition, Func<
}

var ns = GetTrimmedNamespace(xamlType.PreferredXamlNamespace); // No MarkupExtensions are defined in the framework, so we expect a user-defined namespace
INamedTypeSymbol? findType;
if (ns != xamlType.PreferredXamlNamespace)
{
// If GetTrimmedNamespace returned a different string, it's a "using:"-prefixed namespace.
// In this case, we'll have `baseTypeString` as
// the fully qualified type name.
// In this case, we go through this code path as it's much more efficient than FindType.
var baseTypeString = $"{ns}.{xamlType.Name}";
findType = _metadataHelper.FindTypeByFullName(baseTypeString) as INamedTypeSymbol;
findType ??= _metadataHelper.FindTypeByFullName(baseTypeString + "Extension") as INamedTypeSymbol; // Support shortened syntax
}
else
if (ns == xamlType.PreferredXamlNamespace)
{
// It looks like FindType always returns null in this code path.
// So, we avoid the costly call here.
return null;
}

if (findType?.Is(Generation.MarkupExtensionSymbol.Value) ?? false)
{
return findType;
}
// If GetTrimmedNamespace returned a different string, it's a "using:"-prefixed namespace.
// In this case, we'll have `baseTypeString` as
// the fully qualified type name.
// In this case, we go through this code path as it's much more efficient than FindType.
var baseTypeString = $"{ns}.{xamlType.Name}";

return null;
// Try finding the type with "Extension" suffix first, then without
return FindMarkupExtensionType(baseTypeString + "Extension") ?? FindMarkupExtensionType(baseTypeString);
}

private INamedTypeSymbol? FindMarkupExtensionType(string fullTypeName)
{
return _metadataHelper.FindTypeByFullName(fullTypeName) is INamedTypeSymbol type && type.Is(Generation.MarkupExtensionSymbol.Value) ? type : null;
}

private bool IsCustomMarkupExtensionType(XamlType? xamlType) =>
Expand Down
Loading