Skip to content

Commit

Permalink
An error was fixed in the codes generated for ReadOnly lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonultasmf committed Nov 24, 2024
1 parent 524fa32 commit a13576b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/FmgLib.MauiMarkup.Generator/Extensions/ExtensionGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.CodeAnalysis;

using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -109,23 +110,23 @@ void GenerateClassExtensionBody()
(_.Type.Name.Contains(nameof(IList)) || _.Type.AllInterfaces.Any(e => e.Name.Contains(nameof(IList))) || _.Type.Name.Contains(nameof(ICollection)) || _.Type.AllInterfaces.Any(e => e.Name.Contains(nameof(ICollection)))) &&
_.Type.AllInterfaces.Any(e => e.Name.Contains(nameof(IEnumerable))) &&
!_.Type.Name.Equals(nameof(String), StringComparison.InvariantCultureIgnoreCase))
.Where(_ => !(_.Type.Name.Contains("IReadOnlyList") || _.Type.AllInterfaces.Any(e => e.Name.Contains("IReadOnlyList"))))
.ToList();



var events = mainSymbol
.GetMembers()
.Where(_ => _.Kind == SymbolKind.Event)
.Where(_ => _.DeclaredAccessibility == Accessibility.Public)
.Cast<IEventSymbol>()
.Where(_ => !_.Name.Contains('.'))
.Where(_ => (_.ContainingType is INamedTypeSymbol namedTypeSymbol) && namedTypeSymbol.GetFullyQualifiedName() == mainSymbol.GetFullyQualifiedName())
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Equals(editorBrowsableAttribute, SymbolEqualityComparer.Default)))
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Name == "ObsoleteAttribute" || _.AttributeClass.EnsureNotNull().Name == "Obsolete"))
.GroupBy(_ => _.Name, StringComparer.OrdinalIgnoreCase)
.Select(_ => _.First())
.OrderBy(_ => _.Name)
.ToArray();
var events = mainSymbol
.GetMembers()
.Where(_ => _.Kind == SymbolKind.Event)
.Where(_ => _.DeclaredAccessibility == Accessibility.Public)
.Cast<IEventSymbol>()
.Where(_ => !_.Name.Contains('.'))
.Where(_ => (_.ContainingType is INamedTypeSymbol namedTypeSymbol) && namedTypeSymbol.GetFullyQualifiedName() == mainSymbol.GetFullyQualifiedName())
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Equals(editorBrowsableAttribute, SymbolEqualityComparer.Default)))
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Name == "ObsoleteAttribute" || _.AttributeClass.EnsureNotNull().Name == "Obsolete"))
.GroupBy(_ => _.Name, StringComparer.OrdinalIgnoreCase)
.Select(_ => _.First())
.OrderBy(_ => _.Name)
.ToArray();

if (attachedModel == null)
{
Expand Down Expand Up @@ -217,7 +218,8 @@ void GenerateExtensionMethod(IPropertySymbol propertySymbol, bool isOnlyList = f
namedListType.BaseType.TypeArguments.Length == 1)
typeName = namedListType.BaseType.TypeArguments[0].ToDisplayString();

GenerateExtensionMethod_ContentProp_List(info, typeName);
if (!string.IsNullOrEmpty(typeName))
GenerateExtensionMethod_ContentProp_List(info, typeName);
}
else
{
Expand All @@ -242,7 +244,7 @@ void GenerateExtensionMethod(IPropertySymbol propertySymbol, bool isOnlyList = f
GenerateExtensionMethod_AnimateTo(info, "ColorTransform");
}
}

isGeneratedExtension = true;
}
}
Expand Down

0 comments on commit a13576b

Please sign in to comment.