Skip to content

Commit d39a12f

Browse files
authored
Merge pull request #156 from FmgLib/155-readonly-lists-it-needs-to-be-ignored
An error was fixed in the codes generated for ReadOnly lists.
2 parents 81c38f7 + a13576b commit d39a12f

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/FmgLib.MauiMarkup.Generator/Extensions/ExtensionGenerator.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.CodeAnalysis;
2+
23
using System;
34
using System.Collections;
45
using System.Collections.Generic;
@@ -109,23 +110,23 @@ void GenerateClassExtensionBody()
109110
(_.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)))) &&
110111
_.Type.AllInterfaces.Any(e => e.Name.Contains(nameof(IEnumerable))) &&
111112
!_.Type.Name.Equals(nameof(String), StringComparison.InvariantCultureIgnoreCase))
113+
.Where(_ => !(_.Type.Name.Contains("IReadOnlyList") || _.Type.AllInterfaces.Any(e => e.Name.Contains("IReadOnlyList"))))
112114
.ToList();
113115

114-
115116

116-
var events = mainSymbol
117-
.GetMembers()
118-
.Where(_ => _.Kind == SymbolKind.Event)
119-
.Where(_ => _.DeclaredAccessibility == Accessibility.Public)
120-
.Cast<IEventSymbol>()
121-
.Where(_ => !_.Name.Contains('.'))
122-
.Where(_ => (_.ContainingType is INamedTypeSymbol namedTypeSymbol) && namedTypeSymbol.GetFullyQualifiedName() == mainSymbol.GetFullyQualifiedName())
123-
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Equals(editorBrowsableAttribute, SymbolEqualityComparer.Default)))
124-
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Name == "ObsoleteAttribute" || _.AttributeClass.EnsureNotNull().Name == "Obsolete"))
125-
.GroupBy(_ => _.Name, StringComparer.OrdinalIgnoreCase)
126-
.Select(_ => _.First())
127-
.OrderBy(_ => _.Name)
128-
.ToArray();
117+
var events = mainSymbol
118+
.GetMembers()
119+
.Where(_ => _.Kind == SymbolKind.Event)
120+
.Where(_ => _.DeclaredAccessibility == Accessibility.Public)
121+
.Cast<IEventSymbol>()
122+
.Where(_ => !_.Name.Contains('.'))
123+
.Where(_ => (_.ContainingType is INamedTypeSymbol namedTypeSymbol) && namedTypeSymbol.GetFullyQualifiedName() == mainSymbol.GetFullyQualifiedName())
124+
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Equals(editorBrowsableAttribute, SymbolEqualityComparer.Default)))
125+
.Where(_ => !_.GetAttributes().Any(_ => _.AttributeClass.EnsureNotNull().Name == "ObsoleteAttribute" || _.AttributeClass.EnsureNotNull().Name == "Obsolete"))
126+
.GroupBy(_ => _.Name, StringComparer.OrdinalIgnoreCase)
127+
.Select(_ => _.First())
128+
.OrderBy(_ => _.Name)
129+
.ToArray();
129130

130131
if (attachedModel == null)
131132
{
@@ -243,7 +244,7 @@ void GenerateExtensionMethod(IPropertySymbol propertySymbol, bool isOnlyList = f
243244
GenerateExtensionMethod_AnimateTo(info, "ColorTransform");
244245
}
245246
}
246-
247+
247248
isGeneratedExtension = true;
248249
}
249250
}

0 commit comments

Comments
 (0)