Skip to content

Commit 90a072e

Browse files
committed
Merge remote-tracking branch 'origin/155-readonly-lists-it-needs-to-be-ignored'
2 parents d7ce229 + 19cf5e4 commit 90a072e

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

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

Lines changed: 17 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,24 @@ 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(nameof(ICollection)) || _.Type.AllInterfaces.Any(e => e.Name.Contains(nameof(ICollection))) || !(_.Type.Name.Contains("IReadOnlyList") || _.Type.AllInterfaces.Any(e => e.Name.Contains("IReadOnlyList"))))
114+
.Where(_ => !(_.Type.Name.StartsWith("ReadOnlyObservableCollection") || _.Type.Name.StartsWith("ReadOnlyCollection") || _.Type.Name.StartsWith("ReadOnlyDictionary") || (_.Type.BaseType != null && (_.Type.BaseType.Name.StartsWith("ReadOnlyObservableCollection") || _.Type.BaseType.Name.StartsWith("ReadOnlyCollection") || _.Type.BaseType.Name.StartsWith("ReadOnlyDictionary")))))
112115
.ToList();
113116

114-
115117

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

130132
if (attachedModel == null)
131133
{
@@ -243,7 +245,7 @@ void GenerateExtensionMethod(IPropertySymbol propertySymbol, bool isOnlyList = f
243245
GenerateExtensionMethod_AnimateTo(info, "ColorTransform");
244246
}
245247
}
246-
248+
247249
isGeneratedExtension = true;
248250
}
249251
}

0 commit comments

Comments
 (0)