Skip to content

Commit 25f4458

Browse files
committed
Improve code quality
1 parent f3ab347 commit 25f4458

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ private static PluginClassInfo GetValidPluginInfo(
273273
ImmutableArray<PluginClassInfo> pluginClasses,
274274
SourceProductionContext context)
275275
{
276-
if (pluginClasses.All(p => p is null || p.PropertyName == null))
276+
var nonNullExistClasses = pluginClasses.Where(p => p != null || p.PropertyName == null).ToArray();
277+
if (nonNullExistClasses.Length == 0)
277278
{
278279
context.ReportDiagnostic(Diagnostic.Create(
279280
SourceGeneratorDiagnostics.CouldNotFindPluginEntryClass,
@@ -282,13 +283,8 @@ private static PluginClassInfo GetValidPluginInfo(
282283
return null;
283284
}
284285

285-
foreach (var pluginClass in pluginClasses)
286+
foreach (var pluginClass in nonNullExistClasses)
286287
{
287-
if (pluginClass == null || pluginClass.PropertyName is null)
288-
{
289-
continue;
290-
}
291-
292288
if (pluginClass.IsValid == true)
293289
{
294290
return pluginClass;
@@ -330,7 +326,7 @@ private static Location GetLocation(SyntaxTree syntaxTree, CSharpSyntaxNode clas
330326
return Location.Create(syntaxTree, classDeclaration.GetLocation().SourceSpan);
331327
}
332328

333-
#endregion
329+
#endregion
334330

335331
#region Generate Source
336332

0 commit comments

Comments
 (0)