Merge pull request #11323 from abpframework/fix-new-module-creating-cli

Cli: Class parsing should support File-Scoped Namespaces
pull/11324/head
Yunus Emre Kalkan 3 years ago committed by GitHub
commit 9078b58977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,7 +19,7 @@
<PackageReference Include="NuGet.Versioning" Version="5.11.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="$(MicrosoftPackageVersion)" />
<PackageReference Include="System.Security.Permissions" Version="$(MicrosoftPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" />
<PackageReference Include="Polly" Version="7.2.2" />
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageReference Include="LibGit2Sharp" Version="0.26.2" />

@ -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<NamespaceDeclarationSyntax>().First();
var classDeclaration = (namespaceSyntax.DescendantNodes().OfType<ClassDeclarationSyntax>()).First();
var namespaceSyntax = root.DescendantNodes().OfType<NamespaceDeclarationSyntax>().FirstOrDefault();
var classDeclaration = (namespaceSyntax?.DescendantNodes().OfType<ClassDeclarationSyntax>())?.FirstOrDefault();
if (classDeclaration == null)
{
classDeclaration = root.DescendantNodes().OfType<ClassDeclarationSyntax>().First();
}
var baseTypeList = classDeclaration.BaseList?.Types.Select(t => t.ToString()).ToList();
if (baseTypeList == null)

@ -704,13 +704,13 @@ public class SolutionModuleAdder : ITransientDependency
new NugetPackageInfo
{
Name = $"{module.Name}.Blazor.WebAssembly",
ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorWebAssemblyModule",
ModuleClass = $"{module.Name}.Blazor.WebAssembly.{moduleProjectName}BlazorWebAssemblyModule",
Target = NuGetPackageTarget.BlazorWebAssembly
},
new NugetPackageInfo
{
Name = $"{module.Name}.Blazor.Server",
ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorServerModule",
ModuleClass = $"{module.Name}.Blazor.Server.{moduleProjectName}BlazorServerModule",
Target = NuGetPackageTarget.BlazorServer
},
new NugetPackageInfo

Loading…
Cancel
Save