Skip to content

Commit

Permalink
fix: Fully quality BindableMetadata generated types
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Sep 29, 2020
1 parent b34b0cd commit aad95fe
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Microsoft.Build.Execution;
using Uno.UI.SourceGenerators.XamlGenerator;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.CSharp;
using System.Reflection.Metadata.Ecma335;

namespace Uno.UI.SourceGenerators.BindableTypeProviders
{
Expand Down Expand Up @@ -392,7 +394,7 @@ where field.IsStatic

foreach (var property in properties)
{
var propertyTypeName = property.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
var propertyTypeName = GetFullyQualifiedType(property.Type);
var propertyName = property.Name;

if (IsStringIndexer(property))
Expand Down Expand Up @@ -493,6 +495,24 @@ where field.IsStatic
writer.AppendLine();
}

private object GetFullyQualifiedType(ITypeSymbol type)
{
if(type is INamedTypeSymbol namedTypeSymbol)
{
if (namedTypeSymbol.IsGenericType && !namedTypeSymbol.IsNullable())
{
return SymbolDisplay.ToDisplayString(type, format: new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Included,
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
genericsOptions: SymbolDisplayGenericsOptions.None,
miscellaneousOptions: SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers))
+ "<" + string.Join(", ", namedTypeSymbol.TypeArguments.Select(GetFullyQualifiedType)) + ">";
}
}

return type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
}

private static string ExpandType(INamedTypeSymbol ownerType)
{
if(ownerType.TypeKind == TypeKind.Error)
Expand Down

0 comments on commit aad95fe

Please sign in to comment.