From 6ec11e1eb5861bdcf1487b81205c30d03c73ec96 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 14 Jan 2022 10:44:37 +0300 Subject: [PATCH] Cli: Class parsing should support File-Scoped Namespaces --- .../Abp/Cli/ProjectModification/DerivedClassFinder.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs index 52a2fb93b1..5462f3e9fb 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs @@ -54,8 +54,14 @@ public class DerivedClassFinder : ITransientDependency protected bool IsDerived(string csFile, string baseClass) { var root = CSharpSyntaxTree.ParseText(File.ReadAllText(csFile)).GetRoot(); - var namespaceSyntax = root.DescendantNodes().OfType().First(); - var classDeclaration = (namespaceSyntax.DescendantNodes().OfType()).First(); + var namespaceSyntax = root.DescendantNodes().OfType().FirstOrDefault(); + var classDeclaration = (namespaceSyntax?.DescendantNodes().OfType())?.FirstOrDefault(); + + if (classDeclaration == null) + { + classDeclaration = root.DescendantNodes().OfType().First(); + } + var baseTypeList = classDeclaration.BaseList?.Types.Select(t => t.ToString()).ToList(); if (baseTypeList == null)