Browse Source

use file-scoped namespacing for studioOpen module

pull/10696/head
Ahmet Çotur 5 years ago
parent
commit
044ede1e15
  1. 11
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/AbpStudioAnalyzingAbstractionsModule.cs
  2. 29
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Application/ApplicationServiceModel.cs
  3. 37
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Authorization/PermissionModel.cs
  4. 23
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/DatabaseCollectionModel.cs
  5. 23
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/DatabaseTableModel.cs
  6. 29
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/EfCoreDbContextModel.cs
  7. 11
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/IDbContextModel.cs
  8. 29
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/MongoDbContextModel.cs
  9. 17
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/AggregateRootModel.cs
  10. 25
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/DomainServiceModel.cs
  11. 39
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/EntityModel.cs
  12. 29
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/RepositoryInterfaceModel.cs
  13. 69
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Feature/FeatureModel.cs
  14. 21
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Module/AbpModuleModel.cs
  15. 21
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageContentItemModel.cs
  16. 31
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageContentItemNameAttribute.cs
  17. 11
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageContentList.cs
  18. 27
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageModel.cs
  19. 31
      studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Setting/SettingModel.cs
  20. 17
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/AbpStudioDomainCommonServicesModule.cs
  21. 37
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/AbpStudioException.cs
  22. 43
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Helpers/PathHelper.cs
  23. 103
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/AbpModuleFileManager.cs
  24. 265
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/CsprojFileManager.cs
  25. 11
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/IAbpModuleFileManager.cs
  26. 17
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/ICsprojFileManager.cs
  27. 25
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/INugetSourceCodeStore.cs
  28. 39
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/NugetPackageCacheManager.cs
  29. 223
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/NugetSourceCodeStore.cs
  30. 19
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/TemplateNugetPackageInfoProvider.cs
  31. 37
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageDependency.cs
  32. 287
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageTypes.cs
  33. 13
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/ReferenceType.cs
  34. 171
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/DotnetSlnFileModifierService.cs
  35. 9
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/IDotnetSlnFileModifierService.cs
  36. 9
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/ISolutionFileModuleAdder.cs
  37. 51
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/SolutionFileModuleAdder.cs
  38. 63
      studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Xml/XmlFileManagerBase.cs
  39. 13
      studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/AbpStudioDomainSharedModule.cs
  40. 59
      studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/AbpStudioErrorCodes.cs
  41. 27
      studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/Modules/ModuleConsts.cs
  42. 21
      studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/Package/PackageReferenceCompatibility.cs
  43. 13
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/AbpStudioModuleInstallerAbstractionsModule.cs
  44. 75
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Analyzing/AnalyzingOptions.cs
  45. 21
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/EfCoreConfigurationMethodDeclaration.cs
  46. 9
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/IModuleInstallingPipelineBuilder.cs
  47. 113
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingContext.cs
  48. 69
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipeline.cs
  49. 9
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineStep.cs
  50. 9
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/Options/IModuleInstallingOptionProvider.cs
  51. 37
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/Options/ModuleInstallingOption.cs
  52. 17
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/Options/ModuleInstallingOptionType.cs
  53. 11
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageConsts.cs
  54. 17
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageHelper.cs
  55. 41
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageInfo.cs
  56. 35
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageInfoWithAnalyze.cs
  57. 17
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/AbpStudioModuleInstallerModule.cs
  58. 35
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs
  59. 41
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs
  60. 13
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddToSolutionFileStep.cs
  61. 131
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/PackageReferencingStep.cs
  62. 41
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/SourceCodeDownloadStep.cs

11
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/AbpStudioAnalyzingAbstractionsModule.cs

@ -1,9 +1,8 @@
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.Studio.Analyzing namespace Volo.Abp.Studio.Analyzing;
public class AbpStudioAnalyzingAbstractionsModule : AbpModule
{ {
public class AbpStudioAnalyzingAbstractionsModule : AbpModule
{ }
}
}

29
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Application/ApplicationServiceModel.cs

@ -1,21 +1,20 @@
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Application namespace Volo.Abp.Studio.Analyzing.Models.Application;
[PackageContentItemName(ContentTypeName)]
public class ApplicationServiceModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "applicationService";
public class ApplicationServiceModel : PackageContentItemModel
public string Namespace { get; set; }
public string Summary { get; set; }
public List<string> ImplementingInterfaces { get; set; }
public ApplicationServiceModel([NotNull] string name) : base(name)
{ {
public const string ContentTypeName = "applicationService";
public string Namespace { get; set; }
public string Summary { get; set; }
public List<string> ImplementingInterfaces { get; set; }
public ApplicationServiceModel([NotNull] string name) : base(name)
{
}
} }
} }

37
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Authorization/PermissionModel.cs

@ -1,24 +1,23 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Authorization namespace Volo.Abp.Studio.Analyzing.Models.Authorization;
[PackageContentItemName(ContentTypeName)]
public class PermissionModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "permission";
public class PermissionModel : PackageContentItemModel
{ public string DisplayName { get; }
public const string ContentTypeName = "permission";
public string DisplayName { get; } public bool IsEnabled { get; }
public bool IsEnabled { get; } public PermissionModel(
[NotNull] string name,
public PermissionModel( string displayName,
[NotNull] string name, bool isEnabled)
string displayName, : base(name)
bool isEnabled) {
: base(name) DisplayName = displayName;
{ IsEnabled = isEnabled;
DisplayName = displayName;
IsEnabled = isEnabled;
}
} }
} }

23
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/DatabaseCollectionModel.cs

@ -1,17 +1,16 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Database namespace Volo.Abp.Studio.Analyzing.Models.Database;
[PackageContentItemName(ContentTypeName)]
public class DatabaseCollectionModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "databaseCollection";
public class DatabaseCollectionModel : PackageContentItemModel
{
public const string ContentTypeName = "databaseCollection";
public string EntityFullName { get; private set; }
public DatabaseCollectionModel([NotNull] string name, string entityFullName) : base(name) public string EntityFullName { get; private set; }
{
EntityFullName = Check.NotNullOrWhiteSpace(entityFullName, nameof(entityFullName)); public DatabaseCollectionModel([NotNull] string name, string entityFullName) : base(name)
} {
EntityFullName = Check.NotNullOrWhiteSpace(entityFullName, nameof(entityFullName));
} }
} }

23
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/DatabaseTableModel.cs

@ -1,17 +1,16 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Database namespace Volo.Abp.Studio.Analyzing.Models.Database;
[PackageContentItemName(ContentTypeName)]
public class DatabaseTableModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "databaseTable";
public class DatabaseTableModel : PackageContentItemModel
{
public const string ContentTypeName = "databaseTable";
public string EntityFullName { get; private set; }
public DatabaseTableModel([NotNull] string name, string entityFullName) : base(name) public string EntityFullName { get; private set; }
{
EntityFullName = Check.NotNullOrWhiteSpace(entityFullName, nameof(entityFullName)); public DatabaseTableModel([NotNull] string name, string entityFullName) : base(name)
} {
EntityFullName = Check.NotNullOrWhiteSpace(entityFullName, nameof(entityFullName));
} }
} }

29
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/EfCoreDbContextModel.cs

@ -1,25 +1,24 @@
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Database namespace Volo.Abp.Studio.Analyzing.Models.Database;
[PackageContentItemName(ContentTypeName)]
public class EfCoreDbContextModel : PackageContentItemModel, IDbContextModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "efCoreDbContext";
public class EfCoreDbContextModel : PackageContentItemModel, IDbContextModel
{
public const string ContentTypeName = "efCoreDbContext";
public string Namespace { get; private set; } public string Namespace { get; private set; }
public string ConnectionStringName { get; set; } public string ConnectionStringName { get; set; }
public List<DatabaseTableModel> DatabaseTables { get; set; } public List<DatabaseTableModel> DatabaseTables { get; set; }
public EfCoreDbContextModel( public EfCoreDbContextModel(
[NotNull] string name, [NotNull] string name,
[NotNull] string @namespace [NotNull] string @namespace
) : base(name) ) : base(name)
{ {
Namespace = Check.NotNullOrWhiteSpace(@namespace, nameof(@namespace)); Namespace = Check.NotNullOrWhiteSpace(@namespace, nameof(@namespace));
}
} }
} }

11
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/IDbContextModel.cs

@ -1,7 +1,6 @@
namespace Volo.Abp.Studio.Analyzing.Models.Database namespace Volo.Abp.Studio.Analyzing.Models.Database;
public interface IDbContextModel
{ {
public interface IDbContextModel string ConnectionStringName { get; set; }
{ }
string ConnectionStringName { get; set; }
}
}

29
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Database/MongoDbContextModel.cs

@ -1,25 +1,24 @@
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Database namespace Volo.Abp.Studio.Analyzing.Models.Database;
[PackageContentItemName(ContentTypeName)]
public class MongoDbContextModel : PackageContentItemModel, IDbContextModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "mongoDbContext";
public class MongoDbContextModel : PackageContentItemModel, IDbContextModel
{
public const string ContentTypeName = "mongoDbContext";
public string Namespace { get; private set; } public string Namespace { get; private set; }
public string ConnectionStringName { get; set; } public string ConnectionStringName { get; set; }
public List<DatabaseCollectionModel> DatabaseCollections { get; set; } public List<DatabaseCollectionModel> DatabaseCollections { get; set; }
public MongoDbContextModel( public MongoDbContextModel(
[NotNull] string name, [NotNull] string name,
[NotNull] string @namespace [NotNull] string @namespace
) : base(name) ) : base(name)
{ {
Namespace = Check.NotNullOrWhiteSpace(@namespace, nameof(@namespace)); Namespace = Check.NotNullOrWhiteSpace(@namespace, nameof(@namespace));
}
} }
} }

17
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/AggregateRootModel.cs

@ -1,12 +1,11 @@
namespace Volo.Abp.Studio.Analyzing.Models.Domain namespace Volo.Abp.Studio.Analyzing.Models.Domain;
[PackageContentItemName(ContentTypeName)]
public class AggregateRootModel : EntityModel
{ {
[PackageContentItemName(ContentTypeName)] public new const string ContentTypeName = "aggregateRoot";
public class AggregateRootModel : EntityModel
{
public new const string ContentTypeName = "aggregateRoot";
public AggregateRootModel(string name) : base(name) public AggregateRootModel(string name) : base(name)
{ {
}
} }
} }

25
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/DomainServiceModel.cs

@ -1,18 +1,17 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Domain namespace Volo.Abp.Studio.Analyzing.Models.Domain;
[PackageContentItemName(ContentTypeName)]
public class DomainServiceModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "domainService";
public class DomainServiceModel : PackageContentItemModel
{ public string Namespace { get; set; }
public const string ContentTypeName = "domainService";
public string Namespace { get; set; }
public string Summary { get; set; }
public DomainServiceModel([NotNull] string name) : base(name) public string Summary { get; set; }
{
} public DomainServiceModel([NotNull] string name) : base(name)
{
} }
} }

39
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/EntityModel.cs

@ -1,25 +1,24 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Volo.Abp.Studio.Analyzing.Models.Domain namespace Volo.Abp.Studio.Analyzing.Models.Domain;
[PackageContentItemName(ContentTypeName)]
public class EntityModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "entity";
public class EntityModel : PackageContentItemModel
{ public string Namespace { get; set; }
public const string ContentTypeName = "entity";
public string PrimaryKeyType { get; set; }
public string Namespace { get; set; }
public string PrimaryKeyType { get; set; }
public string Summary { get; set; }
public List<string> CollectionProperties { get; set; }
public List<string> NavigationProperties { get; set; }
public EntityModel(string name) : base(name) public string Summary { get; set; }
{
CollectionProperties = new List<string>(); public List<string> CollectionProperties { get; set; }
NavigationProperties = new List<string>(); public List<string> NavigationProperties { get; set; }
}
public EntityModel(string name) : base(name)
{
CollectionProperties = new List<string>();
NavigationProperties = new List<string>();
} }
} }

29
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Domain/RepositoryInterfaceModel.cs

@ -1,20 +1,19 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Domain namespace Volo.Abp.Studio.Analyzing.Models.Domain;
[PackageContentItemName(ContentTypeName)]
public class RepositoryInterfaceModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "repositoryInterface";
public class RepositoryInterfaceModel : PackageContentItemModel
{ public string Namespace { get; set; }
public const string ContentTypeName = "repositoryInterface";
public string Namespace { get; set; } public string Summary { get; set; }
public string Summary { get; set; } public EntityModel EntityModel { get; set; }
public EntityModel EntityModel { get; set; } public RepositoryInterfaceModel([NotNull] string name) : base(name)
{
public RepositoryInterfaceModel([NotNull] string name) : base(name)
{
}
} }
} }

69
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Feature/FeatureModel.cs

@ -1,40 +1,39 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Feature namespace Volo.Abp.Studio.Analyzing.Models.Feature;
[PackageContentItemName(ContentTypeName)]
public class FeatureModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "feature";
public class FeatureModel : PackageContentItemModel
public string ValueType { get; }
public string DefaultValue { get; }
public string DisplayName { get; }
public string Description { get; }
public bool IsAvailableToHost { get; }
public bool IsVisibleToClients { get; }
public FeatureModel(
[NotNull] string name,
[NotNull] string valueType,
string defaultValue,
string displayName,
string description,
bool isAvailableToHost,
bool isVisibleToClients
) : base(name)
{ {
public const string ContentTypeName = "feature"; ValueType = valueType;
DefaultValue = defaultValue;
public string ValueType { get; } DisplayName = displayName;
Description = description;
public string DefaultValue { get; } IsAvailableToHost = isAvailableToHost;
IsVisibleToClients = isVisibleToClients;
public string DisplayName { get; }
public string Description { get; }
public bool IsAvailableToHost { get; }
public bool IsVisibleToClients { get; }
public FeatureModel(
[NotNull] string name,
[NotNull] string valueType,
string defaultValue,
string displayName,
string description,
bool isAvailableToHost,
bool isVisibleToClients
) : base(name)
{
ValueType = valueType;
DefaultValue = defaultValue;
DisplayName = displayName;
Description = description;
IsAvailableToHost = isAvailableToHost;
IsVisibleToClients = isVisibleToClients;
}
} }
} }

21
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Module/AbpModuleModel.cs

@ -1,16 +1,15 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Module namespace Volo.Abp.Studio.Analyzing.Models.Module;
[PackageContentItemName(ContentTypeName)]
public class AbpModuleModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "abpModule";
public class AbpModuleModel : PackageContentItemModel
public string Namespace { get; set; }
public AbpModuleModel([NotNull] string name) : base(name)
{ {
public const string ContentTypeName = "abpModule";
public string Namespace { get; set; }
public AbpModuleModel([NotNull] string name) : base(name)
{
}
} }
} }

21
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageContentItemModel.cs

@ -1,16 +1,15 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models namespace Volo.Abp.Studio.Analyzing.Models;
public abstract class PackageContentItemModel
{ {
public abstract class PackageContentItemModel public string ContentType { get; }
public string Name { get; }
public PackageContentItemModel([NotNull] string name)
{ {
public string ContentType { get; } Name = Check.NotNullOrWhiteSpace(name, nameof(name));
public string Name { get; } ContentType = PackageContentItemNameAttribute.GetName(GetType());
public PackageContentItemModel([NotNull] string name)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name));
ContentType = PackageContentItemNameAttribute.GetName(GetType());
}
} }
} }

31
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageContentItemNameAttribute.cs

@ -1,26 +1,25 @@
using System; using System;
using Volo.Abp.Reflection; using Volo.Abp.Reflection;
namespace Volo.Abp.Studio.Analyzing.Models namespace Volo.Abp.Studio.Analyzing.Models;
public class PackageContentItemNameAttribute : Attribute
{ {
public class PackageContentItemNameAttribute : Attribute public string Name { get; }
public PackageContentItemNameAttribute(string name)
{ {
public string Name { get; } Name = name;
}
public PackageContentItemNameAttribute(string name) public static string GetName(Type type)
{
var attribute = ReflectionHelper.GetSingleAttributeOrDefault<PackageContentItemNameAttribute>(type);
if (attribute == null)
{ {
Name = name; throw new ApplicationException($"Given type {type.FullName} must have an {nameof(PackageContentItemNameAttribute)}, but not defined!");
} }
public static string GetName(Type type)
{
var attribute = ReflectionHelper.GetSingleAttributeOrDefault<PackageContentItemNameAttribute>(type);
if (attribute == null)
{
throw new ApplicationException($"Given type {type.FullName} must have an {nameof(PackageContentItemNameAttribute)}, but not defined!");
}
return attribute.Name; return attribute.Name;
}
} }
} }

11
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageContentList.cs

@ -1,9 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Volo.Abp.Studio.Analyzing.Models namespace Volo.Abp.Studio.Analyzing.Models;
public class PackageContentList : List<PackageContentItemModel>
{ {
public class PackageContentList : List<PackageContentItemModel>
{ }
}
}

27
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/PackageModel.cs

@ -1,20 +1,19 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models namespace Volo.Abp.Studio.Analyzing.Models;
public class PackageModel
{ {
public class PackageModel public string Name { get; }
{
public string Name { get; }
public string Hash { get; } public string Hash { get; }
public PackageContentList Contents { get; }
public PackageModel([NotNull] string name, [NotNull] string hash) public PackageContentList Contents { get; }
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); public PackageModel([NotNull] string name, [NotNull] string hash)
Contents = new PackageContentList(); {
Hash = hash; Name = Check.NotNullOrWhiteSpace(name, nameof(name));
} Contents = new PackageContentList();
Hash = hash;
} }
} }

31
studio/src/Volo.Abp.Studio.Analyzing.Abstractions/Volo/Abp/Studio/Analyzing/Models/Setting/SettingModel.cs

@ -1,26 +1,25 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing.Models.Setting namespace Volo.Abp.Studio.Analyzing.Models.Setting;
[PackageContentItemName(ContentTypeName)]
public class SettingModel : PackageContentItemModel
{ {
[PackageContentItemName(ContentTypeName)] public const string ContentTypeName = "setting";
public class SettingModel : PackageContentItemModel
{
public const string ContentTypeName = "setting";
public string DefaultValue { get; set; } public string DefaultValue { get; set; }
public string DisplayName { get; set; } public string DisplayName { get; set; }
public string Description { get; set; } public string Description { get; set; }
public bool IsVisibleToClient { get; set; } public bool IsVisibleToClient { get; set; }
public bool IsInherited { get; set; } public bool IsInherited { get; set; }
public bool IsEncrypted { get; set; } public bool IsEncrypted { get; set; }
public SettingModel([NotNull] string name) : base(name) public SettingModel([NotNull] string name) : base(name)
{ {
}
} }
} }

17
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/AbpStudioDomainCommonServicesModule.cs

@ -2,16 +2,15 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.Studio namespace Volo.Abp.Studio;
[DependsOn(
typeof(AbpStudioDomainSharedModule)
)]
public class AbpStudioDomainCommonServicesModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpStudioDomainSharedModule)
)]
public class AbpStudioDomainCommonServicesModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) context.Services.AddSingleton<IFileSystem>(new FileSystem());
{
context.Services.AddSingleton<IFileSystem>(new FileSystem());
}
} }
} }

37
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/AbpStudioException.cs

@ -2,27 +2,26 @@
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace Volo.Abp.Studio namespace Volo.Abp.Studio;
public class AbpStudioException : BusinessException
{ {
public class AbpStudioException : BusinessException public AbpStudioException(
string code = null,
string message = null,
string details = null,
Exception innerException = null,
LogLevel logLevel = LogLevel.Warning)
: base(code, message, details, innerException, logLevel)
{ {
public AbpStudioException( Code = code;
string code = null, Details = details;
string message = null, LogLevel = logLevel;
string details = null, }
Exception innerException = null,
LogLevel logLevel = LogLevel.Warning)
: base(code, message, details, innerException, logLevel)
{
Code = code;
Details = details;
LogLevel = logLevel;
}
public AbpStudioException(SerializationInfo serializationInfo, StreamingContext context) public AbpStudioException(SerializationInfo serializationInfo, StreamingContext context)
: base(serializationInfo, context) : base(serializationInfo, context)
{ {
}
} }
} }

43
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Helpers/PathHelper.cs

@ -2,36 +2,35 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Helpers namespace Volo.Abp.Studio.Helpers;
public static class PathHelper
{ {
public static class PathHelper public static string GetRelativePath([NotNull] string basePath, [NotNull] string targetPath)
{ {
public static string GetRelativePath([NotNull] string basePath, [NotNull] string targetPath) Check.NotNull(basePath, nameof(basePath));
{ Check.NotNull(targetPath, nameof(targetPath));
Check.NotNull(basePath, nameof(basePath));
Check.NotNull(targetPath, nameof(targetPath));
return new Uri(basePath).MakeRelativeUri(new Uri(targetPath)).ToString(); return new Uri(basePath).MakeRelativeUri(new Uri(targetPath)).ToString();
} }
public static string EnsureForwardSlash(string path) public static string EnsureForwardSlash(string path)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return path.Replace("\\", "/");
{
return path.Replace("\\", "/");
}
return path;
} }
public static string Normalize(string path) return path;
{ }
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return path.Replace("/", "\\");
}
return path; public static string Normalize(string path)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return path.Replace("/", "\\");
} }
return path;
} }
} }

103
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/AbpModuleFileManager.cs

@ -5,73 +5,72 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Studio.Packages.Modifying namespace Volo.Abp.Studio.Packages.Modifying;
public class AbpModuleFileManager : IAbpModuleFileManager, ITransientDependency
{ {
public class AbpModuleFileManager : IAbpModuleFileManager, ITransientDependency public IFileSystem FileSystem { get; }
public AbpModuleFileManager(IFileSystem fileSystem)
{
FileSystem = fileSystem;
}
public async Task AddDependency(string filePath, string moduleToAdd)
{ {
public IFileSystem FileSystem { get; } var fileContent = await FileSystem.File.ReadAllTextAsync(filePath);
var moduleName = moduleToAdd.Split(".").Last();
var moduleNamespace = moduleToAdd.RemovePostFix("." + moduleName);
var usingStatement = $"using {moduleNamespace};";
var dependsOnStart = $"DependsOn(";
public AbpModuleFileManager(IFileSystem fileSystem) if (fileContent.Contains($"typeof({moduleName})"))
{ {
FileSystem = fileSystem; // module already added
return;
} }
public async Task AddDependency(string filePath, string moduleToAdd) if (!fileContent.NormalizeLineEndings().SplitToLines().Any(l => l.Trim().StartsWith("namespace ") && l.Contains(moduleNamespace)) &&
!fileContent.Contains(usingStatement)
)
{ {
var fileContent = await FileSystem.File.ReadAllTextAsync(filePath); fileContent = usingStatement + Environment.NewLine + fileContent;
var moduleName = moduleToAdd.Split(".").Last();
var moduleNamespace = moduleToAdd.RemovePostFix("." + moduleName);
var usingStatement = $"using {moduleNamespace};";
var dependsOnStart = $"DependsOn(";
if (fileContent.Contains($"typeof({moduleName})"))
{
// module already added
return;
}
if (!fileContent.NormalizeLineEndings().SplitToLines().Any(l=> l.Trim().StartsWith("namespace ") && l.Contains(moduleNamespace)) &&
!fileContent.Contains(usingStatement)
)
{
fileContent = usingStatement + Environment.NewLine + fileContent;
}
if (!fileContent.Contains(dependsOnStart))
{
var fileLines = fileContent.NormalizeLineEndings().SplitToLines().ToList();
fileLines.InsertBefore(l=> l.Contains("public") && l.Contains("class"), $" [DependsOn(typeof({moduleName}))]");
fileContent = fileLines.JoinAsString(Environment.NewLine);
}
else
{
var fileLines = fileContent.NormalizeLineEndings().SplitToLines().ToList();
var dependsOnStartLine = fileLines.First(l=> l.Contains(dependsOnStart));
var dependsOnStartLineModified = dependsOnStartLine.Replace(dependsOnStart,
dependsOnStart + Environment.NewLine +
$" typeof({moduleName}),"
);
fileContent = fileContent.Replace(dependsOnStartLine, dependsOnStartLineModified);
}
FileSystem.File.WriteAllTextAsync(filePath, fileContent);
} }
public async Task<string> ExtractModuleNameWithNamespace(string filePath) if (!fileContent.Contains(dependsOnStart))
{ {
var fileContent = await FileSystem.File.ReadAllTextAsync(filePath); var fileLines = fileContent.NormalizeLineEndings().SplitToLines().ToList();
fileLines.InsertBefore(l => l.Contains("public") && l.Contains("class"), $" [DependsOn(typeof({moduleName}))]");
fileContent = fileLines.JoinAsString(Environment.NewLine);
}
else
{
var fileLines = fileContent.NormalizeLineEndings().SplitToLines().ToList();
var dependsOnStartLine = fileLines.First(l => l.Contains(dependsOnStart));
var dependsOnStartLineModified = dependsOnStartLine.Replace(dependsOnStart,
dependsOnStart + Environment.NewLine +
$" typeof({moduleName}),"
);
fileContent = fileContent.Replace(dependsOnStartLine, dependsOnStartLineModified);
}
FileSystem.File.WriteAllTextAsync(filePath, fileContent);
}
public async Task<string> ExtractModuleNameWithNamespace(string filePath)
{
var fileContent = await FileSystem.File.ReadAllTextAsync(filePath);
var fileLines = fileContent.NormalizeLineEndings().SplitToLines(); var fileLines = fileContent.NormalizeLineEndings().SplitToLines();
var lineOfClassName = fileLines.First(l=> l.Contains("public") && l.Contains("class")); var lineOfClassName = fileLines.First(l => l.Contains("public") && l.Contains("class"));
var moduleName = lineOfClassName.Split(":")[0].Trim().Split(" ").Last(); var moduleName = lineOfClassName.Split(":")[0].Trim().Split(" ").Last();
var lineOfNamespace = fileLines.First(l=> l.Trim().StartsWith("namespace")); var lineOfNamespace = fileLines.First(l => l.Trim().StartsWith("namespace"));
var moduleNamespace = lineOfNamespace.Split(" ").Skip(1).First(); var moduleNamespace = lineOfNamespace.Split(" ").Skip(1).First();
return moduleNamespace + "." + moduleName; return moduleNamespace + "." + moduleName;
}
} }
} }

265
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/CsprojFileManager.cs

@ -8,197 +8,196 @@ using Volo.Abp.Studio.Helpers;
using Volo.Abp.Studio.Package; using Volo.Abp.Studio.Package;
using Volo.Abp.Studio.Xml; using Volo.Abp.Studio.Xml;
namespace Volo.Abp.Studio.Packages.Modifying namespace Volo.Abp.Studio.Packages.Modifying;
public class CsprojFileManager : XmlFileManagerBase, ICsprojFileManager, ITransientDependency
{ {
public class CsprojFileManager: XmlFileManagerBase, ICsprojFileManager, ITransientDependency public async Task AddProjectReferenceAsync(string filePath, string projectToReference)
{ {
public async Task AddProjectReferenceAsync(string filePath, string projectToReference) var document = await GetXmlDocumentAsync(filePath);
/*if (document.SelectNodes($"/Project/ItemGroup/ProjectReference[ends-with(@Include, '{Path.GetFileName(projectToReference)}')]").Count > 0)
{ {
var document = await GetXmlDocumentAsync(filePath); return;
}*/
/*if (document.SelectNodes($"/Project/ItemGroup/ProjectReference[ends-with(@Include, '{Path.GetFileName(projectToReference)}')]").Count > 0) var packageReferenceToSameProject =
{ document.SelectNodes(
return; $"/Project/ItemGroup/PackageReference[starts-with(@Include, '{Path.GetFileName(projectToReference).RemovePostFix(".csproj")}')]"
}*/ );
var packageReferenceToSameProject = if (packageReferenceToSameProject.Count > 0)
document.SelectNodes( {
$"/Project/ItemGroup/PackageReference[starts-with(@Include, '{Path.GetFileName(projectToReference).RemovePostFix(".csproj")}')]" packageReferenceToSameProject[0].ParentNode.RemoveChild(packageReferenceToSameProject[0]);
); }
if (packageReferenceToSameProject.Count > 0) var relativePath = PathHelper.GetRelativePath(filePath, projectToReference);
{
packageReferenceToSameProject[0].ParentNode.RemoveChild(packageReferenceToSameProject[0]);
}
var relativePath = PathHelper.GetRelativePath(filePath, projectToReference); var itemGroupNode = GetOrCreateItemGroupNode(document);
var itemGroupNode = GetOrCreateItemGroupNode(document); var newNode = document.CreateElement("ProjectReference");
var newNode = document.CreateElement("ProjectReference"); var includeAttr = document.CreateAttribute("Include");
includeAttr.Value = relativePath;
newNode.Attributes.Append(includeAttr);
var includeAttr = document.CreateAttribute("Include"); itemGroupNode.AppendChild(newNode);
includeAttr.Value = relativePath;
newNode.Attributes.Append(includeAttr);
itemGroupNode.AppendChild(newNode); await SaveXmlDocumentAsync(filePath, document);
}
await SaveXmlDocumentAsync(filePath, document); public async Task AddPackageReferenceAsync(string filePath, string packageName, string version)
} {
var document = await GetXmlDocumentAsync(filePath);
public async Task AddPackageReferenceAsync(string filePath, string packageName, string version) if (document.SelectNodes($"/Project/ItemGroup/PackageReference[starts-with(@Include, '{packageName}')]").Count > 0)
{ {
var document = await GetXmlDocumentAsync(filePath); // Package reference is already added.
return;
if (document.SelectNodes($"/Project/ItemGroup/PackageReference[starts-with(@Include, '{packageName}')]").Count > 0) }
{
// Package reference is already added.
return;
}
var itemGroupNode = GetOrCreateItemGroupNode(document); var itemGroupNode = GetOrCreateItemGroupNode(document);
var newNode = document.CreateElement("PackageReference"); var newNode = document.CreateElement("PackageReference");
var includeAttr = document.CreateAttribute("Include"); var includeAttr = document.CreateAttribute("Include");
includeAttr.Value = packageName; includeAttr.Value = packageName;
newNode.Attributes.Append(includeAttr); newNode.Attributes.Append(includeAttr);
var versionAttr = document.CreateAttribute("Version"); var versionAttr = document.CreateAttribute("Version");
versionAttr.Value = version; versionAttr.Value = version;
newNode.Attributes.Append(versionAttr); newNode.Attributes.Append(versionAttr);
itemGroupNode.AppendChild(newNode); itemGroupNode.AppendChild(newNode);
itemGroupNode.AppendChild(document.CreateWhitespace(Environment.NewLine + " ")); itemGroupNode.AppendChild(document.CreateWhitespace(Environment.NewLine + " "));
await SaveXmlDocumentAsync(filePath, document); await SaveXmlDocumentAsync(filePath, document);
} }
public async Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference) public async Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference)
{ {
var document = await GetXmlDocumentAsync(filePath); var document = await GetXmlDocumentAsync(filePath);
var packageName = Path.GetFileName(projectToReference).RemovePostFix(".csproj"); var packageName = Path.GetFileName(projectToReference).RemovePostFix(".csproj");
var matchedNodes = document.SelectNodes($"/Project/ItemGroup/PackageReference[starts-with(@Include, '{packageName}')]"); var matchedNodes = document.SelectNodes($"/Project/ItemGroup/PackageReference[starts-with(@Include, '{packageName}')]");
if (matchedNodes.Count == 0) if (matchedNodes.Count == 0)
{ {
return; return;
} }
XmlNode targetNode = null; XmlNode targetNode = null;
foreach (XmlNode matchedNode in matchedNodes) foreach (XmlNode matchedNode in matchedNodes)
{
if (matchedNode.Attributes["Include"].Value == packageName)
{ {
if (matchedNode.Attributes["Include"].Value == packageName) targetNode = matchedNode;
{ break;
targetNode = matchedNode;
break;
}
} }
}
if (targetNode == null) if (targetNode == null)
{ {
return; return;
} }
var targetNodeParent = targetNode.ParentNode; var targetNodeParent = targetNode.ParentNode;
targetNodeParent.RemoveChild(targetNode); targetNodeParent.RemoveChild(targetNode);
var relativePath = PathHelper.GetRelativePath(filePath, projectToReference); var relativePath = PathHelper.GetRelativePath(filePath, projectToReference);
var newNode = document.CreateElement("ProjectReference"); var newNode = document.CreateElement("ProjectReference");
var includeAttr = document.CreateAttribute("Include"); var includeAttr = document.CreateAttribute("Include");
includeAttr.Value = relativePath; includeAttr.Value = relativePath;
newNode.Attributes.Append(includeAttr); newNode.Attributes.Append(includeAttr);
targetNodeParent.AppendChild(newNode); targetNodeParent.AppendChild(newNode);
await SaveXmlDocumentAsync(filePath, document); await SaveXmlDocumentAsync(filePath, document);
} }
public async Task<string> GetTargetFrameworkAsync(string filePath) public async Task<string> GetTargetFrameworkAsync(string filePath)
{ {
var document = await GetXmlDocumentAsync(filePath); var document = await GetXmlDocumentAsync(filePath);
var nodes = document["Project"]?["PropertyGroup"]?.SelectNodes("TargetFramework"); var nodes = document["Project"]?["PropertyGroup"]?.SelectNodes("TargetFramework");
if (nodes == null || nodes.Count == 0) if (nodes == null || nodes.Count == 0)
{ {
return null; return null;
}
return nodes[0].InnerText.Trim();
} }
public async Task<List<PackageDependency>> GetDependencyListAsync(string filePath) return nodes[0].InnerText.Trim();
{ }
var result = new List<PackageDependency>();
var document = await GetXmlDocumentAsync(filePath); public async Task<List<PackageDependency>> GetDependencyListAsync(string filePath)
{
var result = new List<PackageDependency>();
var packageReferenceNodes = document.SelectNodes($"/Project/ItemGroup/PackageReference"); var document = await GetXmlDocumentAsync(filePath);
var projectReferenceNodes = document.SelectNodes($"/Project/ItemGroup/ProjectReference");
if (packageReferenceNodes != null && packageReferenceNodes.Count > 0) var packageReferenceNodes = document.SelectNodes($"/Project/ItemGroup/PackageReference");
{ var projectReferenceNodes = document.SelectNodes($"/Project/ItemGroup/ProjectReference");
foreach (XmlNode packageReferenceNode in packageReferenceNodes)
{
result.Add(
new PackageDependency(
packageReferenceNode.Attributes["Include"].Value,
packageReferenceNode.Attributes["Version"].Value
)
);
}
}
if (projectReferenceNodes != null && projectReferenceNodes.Count > 0) if (packageReferenceNodes != null && packageReferenceNodes.Count > 0)
{
foreach (XmlNode packageReferenceNode in packageReferenceNodes)
{ {
foreach (XmlNode projectReferenceNode in projectReferenceNodes) result.Add(
{ new PackageDependency(
result.Add( packageReferenceNode.Attributes["Include"].Value,
new PackageDependency( packageReferenceNode.Attributes["Version"].Value
Path.GetFullPath(Path.Combine(Path.GetDirectoryName(filePath), projectReferenceNode.Attributes["Include"].Value)) )
) );
);
}
} }
return result;
} }
private XmlNode GetOrCreateItemGroupNode(XmlDocument document) if (projectReferenceNodes != null && projectReferenceNodes.Count > 0)
{ {
var nodes = document["Project"].SelectNodes("ItemGroup"); foreach (XmlNode projectReferenceNode in projectReferenceNodes)
if (nodes == null || nodes.Count < 1)
{ {
var newNode = document.CreateElement("ItemGroup"); result.Add(
document["Project"].AppendChild(newNode); new PackageDependency(
return newNode; Path.GetFullPath(Path.Combine(Path.GetDirectoryName(filePath), projectReferenceNode.Attributes["Include"].Value))
)
);
} }
}
return result;
}
private XmlNode GetOrCreateItemGroupNode(XmlDocument document)
{
var nodes = document["Project"].SelectNodes("ItemGroup");
if (nodes == null || nodes.Count < 1)
{
var newNode = document.CreateElement("ItemGroup");
document["Project"].AppendChild(newNode);
return newNode;
}
foreach (XmlNode node in nodes) foreach (XmlNode node in nodes)
{
if (node.SelectNodes("ProjectReference").Count > 0)
{ {
if (node.SelectNodes("ProjectReference").Count > 0) return node;
{
return node;
}
} }
}
foreach (XmlNode node in nodes) foreach (XmlNode node in nodes)
{
if (node.SelectNodes("PackageReference").Count > 0)
{ {
if (node.SelectNodes("PackageReference").Count > 0) return node;
{
return node;
}
} }
return nodes[0];
} }
return nodes[0];
} }
} }

11
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/IAbpModuleFileManager.cs

@ -1,11 +1,10 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.Packages.Modifying namespace Volo.Abp.Studio.Packages.Modifying;
public interface IAbpModuleFileManager
{ {
public interface IAbpModuleFileManager Task AddDependency(string filePath, string moduleToAdd);
{
Task AddDependency(string filePath, string moduleToAdd);
Task<string> ExtractModuleNameWithNamespace(string filePath); Task<string> ExtractModuleNameWithNamespace(string filePath);
}
} }

17
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/ICsprojFileManager.cs

@ -2,18 +2,17 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Studio.Package; using Volo.Abp.Studio.Package;
namespace Volo.Abp.Studio.Packages.Modifying namespace Volo.Abp.Studio.Packages.Modifying;
public interface ICsprojFileManager
{ {
public interface ICsprojFileManager Task AddProjectReferenceAsync(string filePath, string projectToReference);
{
Task AddProjectReferenceAsync(string filePath, string projectToReference);
Task AddPackageReferenceAsync(string filePath, string packageName, string version); Task AddPackageReferenceAsync(string filePath, string packageName, string version);
Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference); Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference);
Task<string> GetTargetFrameworkAsync(string filePath); Task<string> GetTargetFrameworkAsync(string filePath);
Task<List<PackageDependency>> GetDependencyListAsync(string filePath); Task<List<PackageDependency>> GetDependencyListAsync(string filePath);
}
} }

25
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/INugetSourceCodeStore.cs

@ -1,18 +1,17 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.Nuget namespace Volo.Abp.Studio.Nuget;
public interface INugetSourceCodeStore
{ {
public interface INugetSourceCodeStore Task<string> GetCachedSourceCodeFilePathAsync(string name,
{ string type,
Task<string> GetCachedSourceCodeFilePathAsync(string name, string version = null,
string type, bool includePreReleases = false);
string version = null,
bool includePreReleases = false);
Task<string> GetCachedDllFilePathAsync(string name, Task<string> GetCachedDllFilePathAsync(string name,
string type, string type,
string version = null, string version = null,
bool includePreReleases = false, bool includePreReleases = false,
bool includeDependencies = false); bool includeDependencies = false);
}
} }

39
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/NugetPackageCacheManager.cs

@ -5,32 +5,31 @@ using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Studio.Helpers; using Volo.Abp.Studio.Helpers;
namespace Volo.Abp.Studio.Nuget namespace Volo.Abp.Studio.Nuget;
{
public class NugetPackageCacheManager : ITransientDependency
{
private readonly ICmdHelper _cmdHelper;
public NugetPackageCacheManager(ICmdHelper cmdHelper) public class NugetPackageCacheManager : ITransientDependency
{ {
_cmdHelper = cmdHelper; private readonly ICmdHelper _cmdHelper;
}
public async Task<string> CachePackageAsync(string packageName, string version, bool deleteAfter = true) public NugetPackageCacheManager(ICmdHelper cmdHelper)
{ {
var temporaryFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); _cmdHelper = cmdHelper;
}
Directory.CreateDirectory(temporaryFolder); public async Task<string> CachePackageAsync(string packageName, string version, bool deleteAfter = true)
{
var temporaryFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
_cmdHelper.RunCmdAndGetOutput("dotnet new console -lang c#", temporaryFolder); Directory.CreateDirectory(temporaryFolder);
_cmdHelper.RunCmdAndGetOutput($"dotnet add package {packageName} --version {version}", temporaryFolder);
if (deleteAfter) _cmdHelper.RunCmdAndGetOutput("dotnet new console -lang c#", temporaryFolder);
{ _cmdHelper.RunCmdAndGetOutput($"dotnet add package {packageName} --version {version}", temporaryFolder);
Directory.Delete(temporaryFolder, true);
}
return temporaryFolder; if (deleteAfter)
{
Directory.Delete(temporaryFolder, true);
} }
return temporaryFolder;
} }
} }

223
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/NugetSourceCodeStore.cs

@ -9,155 +9,154 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Studio.Helpers; using Volo.Abp.Studio.Helpers;
using Volo.Abp.Studio.Modules; using Volo.Abp.Studio.Modules;
namespace Volo.Abp.Studio.Nuget namespace Volo.Abp.Studio.Nuget;
[Dependency(ReplaceServices = true)]
public class NugetSourceCodeStore : ISourceCodeStore, INugetSourceCodeStore, ITransientDependency
{ {
[Dependency(ReplaceServices = true)] private readonly NuGetService _nuGetService;
public class NugetSourceCodeStore : ISourceCodeStore, INugetSourceCodeStore, ITransientDependency private readonly NugetPackageCacheManager _nugetPackageCacheManager;
private readonly ICmdHelper _cmdHelper;
public NugetSourceCodeStore(
NuGetService nuGetService,
NugetPackageCacheManager nugetPackageCacheManager,
ICmdHelper cmdHelper)
{ {
private readonly NuGetService _nuGetService; _nuGetService = nuGetService;
private readonly NugetPackageCacheManager _nugetPackageCacheManager; _nugetPackageCacheManager = nugetPackageCacheManager;
private readonly ICmdHelper _cmdHelper; _cmdHelper = cmdHelper;
}
public NugetSourceCodeStore(
NuGetService nuGetService,
NugetPackageCacheManager nugetPackageCacheManager,
ICmdHelper cmdHelper)
{
_nuGetService = nuGetService;
_nugetPackageCacheManager = nugetPackageCacheManager;
_cmdHelper = cmdHelper;
}
public async Task<TemplateFile> GetAsync(
string name,
string type,
string version = null,
string templateSource = null,
bool includePreReleases = false)
{
name = GetNugetPackageName(name, type);
var latestVersion = await GetLatestVersionAsync(name, includePreReleases); public async Task<TemplateFile> GetAsync(
string name,
string type,
string version = null,
string templateSource = null,
bool includePreReleases = false)
{
name = GetNugetPackageName(name, type);
version ??= latestVersion; var latestVersion = await GetLatestVersionAsync(name, includePreReleases);
var localCachedFilePath = await GetLocalCacheSourceCodeFilePathInternal(name, version); version ??= latestVersion;
if (localCachedFilePath == null) var localCachedFilePath = await GetLocalCacheSourceCodeFilePathInternal(name, version);
{
return null;
}
return new TemplateFile(await File.ReadAllBytesAsync(localCachedFilePath), version, latestVersion, version); if (localCachedFilePath == null)
{
return null;
} }
public async Task<string> GetCachedSourceCodeFilePathAsync(string name, string type, string version = null, return new TemplateFile(await File.ReadAllBytesAsync(localCachedFilePath), version, latestVersion, version);
bool includePreReleases = false) }
{
name = GetNugetPackageName(name, type); public async Task<string> GetCachedSourceCodeFilePathAsync(string name, string type, string version = null,
bool includePreReleases = false)
{
name = GetNugetPackageName(name, type);
version ??= await GetLatestVersionAsync(name, includePreReleases);
version ??= await GetLatestVersionAsync(name, includePreReleases); return await GetLocalCacheSourceCodeFilePathInternal(name, version);
}
return await GetLocalCacheSourceCodeFilePathInternal(name, version); public async Task<string> GetCachedDllFilePathAsync(string name, string type, string version = null, bool includePreReleases = false, bool includeDependencies = false)
{
if (type == SourceCodeTypes.Template)
{
name = TemplateNugetPackageInfoProvider.GetNugetPackageName(name);
} }
public async Task<string> GetCachedDllFilePathAsync(string name, string type, string version = null, bool includePreReleases = false, bool includeDependencies = false) version ??= await GetLatestVersionAsync(name, includePreReleases);
var localDllFolder = Path.Combine(
GetLocalNugetCachePath(),
name,
version,
"lib");
if (!Directory.Exists(localDllFolder) ||
(includeDependencies && !Directory.GetFiles(localDllFolder, $"*Volo.Abp.Studio.ModuleInstaller.dll", SearchOption.AllDirectories).Any()))
{ {
if (type == SourceCodeTypes.Template) if (includeDependencies)
{ {
name = TemplateNugetPackageInfoProvider.GetNugetPackageName(name); var temporaryFolder = await _nugetPackageCacheManager.CachePackageAsync(name, version, false);
}
version ??= await GetLatestVersionAsync(name, includePreReleases); var outputFolder = Path.GetDirectoryName(
Directory
.GetFiles(localDllFolder, $"*{name}.dll", SearchOption.AllDirectories)
.First()
);
var localDllFolder = Path.Combine( _cmdHelper.RunCmdAndGetOutput($"dotnet build -o {outputFolder}", temporaryFolder);
GetLocalNugetCachePath(),
name,
version,
"lib");
if (!Directory.Exists(localDllFolder) || Directory.Delete(temporaryFolder, true);
(includeDependencies && !Directory.GetFiles(localDllFolder, $"*Volo.Abp.Studio.ModuleInstaller.dll", SearchOption.AllDirectories).Any()))
{
if (includeDependencies)
{
var temporaryFolder = await _nugetPackageCacheManager.CachePackageAsync(name, version, false);
var outputFolder = Path.GetDirectoryName(
Directory
.GetFiles(localDllFolder, $"*{name}.dll", SearchOption.AllDirectories)
.First()
);
_cmdHelper.RunCmdAndGetOutput($"dotnet build -o {outputFolder}", temporaryFolder);
Directory.Delete(temporaryFolder, true);
}
else
{
await _nugetPackageCacheManager.CachePackageAsync(name, version);
}
} }
else
if (!Directory.Exists(localDllFolder))
{ {
return null; await _nugetPackageCacheManager.CachePackageAsync(name, version);
} }
return Directory.GetFiles(localDllFolder, $"{name}.dll", SearchOption.AllDirectories).FirstOrDefault();
} }
private async Task<string> GetLatestVersionAsync(string nugetPackage, bool includePreReleases) if (!Directory.Exists(localDllFolder))
{ {
var v = await _nuGetService.GetLatestVersionOrNullAsync(nugetPackage, includePreReleases); return null;
return v.ToString();
} }
private async Task<string> GetLocalCacheSourceCodeFilePathInternal(string name, string version) return Directory.GetFiles(localDllFolder, $"{name}.dll", SearchOption.AllDirectories).FirstOrDefault();
{ }
var localCacheFile = Path.Combine(
GetLocalNugetCachePath(),
name,
version,
"content",
$"{name}.zip");
private async Task<string> GetLatestVersionAsync(string nugetPackage, bool includePreReleases)
{
var v = await _nuGetService.GetLatestVersionOrNullAsync(nugetPackage, includePreReleases);
if (!File.Exists(localCacheFile)) return v.ToString();
{ }
await _nugetPackageCacheManager.CachePackageAsync(name, version);
if (!File.Exists(localCacheFile)) private async Task<string> GetLocalCacheSourceCodeFilePathInternal(string name, string version)
{ {
return null; var localCacheFile = Path.Combine(
} GetLocalNugetCachePath(),
} name,
version,
"content",
$"{name}.zip");
return localCacheFile;
}
private string GetLocalNugetCachePath() if (!File.Exists(localCacheFile))
{ {
return Path.Combine( await _nugetPackageCacheManager.CachePackageAsync(name, version);
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
".nuget",
"packages");
}
private string GetNugetPackageName(string name, string type) if (!File.Exists(localCacheFile))
{
if (type == SourceCodeTypes.Template)
{ {
return TemplateNugetPackageInfoProvider.GetNugetPackageName(name); return null;
} }
}
if (type == SourceCodeTypes.Module) return localCacheFile;
{ }
return name + ModuleConsts.SourceCorePackagePostfix;
} private string GetLocalNugetCachePath()
{
return Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
".nuget",
"packages");
}
return name; private string GetNugetPackageName(string name, string type)
{
if (type == SourceCodeTypes.Template)
{
return TemplateNugetPackageInfoProvider.GetNugetPackageName(name);
}
if (type == SourceCodeTypes.Module)
{
return name + ModuleConsts.SourceCorePackagePostfix;
} }
return name;
} }
} }

19
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Nuget/TemplateNugetPackageInfoProvider.cs

@ -1,18 +1,17 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.Nuget namespace Volo.Abp.Studio.Nuget;
public static class TemplateNugetPackageInfoProvider
{ {
public static class TemplateNugetPackageInfoProvider public static string GetNugetPackageName(string template)
{ {
public static string GetNugetPackageName(string template) switch (template)
{ {
switch (template) case "app":
{ return "Cotur.Abp.Basic.Template"; // todo: replace with real template!
case "app": default:
return "Cotur.Abp.Basic.Template"; // todo: replace with real template! return null;
default:
return null;
}
} }
} }
} }

37
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageDependency.cs

@ -1,30 +1,29 @@
using System; using System;
using System.IO; using System.IO;
namespace Volo.Abp.Studio.Package namespace Volo.Abp.Studio.Package;
public class PackageDependency
{ {
public class PackageDependency public ReferenceType Type { get; }
{
public ReferenceType Type { get; }
public string Name { get; } public string Name { get; }
public string Version { get; } public string Version { get; }
public string Path { get; } public string Path { get; }
public PackageDependency(string name, string version) public PackageDependency(string name, string version)
{ {
Type = ReferenceType.Package; Type = ReferenceType.Package;
Name = name; Name = name;
Version = version; Version = version;
} }
public PackageDependency(string path) public PackageDependency(string path)
{ {
Type = ReferenceType.Project; Type = ReferenceType.Project;
Path = path; Path = path;
Name = System.IO.Path.GetFileName(path).RemovePostFix(".csproj"); Name = System.IO.Path.GetFileName(path).RemovePostFix(".csproj");
}
} }
} }

287
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageTypes.cs

@ -1,127 +1,127 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Volo.Abp.Studio.Packages namespace Volo.Abp.Studio.Packages;
public static class PackageTypes
{ {
public static class PackageTypes public const string Domain = "lib.domain";
public const string DomainShared = "lib.domain-shared";
public const string Application = "lib.application";
public const string ApplicationContracts = "lib.application-contracts";
public const string EntityFrameworkCore = "lib.ef";
public const string MongoDB = "lib.mongodb";
public const string HttpApi = "lib.http-api";
public const string HttpApiClient = "lib.http-api-client";
public const string Mvc = "lib.mvc";
public const string Blazor = "lib.blazor";
public const string BlazorWebAssembly = "lib.blazor-wasm";
public const string BlazorServer = "lib.blazor-server";
public const string Test = "lib.test";
public const string HostHttpApi = "host.http-api";
public const string HostMvc = "host.mvc";
public const string HostBlazorWebAssembly = "host.blazor-wasm";
public const string HostBlazorServer = "host.blazor-server";
public const string HostApiGatewayOcelot = "host.api-gateway-ocelot";
public static string CalculateDefaultPackageNameForModule(
string moduleName,
string packageType)
{ {
public const string Domain = "lib.domain"; switch (packageType)
public const string DomainShared = "lib.domain-shared";
public const string Application = "lib.application";
public const string ApplicationContracts = "lib.application-contracts";
public const string EntityFrameworkCore = "lib.ef";
public const string MongoDB = "lib.mongodb";
public const string HttpApi = "lib.http-api";
public const string HttpApiClient = "lib.http-api-client";
public const string Mvc = "lib.mvc";
public const string Blazor = "lib.blazor";
public const string BlazorWebAssembly = "lib.blazor-wasm";
public const string BlazorServer = "lib.blazor-server";
public const string Test = "lib.test";
public const string HostHttpApi = "host.http-api";
public const string HostMvc = "host.mvc";
public const string HostBlazorWebAssembly = "host.blazor-wasm";
public const string HostBlazorServer = "host.blazor-server";
public const string HostApiGatewayOcelot = "host.api-gateway-ocelot";
public static string CalculateDefaultPackageNameForModule(
string moduleName,
string packageType)
{ {
switch (packageType) case Domain:
{ return moduleName + ".Domain";
case Domain: case DomainShared:
return moduleName + ".Domain"; return moduleName + ".Domain.Shared";
case DomainShared: case Application:
return moduleName + ".Domain.Shared"; return moduleName + ".Application";
case Application: case ApplicationContracts:
return moduleName + ".Application"; return moduleName + ".Application.Contracts";
case ApplicationContracts: case EntityFrameworkCore:
return moduleName + ".Application.Contracts"; return moduleName + ".EntityFrameworkCore";
case EntityFrameworkCore: case HttpApi:
return moduleName + ".EntityFrameworkCore"; return moduleName + ".HttpApi";
case HttpApi: case HttpApiClient:
return moduleName + ".HttpApi"; return moduleName + ".HttpApi.Client";
case HttpApiClient: case MongoDB:
return moduleName + ".HttpApi.Client"; return moduleName + ".MongoDB";
case MongoDB: case Mvc:
return moduleName + ".MongoDB"; return moduleName + ".Web";
case Mvc: case Blazor:
return moduleName + ".Web"; return moduleName + ".Blazor";
case Blazor: case BlazorWebAssembly:
return moduleName + ".Blazor"; return moduleName + ".Blazor.WebAssembly";
case BlazorWebAssembly: case BlazorServer:
return moduleName + ".Blazor.WebAssembly"; return moduleName + ".Blazor.Server";
case BlazorServer: case HostHttpApi:
return moduleName + ".Blazor.Server"; return moduleName + ".HttpApi.Host";
case HostHttpApi: case HostMvc:
return moduleName + ".HttpApi.Host"; return moduleName + ".Web.Host";
case HostMvc: case HostBlazorWebAssembly:
return moduleName + ".Web.Host"; return moduleName + ".Blazor.Client";
case HostBlazorWebAssembly: case HostBlazorServer:
return moduleName + ".Blazor.Client"; return moduleName + ".Blazor.Host";
case HostBlazorServer: case HostApiGatewayOcelot:
return moduleName + ".Blazor.Host"; return moduleName + ".Gateway";
case HostApiGatewayOcelot: default:
return moduleName + ".Gateway"; throw new AbpStudioException(AbpStudioErrorCodes.PackageNameMustBeSpecified);
default:
throw new AbpStudioException(AbpStudioErrorCodes.PackageNameMustBeSpecified);
}
} }
}
public static bool IsHostProject(string packageType) public static bool IsHostProject(string packageType)
{ {
return return
packageType == HostMvc || packageType == HostMvc ||
packageType == HostHttpApi || packageType == HostHttpApi ||
packageType == HostBlazorWebAssembly || packageType == HostBlazorWebAssembly ||
packageType == HostBlazorServer || packageType == HostBlazorServer ||
packageType == HostApiGatewayOcelot; packageType == HostApiGatewayOcelot;
} }
public static bool IsUiProject(string packageType) public static bool IsUiProject(string packageType)
{ {
return return
packageType == Mvc || packageType == Mvc ||
packageType == BlazorWebAssembly || packageType == BlazorWebAssembly ||
packageType == BlazorServer; packageType == BlazorServer;
} }
public static string GetHostTypeOfUi(string packageType, bool useHostBlazorServerForMvcPackages = false) public static string GetHostTypeOfUi(string packageType, bool useHostBlazorServerForMvcPackages = false)
{
return packageType switch
{ {
return packageType switch Mvc => !useHostBlazorServerForMvcPackages ? HostMvc : HostBlazorServer,
{ BlazorWebAssembly => HostBlazorWebAssembly,
Mvc => !useHostBlazorServerForMvcPackages ? HostMvc : HostBlazorServer, BlazorServer => HostBlazorServer,
BlazorWebAssembly => HostBlazorWebAssembly, _ => null
BlazorServer => HostBlazorServer, };
_ => null }
};
}
public static List<string> GetSuggestedInstallationType(string packageType) public static List<string> GetSuggestedInstallationType(string packageType)
{
if (packageType == DomainShared)
{ {
if (packageType == DomainShared) return new List<string>()
{
return new List<string>()
{ {
Domain, Domain,
DomainShared, DomainShared,
ApplicationContracts ApplicationContracts
}; };
} }
if (packageType == Domain) if (packageType == Domain)
{ {
return new List<string>() return new List<string>()
{ {
Domain, Domain,
Application Application
}; };
} }
if (packageType == ApplicationContracts) if (packageType == ApplicationContracts)
{ {
return new List<string>() return new List<string>()
{ {
Application, Application,
ApplicationContracts, ApplicationContracts,
@ -131,11 +131,11 @@ namespace Volo.Abp.Studio.Packages
BlazorWebAssembly, BlazorWebAssembly,
HttpApi HttpApi
}; };
} }
if (packageType == Application) if (packageType == Application)
{ {
return new List<string>() return new List<string>()
{ {
Application, Application,
HostMvc, HostMvc,
@ -143,11 +143,11 @@ namespace Volo.Abp.Studio.Packages
HostBlazorWebAssembly, HostBlazorWebAssembly,
HostHttpApi HostHttpApi
}; };
} }
if (packageType == EntityFrameworkCore) if (packageType == EntityFrameworkCore)
{ {
return new List<string>() return new List<string>()
{ {
EntityFrameworkCore, EntityFrameworkCore,
HostMvc, HostMvc,
@ -155,11 +155,11 @@ namespace Volo.Abp.Studio.Packages
HostBlazorWebAssembly, HostBlazorWebAssembly,
HostHttpApi HostHttpApi
}; };
} }
if (packageType == MongoDB) if (packageType == MongoDB)
{ {
return new List<string>() return new List<string>()
{ {
MongoDB, MongoDB,
HostMvc, HostMvc,
@ -167,11 +167,11 @@ namespace Volo.Abp.Studio.Packages
HostBlazorWebAssembly, HostBlazorWebAssembly,
HostHttpApi HostHttpApi
}; };
} }
if (packageType == HttpApi) if (packageType == HttpApi)
{ {
return new List<string>() return new List<string>()
{ {
HttpApi, HttpApi,
HostMvc, HostMvc,
@ -179,11 +179,11 @@ namespace Volo.Abp.Studio.Packages
HostBlazorWebAssembly, HostBlazorWebAssembly,
HostHttpApi HostHttpApi
}; };
} }
if (packageType == HttpApiClient) if (packageType == HttpApiClient)
{ {
return new List<string>() return new List<string>()
{ {
HttpApiClient, HttpApiClient,
HostMvc, HostMvc,
@ -191,54 +191,53 @@ namespace Volo.Abp.Studio.Packages
HostBlazorWebAssembly, HostBlazorWebAssembly,
HostHttpApi HostHttpApi
}; };
} }
if (packageType == Mvc) if (packageType == Mvc)
{ {
return new List<string>() return new List<string>()
{ {
Mvc, Mvc,
HostMvc HostMvc
}; };
} }
if (packageType == Blazor) if (packageType == Blazor)
{ {
return new List<string>() return new List<string>()
{ {
Blazor, Blazor,
BlazorServer, BlazorServer,
BlazorWebAssembly BlazorWebAssembly
}; };
} }
if (packageType == BlazorServer) if (packageType == BlazorServer)
{ {
return new List<string>() return new List<string>()
{ {
BlazorServer, BlazorServer,
HostBlazorServer HostBlazorServer
}; };
} }
if (packageType == BlazorWebAssembly) if (packageType == BlazorWebAssembly)
{ {
return new List<string>() return new List<string>()
{ {
BlazorWebAssembly, BlazorWebAssembly,
HostBlazorWebAssembly HostBlazorWebAssembly
}; };
} }
if (packageType == Test) if (packageType == Test)
{ {
return new List<string>() return new List<string>()
{ {
Test Test
}; };
}
return new List<string>();
} }
return new List<string>();
} }
} }

13
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/ReferenceType.cs

@ -1,8 +1,7 @@
namespace Volo.Abp.Studio.Package namespace Volo.Abp.Studio.Package;
public enum ReferenceType
{ {
public enum ReferenceType Project = 1,
{ Package = 2
Project = 1, }
Package = 2
}
}

171
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/DotnetSlnFileModifierService.cs

@ -7,120 +7,119 @@ using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Studio.Helpers; using Volo.Abp.Studio.Helpers;
namespace Volo.Abp.Studio.Solution namespace Volo.Abp.Studio.Solution;
public class DotnetSlnFileModifierService : IDotnetSlnFileModifierService, ITransientDependency
{ {
public class DotnetSlnFileModifierService : IDotnetSlnFileModifierService, ITransientDependency public IFileSystem FileSystem { get; }
public DotnetSlnFileModifierService(IFileSystem fileSystem)
{
FileSystem = fileSystem;
}
public async Task AddProjectAsync(string slnFilePath, string projectPath, string slnTargetFolder = "src")
{ {
public IFileSystem FileSystem { get; } var projectName = FileSystem.Path.GetFileName(projectPath).RemovePostFix(".csproj");
var folderId = await GetOrAddFolderIdAsync(slnFilePath, slnTargetFolder);
var slnFileLines = (await FileSystem.File.ReadAllTextAsync(slnFilePath))
.Split(Environment.NewLine).ToList();
public DotnetSlnFileModifierService(IFileSystem fileSystem) if (slnFileLines.Any(l => l.Contains($"\"{projectName}\"") && l.Contains("9A19103F-16F7-4668-BE54-9A1E7A4F7556")))
{ {
FileSystem = fileSystem; throw new AbpStudioException(AbpStudioErrorCodes.ProjectWithSameNameAlreadyExistInTheSolutionFile)
.WithData("Solution Path", slnFilePath)
.WithData("Project Name", projectName);
} }
public async Task AddProjectAsync(string slnFilePath, string projectPath, string slnTargetFolder = "src") var projectId = Guid.NewGuid().ToString();
{ var relativeProjectPath = PathHelper.GetRelativePath(slnFilePath, projectPath).Replace("/", "\\");
var projectName = FileSystem.Path.GetFileName(projectPath).RemovePostFix(".csproj"); var newProjectLine = "Project(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"" + projectName + "\"," +
var folderId = await GetOrAddFolderIdAsync(slnFilePath, slnTargetFolder); " \"" + relativeProjectPath + "\", \"{" + projectId + "}\""
var slnFileLines = (await FileSystem.File.ReadAllTextAsync(slnFilePath)) + Environment.NewLine + "EndProject";
.Split(Environment.NewLine).ToList();
if (slnFileLines.Any(l => l.Contains($"\"{projectName}\"") && l.Contains("9A19103F-16F7-4668-BE54-9A1E7A4F7556"))) slnFileLines.InsertAfter(l => l.Trim().Equals("EndProject"), newProjectLine);
{
throw new AbpStudioException(AbpStudioErrorCodes.ProjectWithSameNameAlreadyExistInTheSolutionFile)
.WithData("Solution Path", slnFilePath)
.WithData("Project Name", projectName);
}
var projectId = Guid.NewGuid().ToString(); var newPostSolutionLine =
var relativeProjectPath = PathHelper.GetRelativePath(slnFilePath, projectPath).Replace("/", "\\"); " {" + projectId + "}.Debug|Any CPU.ActiveCfg = Debug|Any CPU" + Environment.NewLine +
var newProjectLine = "Project(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"" + projectName + "\"," + " {" + projectId + "}.Debug|Any CPU.Build.0 = Debug|Any CPU" + Environment.NewLine +
" \"" + relativeProjectPath + "\", \"{" + projectId + "}\"" " {" + projectId + "}.Release|Any CPU.ActiveCfg = Release|Any CPU" + Environment.NewLine +
+ Environment.NewLine + "EndProject"; " {" + projectId + "}.Release|Any CPU.Build.0 = Release|Any CPU";
slnFileLines.InsertAfter(l => l.Trim().Equals("EndProject"), newProjectLine); if (!slnFileLines.Any(l => l.Contains("GlobalSection") && l.Contains("ProjectConfigurationPlatforms")))
{
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " GlobalSection(ProjectConfigurationPlatforms) = postSolution");
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " EndGlobalSection");
}
var newPostSolutionLine = slnFileLines.InsertAfter(l => l.Contains("GlobalSection") && l.Contains("ProjectConfigurationPlatforms"),
" {" + projectId + "}.Debug|Any CPU.ActiveCfg = Debug|Any CPU" + Environment.NewLine + newPostSolutionLine);
" {" + projectId + "}.Debug|Any CPU.Build.0 = Debug|Any CPU" + Environment.NewLine +
" {" + projectId + "}.Release|Any CPU.ActiveCfg = Release|Any CPU" + Environment.NewLine +
" {" + projectId + "}.Release|Any CPU.Build.0 = Release|Any CPU";
if (!slnFileLines.Any(l => l.Contains("GlobalSection") && l.Contains("ProjectConfigurationPlatforms"))) var newPreSolutionLine =
{ " {" + projectId + "} = {" + folderId + "}";
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " GlobalSection(ProjectConfigurationPlatforms) = postSolution");
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " EndGlobalSection");
}
slnFileLines.InsertAfter(l => l.Contains("GlobalSection") && l.Contains("ProjectConfigurationPlatforms"),
newPostSolutionLine);
var newPreSolutionLine = if (!slnFileLines.Any(l => l.Contains("GlobalSection") && l.Contains("NestedProjects")))
" {" + projectId + "} = {" + folderId + "}"; {
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " GlobalSection(NestedProjects) = preSolution");
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " EndGlobalSection");
}
slnFileLines.InsertAfter(l => l.Contains("GlobalSection") && l.Contains("NestedProjects"), newPreSolutionLine);
if (!slnFileLines.Any(l => l.Contains("GlobalSection") && l.Contains("NestedProjects"))) await FileSystem.File.WriteAllTextAsync(slnFilePath, string.Join(Environment.NewLine, slnFileLines));
{ }
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " GlobalSection(NestedProjects) = preSolution");
slnFileLines.InsertBefore(l => l.Trim().Equals("EndGlobal"), " EndGlobalSection");
}
slnFileLines.InsertAfter(l => l.Contains("GlobalSection") && l.Contains("NestedProjects"), newPreSolutionLine); private async Task<string> GetOrAddFolderIdAsync(string solutionFile, string folderName, string parentFolderId = null)
{
if (folderName.Contains("/") && parentFolderId == null)
{
var parents = folderName.Split("/").SkipLast(1).JoinAsString("/");
folderName = folderName.Split("/").Last();
await FileSystem.File.WriteAllTextAsync(slnFilePath, string.Join(Environment.NewLine, slnFileLines)); parentFolderId = await GetOrAddFolderIdAsync(solutionFile, parents);
} }
private async Task<string> GetOrAddFolderIdAsync(string solutionFile, string folderName, string parentFolderId = null) var file = await FileSystem.File.ReadAllTextAsync(solutionFile);
{ var lines = file.Split(Environment.NewLine).ToList();
if (folderName.Contains("/") && parentFolderId == null) string folderId;
{
var parents = folderName.Split("/").SkipLast(1).JoinAsString("/");
folderName = folderName.Split("/").Last();
parentFolderId = await GetOrAddFolderIdAsync(solutionFile, parents);
}
var file = await FileSystem.File.ReadAllTextAsync(solutionFile); var folderLineIndex = lines.FindIndex(l =>
var lines = file.Split(Environment.NewLine).ToList(); l.Contains("2150E333-8FDC-42A3-9474-1A3956D46DE8") && l.Contains("\"" + folderName + "\""));
string folderId;
var folderLineIndex = lines.FindIndex(l => if (folderLineIndex < 0)
l.Contains("2150E333-8FDC-42A3-9474-1A3956D46DE8") && l.Contains("\"" + folderName + "\"")); {
folderId = Guid.NewGuid().ToString();
var newFolderLine = "Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"" + folderName + "\", \"" +
folderName + "\", \"{" + folderId + "}\""
+ Environment.NewLine + "EndProject";
if (folderLineIndex < 0) if (lines.Any(l => l.Trim().Equals("EndProject")))
{ {
folderId = Guid.NewGuid().ToString(); lines.InsertAfter(l => l.Trim().Equals("EndProject"), newFolderLine);
var newFolderLine = "Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"" + folderName + "\", \"" +
folderName + "\", \"{" + folderId + "}\""
+ Environment.NewLine + "EndProject";
if (lines.Any(l => l.Trim().Equals("EndProject")))
{
lines.InsertAfter(l => l.Trim().Equals("EndProject"), newFolderLine);
}
else
{
lines.InsertAfter(l => l.StartsWith("Microsoft Visual Studio Solution File"), newFolderLine);
}
if (parentFolderId != null && lines.Any(l=>l.Contains("GlobalSection") && l.Contains("NestedProjects")))
{
var newPreSolutionLine =
" {" + folderId + "} = {" + parentFolderId + "}";
lines.InsertAfter(l => l.Contains("GlobalSection") && l.Contains("NestedProjects"),
newPreSolutionLine);
}
await FileSystem.File.WriteAllTextAsync(solutionFile, string.Join(Environment.NewLine, lines));
} }
else else
{ {
folderId = lines[folderLineIndex].Replace("\"", " ").Replace("{", " ").Replace("}", " ").TrimEnd() lines.InsertAfter(l => l.StartsWith("Microsoft Visual Studio Solution File"), newFolderLine);
.Split(" ").Last();
} }
return folderId; if (parentFolderId != null && lines.Any(l => l.Contains("GlobalSection") && l.Contains("NestedProjects")))
{
var newPreSolutionLine =
" {" + folderId + "} = {" + parentFolderId + "}";
lines.InsertAfter(l => l.Contains("GlobalSection") && l.Contains("NestedProjects"),
newPreSolutionLine);
}
await FileSystem.File.WriteAllTextAsync(solutionFile, string.Join(Environment.NewLine, lines));
} }
else
{
folderId = lines[folderLineIndex].Replace("\"", " ").Replace("{", " ").Replace("}", " ").TrimEnd()
.Split(" ").Last();
}
return folderId;
} }
} }

9
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/IDotnetSlnFileModifierService.cs

@ -1,9 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.Solution namespace Volo.Abp.Studio.Solution;
public interface IDotnetSlnFileModifierService
{ {
public interface IDotnetSlnFileModifierService Task AddProjectAsync(string slnFile, string projectPath, string slnTargetFolder = "src");
{
Task AddProjectAsync(string slnFile, string projectPath, string slnTargetFolder = "src");
}
} }

9
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/ISolutionFileModuleAdder.cs

@ -1,9 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.Solution namespace Volo.Abp.Studio.Solution;
public interface ISolutionFileModuleAdder
{ {
public interface ISolutionFileModuleAdder Task AddAsync(string TargetModule, string ModuleName);
{
Task AddAsync(string TargetModule, string ModuleName);
}
} }

51
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Solution/SolutionFileModuleAdder.cs

@ -4,39 +4,38 @@ using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Studio.Modules; using Volo.Abp.Studio.Modules;
namespace Volo.Abp.Studio.Solution namespace Volo.Abp.Studio.Solution;
public class SolutionFileModuleAdder : ISolutionFileModuleAdder, ITransientDependency
{ {
public class SolutionFileModuleAdder : ISolutionFileModuleAdder, ITransientDependency private readonly IDotnetSlnFileModifierService _dotnetSlnFileModifierService;
public SolutionFileModuleAdder(IDotnetSlnFileModifierService dotnetSlnFileModifierService)
{ {
private readonly IDotnetSlnFileModifierService _dotnetSlnFileModifierService; _dotnetSlnFileModifierService = dotnetSlnFileModifierService;
}
public SolutionFileModuleAdder(IDotnetSlnFileModifierService dotnetSlnFileModifierService) public async Task AddAsync(string TargetModule, string ModuleName)
{ {
_dotnetSlnFileModifierService = dotnetSlnFileModifierService; var targetFolder = Path.Combine(Path.GetDirectoryName(TargetModule), "modules", ModuleName); ;
} var slnFile = TargetModule.RemovePostFix(ModuleConsts.FileExtension) + ".sln";
var moduleSrcFolder = Path.Combine(targetFolder, "src");
var moduleTestFolder = Path.Combine(targetFolder, "test");
public async Task AddAsync(string TargetModule, string ModuleName) await AddProjectsUnderDirectoryToSolutionFile(slnFile, moduleSrcFolder, $"modules/{ModuleName}");
{ await AddProjectsUnderDirectoryToSolutionFile(slnFile, moduleTestFolder, $"test/{ModuleName}.Tests");
var targetFolder = Path.Combine(Path.GetDirectoryName(TargetModule), "modules", ModuleName);; }
var slnFile = TargetModule.RemovePostFix(ModuleConsts.FileExtension) + ".sln";
var moduleSrcFolder = Path.Combine(targetFolder, "src");
var moduleTestFolder = Path.Combine(targetFolder, "test");
await AddProjectsUnderDirectoryToSolutionFile(slnFile, moduleSrcFolder, $"modules/{ModuleName}"); private async Task AddProjectsUnderDirectoryToSolutionFile(
await AddProjectsUnderDirectoryToSolutionFile(slnFile, moduleTestFolder, $"test/{ModuleName}.Tests"); string slnFile,
} string directory,
string slnTargetFolder)
{
var projects = Directory.GetFiles(directory, "*.csproj", SearchOption.AllDirectories);
private async Task AddProjectsUnderDirectoryToSolutionFile( foreach (var project in projects)
string slnFile,
string directory,
string slnTargetFolder)
{ {
var projects = Directory.GetFiles(directory, "*.csproj", SearchOption.AllDirectories); await _dotnetSlnFileModifierService.AddProjectAsync(slnFile, project, slnTargetFolder);
foreach (var project in projects)
{
await _dotnetSlnFileModifierService.AddProjectAsync(slnFile, project, slnTargetFolder);
}
} }
} }
} }

63
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Xml/XmlFileManagerBase.cs

@ -6,46 +6,45 @@ using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using Volo.Abp.Threading; using Volo.Abp.Threading;
namespace Volo.Abp.Studio.Xml namespace Volo.Abp.Studio.Xml;
public abstract class XmlFileManagerBase
{ {
public abstract class XmlFileManagerBase public IFileSystem FileSystem { get; set; }
{
public IFileSystem FileSystem { get; set; }
public ICancellationTokenProvider CancellationTokenProvider { get; set; } public ICancellationTokenProvider CancellationTokenProvider { get; set; }
protected async Task<XmlDocument> GetXmlDocumentAsync(string filePath) protected async Task<XmlDocument> GetXmlDocumentAsync(string filePath)
{
try
{ {
try var doc = new XmlDocument() { PreserveWhitespace = true };
{ doc.Load(GenerateStreamFromString(await FileSystem.File.ReadAllTextAsync(filePath)));
var doc = new XmlDocument() { PreserveWhitespace = true }; return doc;
doc.Load(GenerateStreamFromString(await FileSystem.File.ReadAllTextAsync(filePath)));
return doc;
}
catch (Exception ex)
{
throw new AbpException($"Error while reading {filePath} as XML document.", innerException: ex);
}
} }
catch (Exception ex)
protected async Task SaveXmlDocumentAsync(string filePath, XmlDocument rootNode)
{ {
await SaveFileContentAsync(filePath, XDocument.Parse(rootNode.OuterXml).ToString()); throw new AbpException($"Error while reading {filePath} as XML document.", innerException: ex);
} }
}
protected async Task SaveFileContentAsync(string filePath, string content) protected async Task SaveXmlDocumentAsync(string filePath, XmlDocument rootNode)
{ {
await FileSystem.File.WriteAllTextAsync(filePath, content, CancellationTokenProvider.Token); await SaveFileContentAsync(filePath, XDocument.Parse(rootNode.OuterXml).ToString());
} }
private MemoryStream GenerateStreamFromString(string s) protected async Task SaveFileContentAsync(string filePath, string content)
{ {
var stream = new MemoryStream(); await FileSystem.File.WriteAllTextAsync(filePath, content, CancellationTokenProvider.Token);
var writer = new StreamWriter(stream); }
writer.Write(s);
writer.Flush(); private MemoryStream GenerateStreamFromString(string s)
stream.Position = 0; {
return stream; var stream = new MemoryStream();
} var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
} }
} }

13
studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/AbpStudioDomainSharedModule.cs

@ -1,13 +1,12 @@
using Volo.Abp.Cli; using Volo.Abp.Cli;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.Studio namespace Volo.Abp.Studio;
[DependsOn(
typeof(AbpCliCoreModule)
)]
public class AbpStudioDomainSharedModule : AbpModule
{ {
[DependsOn(
typeof(AbpCliCoreModule)
)]
public class AbpStudioDomainSharedModule : AbpModule
{
}
} }

59
studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/AbpStudioErrorCodes.cs

@ -1,32 +1,31 @@
namespace Volo.Abp.Studio namespace Volo.Abp.Studio;
public static class AbpStudioErrorCodes
{ {
public static class AbpStudioErrorCodes public const string SolutionAlreadyExists = "AbpStudio:SolutionAlreadyExists";
{ public const string ModuleAlreadyExistsInTheSolution = "AbpStudio:ModuleAlreadyExistsInTheSolution";
public const string SolutionAlreadyExists = "AbpStudio:SolutionAlreadyExists"; public const string ModuleFileAlreadyExists = "AbpStudio:ModuleFileAlreadyExists";
public const string ModuleAlreadyExistsInTheSolution = "AbpStudio:ModuleAlreadyExistsInTheSolution"; public const string IncorrectFileFormat = "AbpStudio:IncorrectFileFormat";
public const string ModuleFileAlreadyExists = "AbpStudio:ModuleFileAlreadyExists"; public const string ModuleNotFound = "AbpStudio:ModuleNotFound";
public const string IncorrectFileFormat = "AbpStudio:IncorrectFileFormat"; public const string SolutionNotFound = "AbpStudio:SolutionNotFound";
public const string ModuleNotFound = "AbpStudio:ModuleNotFound"; public const string ModuleNotSpecified = "AbpStudio:ModuleNotSpecified";
public const string SolutionNotFound = "AbpStudio:SolutionNotFound"; public const string SolutionNotSpecified = "AbpStudio:SolutionNotSpecified";
public const string ModuleNotSpecified = "AbpStudio:ModuleNotSpecified"; public const string ProjectAlreadyExistInTheModule = "AbpStudio:ProjectAlreadyExistInTheModule";
public const string SolutionNotSpecified = "AbpStudio:SolutionNotSpecified"; public const string IncorrectSolutionFileFormat = "AbpStudio:IncorrectSolutionFileFormat";
public const string ProjectAlreadyExistInTheModule = "AbpStudio:ProjectAlreadyExistInTheModule"; public const string FolderNotFound = "AbpStudio:FolderNotFound";
public const string IncorrectSolutionFileFormat = "AbpStudio:IncorrectSolutionFileFormat"; public const string ProjectWithSameNameAlreadyExistInTheSolutionFile = "AbpStudio:ProjectWithSameNameAlreadyExistInTheSolutionFile";
public const string FolderNotFound = "AbpStudio:FolderNotFound"; public const string UndefinedPackageTemplate = "AbpStudio:UndefinedPackageTemplate";
public const string ProjectWithSameNameAlreadyExistInTheSolutionFile = "AbpStudio:ProjectWithSameNameAlreadyExistInTheSolutionFile"; public const string PackageTemplateNotSpecified = "AbpStudio:PackageTemplateNotSpecified";
public const string UndefinedPackageTemplate = "AbpStudio:UndefinedPackageTemplate"; public const string PackageNameMustBeSpecified = "AbpStudio:PackageNameMustBeSpecified";
public const string PackageTemplateNotSpecified = "AbpStudio:PackageTemplateNotSpecified"; public const string FileAlreadyExists = "AbpStudio:FileAlreadyExists";
public const string PackageNameMustBeSpecified = "AbpStudio:PackageNameMustBeSpecified"; public const string PackageNotSpecified = "AbpStudio:PackageNotSpecified";
public const string FileAlreadyExists = "AbpStudio:FileAlreadyExists"; public const string DbmsMustBeSpecified = "AbpStudio:DbmsMustBeSpecified";
public const string PackageNotSpecified = "AbpStudio:PackageNotSpecified"; public const string UserNotLoggedIn = "AbpStudio:UserNotLoggedIn";
public const string DbmsMustBeSpecified = "AbpStudio:DbmsMustBeSpecified"; public const string PackageAlreadyExist = "AbpStudio:PackageAlreadyExist";
public const string UserNotLoggedIn = "AbpStudio:UserNotLoggedIn"; public const string AbpModuleFileNotFound = "AbpStudio:AbpModuleFileNotFound";
public const string PackageAlreadyExist = "AbpStudio:PackageAlreadyExist"; public const string DllNotFound = "AbpStudio:DllNotFound";
public const string AbpModuleFileNotFound = "AbpStudio:AbpModuleFileNotFound"; public const string PackageNotFound = "AbpStudio:PackageNotFound";
public const string DllNotFound = "AbpStudio:DllNotFound"; public const string FileNotFound = "AbpStudio:FileNotFound";
public const string PackageNotFound = "AbpStudio:PackageNotFound"; public const string IncorrectFolderName = "AbpStudio:IncorrectFolderName";
public const string FileNotFound = "AbpStudio:FileNotFound"; public const string ModuleAlreadyInstalled = "AbpStudio:ModuleAlreadyInstalled";
public const string IncorrectFolderName = "AbpStudio:IncorrectFolderName";
public const string ModuleAlreadyInstalled = "AbpStudio:ModuleAlreadyInstalled";
}
} }

27
studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/Modules/ModuleConsts.cs

@ -1,18 +1,17 @@
namespace Volo.Abp.Studio.Modules namespace Volo.Abp.Studio.Modules;
public static class ModuleConsts
{ {
public static class ModuleConsts public const string FileExtension = ".abpmdl.json";
{ public const string InstallerPackagePostfix = ".Installer";
public const string FileExtension = ".abpmdl.json"; public const string SourceCorePackagePostfix = ".SourceCode";
public const string InstallerPackagePostfix = ".Installer"; public const string Packages = "packages";
public const string SourceCorePackagePostfix = ".SourceCode";
public const string Packages = "packages";
public static class Layers //TODO: Moving to PackageTypes public static class Layers //TODO: Moving to PackageTypes
{ {
public const string Domain = "lib.domain"; public const string Domain = "lib.domain";
public const string DomainShared = "lib.domain.shared"; public const string DomainShared = "lib.domain.shared";
public const string Application = "lib.application"; public const string Application = "lib.application";
public const string ApplicationContracts = "lib.application.contracts"; public const string ApplicationContracts = "lib.application.contracts";
}
} }
} }

21
studio/src/Volo.Abp.Studio.Domain.Shared/Volo/Abp/Studio/Package/PackageReferenceCompatibility.cs

@ -1,13 +1,12 @@
namespace Volo.Abp.Studio.Packages.Referencing namespace Volo.Abp.Studio.Packages.Referencing;
public enum PackageReferenceCompatibility
{ {
public enum PackageReferenceCompatibility Unknown,
{ DDD_Compatible,
Unknown, Compatible,
DDD_Compatible, TestProject,
Compatible, IndirectlyReferenced,
TestProject, DirectlyReferenced,
IndirectlyReferenced, CircularReference
DirectlyReferenced,
CircularReference
}
} }

13
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/AbpStudioModuleInstallerAbstractionsModule.cs

@ -1,13 +1,12 @@
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Studio.Analyzing; using Volo.Abp.Studio.Analyzing;
namespace Volo.Abp.Studio namespace Volo.Abp.Studio;
[DependsOn(
typeof(AbpStudioAnalyzingAbstractionsModule)
)]
public class AbpStudioModuleInstallerAbstractionsModule : AbpModule
{ {
[DependsOn(
typeof(AbpStudioAnalyzingAbstractionsModule)
)]
public class AbpStudioModuleInstallerAbstractionsModule : AbpModule
{
}
} }

75
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Analyzing/AnalyzingOptions.cs

@ -1,45 +1,44 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Analyzing namespace Volo.Abp.Studio.Analyzing;
public class AnalyzingOptions
{ {
public class AnalyzingOptions public bool Force { get; set; } = false;
[CanBeNull]
public string AnalyzeConfigurationFile { get; set; }
[CanBeNull]
public string SettingNamePrefix { get; set; }
[CanBeNull]
public string FeatureNamePrefix { get; set; }
// Combines two options
// The second option has more priority
public static AnalyzingOptions Combine([CanBeNull] AnalyzingOptions first, [CanBeNull] AnalyzingOptions second)
{ {
public bool Force { get; set; } = false; if (second == null && first == null)
[CanBeNull]
public string AnalyzeConfigurationFile { get; set; }
[CanBeNull]
public string SettingNamePrefix { get; set; }
[CanBeNull]
public string FeatureNamePrefix { get; set; }
// Combines two options
// The second option has more priority
public static AnalyzingOptions Combine([CanBeNull] AnalyzingOptions first, [CanBeNull] AnalyzingOptions second)
{ {
if (second == null && first == null) return new AnalyzingOptions();
{
return new AnalyzingOptions();
}
if (second == null)
{
return first;
}
if (first == null)
{
return second;
}
return new AnalyzingOptions
{
AnalyzeConfigurationFile = second.AnalyzeConfigurationFile ?? first.AnalyzeConfigurationFile,
SettingNamePrefix = second.SettingNamePrefix ?? first.SettingNamePrefix,
FeatureNamePrefix = second.FeatureNamePrefix ?? first.FeatureNamePrefix
};
} }
if (second == null)
{
return first;
}
if (first == null)
{
return second;
}
return new AnalyzingOptions
{
AnalyzeConfigurationFile = second.AnalyzeConfigurationFile ?? first.AnalyzeConfigurationFile,
SettingNamePrefix = second.SettingNamePrefix ?? first.SettingNamePrefix,
FeatureNamePrefix = second.FeatureNamePrefix ?? first.FeatureNamePrefix
};
} }
} }

21
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/EfCoreConfigurationMethodDeclaration.cs

@ -1,18 +1,17 @@
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.ModuleInstalling namespace Volo.Abp.Studio.ModuleInstalling;
{
public class EfCoreConfigurationMethodDeclaration
{
public string Namespace { get; }
public string MethodName { get; } public class EfCoreConfigurationMethodDeclaration
{
public string Namespace { get; }
public EfCoreConfigurationMethodDeclaration([NotNull] string nameSpace, [NotNull] string methodName) public string MethodName { get; }
{
Namespace = Check.NotNullOrEmpty(nameSpace, nameof(nameSpace));
MethodName = Check.NotNullOrEmpty(methodName, nameof(methodName));
}
public EfCoreConfigurationMethodDeclaration([NotNull] string nameSpace, [NotNull] string methodName)
{
Namespace = Check.NotNullOrEmpty(nameSpace, nameof(nameSpace));
MethodName = Check.NotNullOrEmpty(methodName, nameof(methodName));
} }
} }

9
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/IModuleInstallingPipelineBuilder.cs

@ -1,9 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.ModuleInstalling namespace Volo.Abp.Studio.ModuleInstalling;
public interface IModuleInstallingPipelineBuilder
{ {
public interface IModuleInstallingPipelineBuilder Task<ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context);
{
Task<ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context);
}
} }

113
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingContext.cs

@ -4,86 +4,85 @@ using System.IO;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Studio.Packages; using Volo.Abp.Studio.Packages;
namespace Volo.Abp.Studio.ModuleInstalling namespace Volo.Abp.Studio.ModuleInstalling;
public class ModuleInstallingContext
{ {
public class ModuleInstallingContext public string ModuleName { get; set; }
{
public string ModuleName { get; set; }
public string TargetModule { get; set; } public string TargetModule { get; set; }
public bool WithSourceCode { get; set; } public bool WithSourceCode { get; set; }
public bool AddToSolutionFile { get; set; } public bool AddToSolutionFile { get; set; }
public string Version { get; set; } public string Version { get; set; }
public List<EfCoreConfigurationMethodDeclaration> EfCoreConfigurationMethodDeclarations { get; } public List<EfCoreConfigurationMethodDeclaration> EfCoreConfigurationMethodDeclarations { get; }
public List<PackageInfo> TargetModulePackages { get; protected set; } public List<PackageInfo> TargetModulePackages { get; protected set; }
public List<PackageInfoWithAnalyze> ReferenceModulePackages { get; protected set; } public List<PackageInfoWithAnalyze> ReferenceModulePackages { get; protected set; }
public Dictionary<string,string> Options { get; } public Dictionary<string, string> Options { get; }
public IServiceProvider ServiceProvider { get; } public IServiceProvider ServiceProvider { get; }
public ModuleInstallingContext( public ModuleInstallingContext(
string moduleName, string moduleName,
string targetModule, string targetModule,
bool withSourceCode, bool withSourceCode,
bool addToSolutionFile, bool addToSolutionFile,
string version, string version,
Dictionary<string,string> options, Dictionary<string, string> options,
IServiceProvider serviceProvider) IServiceProvider serviceProvider)
{ {
ModuleName = moduleName; ModuleName = moduleName;
TargetModule = targetModule; TargetModule = targetModule;
WithSourceCode = withSourceCode; WithSourceCode = withSourceCode;
AddToSolutionFile = addToSolutionFile; AddToSolutionFile = addToSolutionFile;
Version = version; Version = version;
Options = options; Options = options;
TargetModulePackages = new List<PackageInfo>(); TargetModulePackages = new List<PackageInfo>();
ReferenceModulePackages = new List<PackageInfoWithAnalyze>(); ReferenceModulePackages = new List<PackageInfoWithAnalyze>();
EfCoreConfigurationMethodDeclarations = new List<EfCoreConfigurationMethodDeclaration>(); EfCoreConfigurationMethodDeclarations = new List<EfCoreConfigurationMethodDeclaration>();
ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider)); ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider));
} }
public void AddEfCoreConfigurationMethodDeclaration(params EfCoreConfigurationMethodDeclaration[] methodNames) public void AddEfCoreConfigurationMethodDeclaration(params EfCoreConfigurationMethodDeclaration[] methodNames)
{
foreach (var methodName in methodNames)
{ {
foreach (var methodName in methodNames) Check.NotNull(methodName, nameof(methodName));
{
Check.NotNull(methodName, nameof(methodName));
EfCoreConfigurationMethodDeclarations.Add(methodName); EfCoreConfigurationMethodDeclarations.Add(methodName);
}
} }
}
public void SetReferenceModulePackages([NotNull] List<PackageInfoWithAnalyze> referenceModulePackages) public void SetReferenceModulePackages([NotNull] List<PackageInfoWithAnalyze> referenceModulePackages)
{ {
Check.NotNull(referenceModulePackages, nameof(referenceModulePackages)); Check.NotNull(referenceModulePackages, nameof(referenceModulePackages));
ReferenceModulePackages = referenceModulePackages; ReferenceModulePackages = referenceModulePackages;
} }
public void SetTargetModulePackages([NotNull] List<PackageInfo> targetModulePackages) public void SetTargetModulePackages([NotNull] List<PackageInfo> targetModulePackages)
{ {
Check.NotNull(targetModulePackages, nameof(targetModulePackages)); Check.NotNull(targetModulePackages, nameof(targetModulePackages));
TargetModulePackages = targetModulePackages; TargetModulePackages = targetModulePackages;
} }
public string GetTargetSourceCodeFolder() public string GetTargetSourceCodeFolder()
{ {
return CalculateTargetSourceCodeFolder(TargetModule, ModuleName); return CalculateTargetSourceCodeFolder(TargetModule, ModuleName);
} }
public static string CalculateTargetSourceCodeFolder(string targetModule, string moduleName) public static string CalculateTargetSourceCodeFolder(string targetModule, string moduleName)
{ {
return Path.Combine(Path.GetDirectoryName(targetModule), "modules", moduleName); return Path.Combine(Path.GetDirectoryName(targetModule), "modules", moduleName);
}
} }
} }

69
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipeline.cs

@ -3,51 +3,50 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.ModuleInstalling namespace Volo.Abp.Studio.ModuleInstalling;
public class ModuleInstallingPipeline
{ {
public class ModuleInstallingPipeline public ModuleInstallingContext Context { get; }
{
public ModuleInstallingContext Context { get; }
public List<ModuleInstallingPipelineStep> Steps { get; } public List<ModuleInstallingPipelineStep> Steps { get; }
public ModuleInstallingPipeline(ModuleInstallingContext context) public ModuleInstallingPipeline(ModuleInstallingContext context)
{ {
Context = context; Context = context;
Steps = new List<ModuleInstallingPipelineStep>(); Steps = new List<ModuleInstallingPipelineStep>();
} }
public async Task ExecuteAsync() public async Task ExecuteAsync()
{
foreach (var step in Steps)
{ {
foreach (var step in Steps) await step.ExecuteAsync(Context);
{
await step.ExecuteAsync(Context);
}
} }
}
public void Add(ModuleInstallingPipelineStep step) public void Add(ModuleInstallingPipelineStep step)
{ {
Steps.Add(step); Steps.Add(step);
} }
public void Remove(Type stepType) public void Remove(Type stepType)
{ {
Steps.RemoveAll(step => step.GetType() == stepType); Steps.RemoveAll(step => step.GetType() == stepType);
} }
public void Replace(Type stepType, ModuleInstallingPipelineStep step) public void Replace(Type stepType, ModuleInstallingPipelineStep step)
{ {
Steps.ReplaceOne(step => step.GetType() == stepType , step); Steps.ReplaceOne(step => step.GetType() == stepType, step);
} }
public void InsertAfter(Type stepType, ModuleInstallingPipelineStep step) public void InsertAfter(Type stepType, ModuleInstallingPipelineStep step)
{ {
Steps.InsertAfter(step => step.GetType() == stepType , step); Steps.InsertAfter(step => step.GetType() == stepType, step);
} }
public void InsertBefore(Type stepType, ModuleInstallingPipelineStep step) public void InsertBefore(Type stepType, ModuleInstallingPipelineStep step)
{ {
Steps.InsertBefore(step => step.GetType() == stepType , step); Steps.InsertBefore(step => step.GetType() == stepType, step);
}
} }
} }

9
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineStep.cs

@ -1,9 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.ModuleInstalling namespace Volo.Abp.Studio.ModuleInstalling;
public abstract class ModuleInstallingPipelineStep
{ {
public abstract class ModuleInstallingPipelineStep public abstract Task ExecuteAsync(ModuleInstallingContext context);
{
public abstract Task ExecuteAsync(ModuleInstallingContext context);
}
} }

9
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/Options/IModuleInstallingOptionProvider.cs

@ -1,10 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Volo.Abp.Studio.ModuleInstalling.Options namespace Volo.Abp.Studio.ModuleInstalling.Options;
public interface IModuleInstallingOptionProvider
{ {
public interface IModuleInstallingOptionProvider Task<List<ModuleInstallingOption>> GetAsync();
{
Task<List<ModuleInstallingOption>> GetAsync();
}
} }

37
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/Options/ModuleInstallingOption.cs

@ -1,28 +1,27 @@
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.ModuleInstalling.Options namespace Volo.Abp.Studio.ModuleInstalling.Options;
public class ModuleInstallingOption
{ {
public class ModuleInstallingOption public string Name { get; set; }
{
public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public ModuleInstallingOptionType Type { get; set; } public ModuleInstallingOptionType Type { get; set; }
public Dictionary<string, string> Values { get; set; } public Dictionary<string, string> Values { get; set; }
public ModuleInstallingOption( public ModuleInstallingOption(
[NotNull] string name, [NotNull] string name,
[NotNull] string description, [NotNull] string description,
[NotNull] ModuleInstallingOptionType type, [NotNull] ModuleInstallingOptionType type,
[CanBeNull] Dictionary<string, string> values = null) [CanBeNull] Dictionary<string, string> values = null)
{ {
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); Name = Check.NotNullOrWhiteSpace(name, nameof(name));
Description = Check.NotNullOrWhiteSpace(description, nameof(description)); Description = Check.NotNullOrWhiteSpace(description, nameof(description));
Type = type; Type = type;
Values = values ?? new Dictionary<string, string>(); Values = values ?? new Dictionary<string, string>();
}
} }
} }

17
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/Options/ModuleInstallingOptionType.cs

@ -1,10 +1,9 @@
namespace Volo.Abp.Studio.ModuleInstalling.Options namespace Volo.Abp.Studio.ModuleInstalling.Options;
public enum ModuleInstallingOptionType
{ {
public enum ModuleInstallingOptionType NotSpecified,
{ Checkbox,
NotSpecified, FreeText,
Checkbox, ComboBox
FreeText, }
ComboBox
}
}

11
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageConsts.cs

@ -1,9 +1,8 @@
namespace Volo.Abp.Studio.Packages namespace Volo.Abp.Studio.Packages;
public static class PackageConsts
{ {
public static class PackageConsts public const string FileExtension = ".abppkg.json";
{
public const string FileExtension = ".abppkg.json";
public const string RoleProperty = "role"; public const string RoleProperty = "role";
}
} }

17
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageHelper.cs

@ -2,17 +2,16 @@
using System.IO; using System.IO;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Volo.Abp.Studio.Packages namespace Volo.Abp.Studio.Packages;
public static class PackageHelper
{ {
public static class PackageHelper public static string GetNameFromPath([NotNull] string path)
{ {
public static string GetNameFromPath([NotNull] string path) Check.NotNullOrWhiteSpace(path, nameof(path));
{
Check.NotNullOrWhiteSpace(path, nameof(path));
return Path return Path
.GetFileName(path) .GetFileName(path)
.RemovePostFix(StringComparison.OrdinalIgnoreCase, PackageConsts.FileExtension); .RemovePostFix(StringComparison.OrdinalIgnoreCase, PackageConsts.FileExtension);
}
} }
} }

41
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageInfo.cs

@ -1,27 +1,26 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Studio.Analyzing; using Volo.Abp.Studio.Analyzing;
namespace Volo.Abp.Studio.Packages namespace Volo.Abp.Studio.Packages;
public class PackageInfo
{ {
public class PackageInfo [NotNull]
{ public string Path { get; }
[NotNull]
public string Path { get; } [NotNull]
public string Name { get; }
[NotNull]
public string Name { get; }
[CanBeNull]
public string Role { get; }
[CanBeNull]
public AnalyzingOptions AnalyzingOptions { get; set; }
public PackageInfo([NotNull] string path, [CanBeNull] string role) [CanBeNull]
{ public string Role { get; }
Path = Check.NotNullOrWhiteSpace(path, nameof(path));
Name = PackageHelper.GetNameFromPath(path); [CanBeNull]
Role = role; public AnalyzingOptions AnalyzingOptions { get; set; }
}
public PackageInfo([NotNull] string path, [CanBeNull] string role)
{
Path = Check.NotNullOrWhiteSpace(path, nameof(path));
Name = PackageHelper.GetNameFromPath(path);
Role = role;
} }
} }

35
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/Package/PackageInfoWithAnalyze.cs

@ -1,28 +1,27 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.Studio.Analyzing.Models; using Volo.Abp.Studio.Analyzing.Models;
namespace Volo.Abp.Studio.Packages namespace Volo.Abp.Studio.Packages;
public class PackageInfoWithAnalyze
{ {
public class PackageInfoWithAnalyze [NotNull]
{ public string Path { get; }
[NotNull]
public string Path { get; }
[NotNull] [NotNull]
public string Name { get; } public string Name { get; }
[CanBeNull] [CanBeNull]
public string Role { get; } public string Role { get; }
[NotNull] [NotNull]
public PackageModel Analyze { get; } public PackageModel Analyze { get; }
public PackageInfoWithAnalyze([NotNull] string path, [CanBeNull] string role, [NotNull] PackageModel analyze) public PackageInfoWithAnalyze([NotNull] string path, [CanBeNull] string role, [NotNull] PackageModel analyze)
{ {
Path = Check.NotNullOrWhiteSpace(path, nameof(path)); Path = Check.NotNullOrWhiteSpace(path, nameof(path));
Name = PackageHelper.GetNameFromPath(path); Name = PackageHelper.GetNameFromPath(path);
Role = role; Role = role;
Analyze = Check.NotNull(analyze, nameof(analyze)); Analyze = Check.NotNull(analyze, nameof(analyze));
}
} }
} }

17
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/AbpStudioModuleInstallerModule.cs

@ -1,16 +1,15 @@
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace Volo.Abp.Studio namespace Volo.Abp.Studio;
[DependsOn(
typeof(AbpStudioDomainCommonServicesModule),
typeof(AbpStudioModuleInstallerAbstractionsModule)
)]
public class AbpStudioModuleInstallerModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpStudioDomainCommonServicesModule),
typeof(AbpStudioModuleInstallerAbstractionsModule)
)]
public class AbpStudioModuleInstallerModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context)
{
}
} }
} }

35
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs

@ -1,32 +1,31 @@
using System.Linq; using System.Linq;
using Volo.Abp.Studio.ModuleInstalling.Steps; using Volo.Abp.Studio.ModuleInstalling.Steps;
namespace Volo.Abp.Studio.ModuleInstalling namespace Volo.Abp.Studio.ModuleInstalling;
public abstract class ModuleInstallingPipelineBuilderBase
{ {
public abstract class ModuleInstallingPipelineBuilderBase protected ModuleInstallingPipeline GetBasePipeline(ModuleInstallingContext context)
{ {
protected ModuleInstallingPipeline GetBasePipeline(ModuleInstallingContext context) var pipeline = new ModuleInstallingPipeline(context);
if (context.WithSourceCode)
{ {
var pipeline = new ModuleInstallingPipeline(context); pipeline.Add(new SourceCodeDownloadStep());
if (context.WithSourceCode) if (context.AddToSolutionFile)
{ {
pipeline.Add(new SourceCodeDownloadStep()); pipeline.Add(new AddToSolutionFileStep());
if (context.AddToSolutionFile)
{
pipeline.Add(new AddToSolutionFileStep());
}
} }
}
pipeline.Add(new PackageReferencingStep()); pipeline.Add(new PackageReferencingStep());
if (context.EfCoreConfigurationMethodDeclarations.Any()) if (context.EfCoreConfigurationMethodDeclarations.Any())
{ {
pipeline.Add(new AddEfCoreConfigurationMethodStep()); pipeline.Add(new AddEfCoreConfigurationMethodStep());
}
return pipeline;
} }
return pipeline;
} }
} }

41
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs

@ -9,35 +9,34 @@ using Volo.Abp.Studio.Packages;
using Volo.Abp.Studio.Packages.Modifying; using Volo.Abp.Studio.Packages.Modifying;
using Volo.Abp.Studio.Analyzing.Models.Module; using Volo.Abp.Studio.Analyzing.Models.Module;
namespace Volo.Abp.Studio.ModuleInstalling.Steps namespace Volo.Abp.Studio.ModuleInstalling.Steps;
public class AddEfCoreConfigurationMethodStep : ModuleInstallingPipelineStep
{ {
public class AddEfCoreConfigurationMethodStep : ModuleInstallingPipelineStep public override async Task ExecuteAsync(ModuleInstallingContext context)
{ {
public override async Task ExecuteAsync(ModuleInstallingContext context) var efCoreProject = context.TargetModulePackages.FirstOrDefault(p => p.Role == PackageTypes.EntityFrameworkCore);
{
var efCoreProject = context.TargetModulePackages.FirstOrDefault(p => p.Role == PackageTypes.EntityFrameworkCore);
if (efCoreProject == null) if (efCoreProject == null)
{ {
return; return;
} }
var efCoreProjectCsprojPath = efCoreProject.Path.RemovePostFix(PackageConsts.FileExtension) + ".csproj"; var efCoreProjectCsprojPath = efCoreProject.Path.RemovePostFix(PackageConsts.FileExtension) + ".csproj";
var _derivedClassFinder = context.ServiceProvider.GetRequiredService<DerivedClassFinder>(); var _derivedClassFinder = context.ServiceProvider.GetRequiredService<DerivedClassFinder>();
var _dbContextFileBuilderConfigureAdder = context.ServiceProvider.GetRequiredService<DbContextFileBuilderConfigureAdder>(); var _dbContextFileBuilderConfigureAdder = context.ServiceProvider.GetRequiredService<DbContextFileBuilderConfigureAdder>();
var dbContextFile = _derivedClassFinder.Find(efCoreProjectCsprojPath, "AbpDbContext").FirstOrDefault(); var dbContextFile = _derivedClassFinder.Find(efCoreProjectCsprojPath, "AbpDbContext").FirstOrDefault();
if (dbContextFile == null) if (dbContextFile == null)
{ {
return; return;
} }
foreach (var declaration in context.EfCoreConfigurationMethodDeclarations) foreach (var declaration in context.EfCoreConfigurationMethodDeclarations)
{ {
_dbContextFileBuilderConfigureAdder.Add(dbContextFile, declaration.Namespace + ":" + declaration.MethodName); _dbContextFileBuilderConfigureAdder.Add(dbContextFile, declaration.Namespace + ":" + declaration.MethodName);
}
} }
} }
} }

13
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddToSolutionFileStep.cs

@ -2,15 +2,14 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Studio.Solution; using Volo.Abp.Studio.Solution;
namespace Volo.Abp.Studio.ModuleInstalling.Steps namespace Volo.Abp.Studio.ModuleInstalling.Steps;
public class AddToSolutionFileStep : ModuleInstallingPipelineStep
{ {
public class AddToSolutionFileStep : ModuleInstallingPipelineStep public override async Task ExecuteAsync(ModuleInstallingContext context)
{ {
public override async Task ExecuteAsync(ModuleInstallingContext context) var _solutionFileModuleAdder = context.ServiceProvider.GetRequiredService<ISolutionFileModuleAdder>();
{
var _solutionFileModuleAdder = context.ServiceProvider.GetRequiredService<ISolutionFileModuleAdder>();
await _solutionFileModuleAdder.AddAsync(context.TargetModule, context.ModuleName); await _solutionFileModuleAdder.AddAsync(context.TargetModule, context.ModuleName);
}
} }
} }

131
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/PackageReferencingStep.cs

@ -8,95 +8,94 @@ using Volo.Abp.Studio.Packages;
using Volo.Abp.Studio.Packages.Modifying; using Volo.Abp.Studio.Packages.Modifying;
using Volo.Abp.Studio.Analyzing.Models.Module; using Volo.Abp.Studio.Analyzing.Models.Module;
namespace Volo.Abp.Studio.ModuleInstalling.Steps namespace Volo.Abp.Studio.ModuleInstalling.Steps;
public class PackageReferencingStep : ModuleInstallingPipelineStep
{ {
public class PackageReferencingStep : ModuleInstallingPipelineStep public override async Task ExecuteAsync(ModuleInstallingContext context)
{ {
public override async Task ExecuteAsync(ModuleInstallingContext context) var _abpModuleFileManager = context.ServiceProvider.GetRequiredService<IAbpModuleFileManager>();
foreach (var referencePackage in context.ReferenceModulePackages)
{ {
var _abpModuleFileManager = context.ServiceProvider.GetRequiredService<IAbpModuleFileManager>(); var targetPackages = GetTargetPackages(context.TargetModulePackages, referencePackage);
foreach (var referencePackage in context.ReferenceModulePackages) foreach (var targetPackage in targetPackages)
{ {
var targetPackages = GetTargetPackages(context.TargetModulePackages, referencePackage); await AddReferenceAsync(context, targetPackage, referencePackage);
foreach (var targetPackage in targetPackages) var targetAbpModulePath = FindAbpModuleFile(targetPackage.Path);
{
await AddReferenceAsync(context, targetPackage, referencePackage);
var targetAbpModulePath = FindAbpModuleFile(targetPackage.Path); await _abpModuleFileManager.AddDependency(targetAbpModulePath, FindAbpModuleName(referencePackage));
await _abpModuleFileManager.AddDependency(targetAbpModulePath, FindAbpModuleName(referencePackage));
}
} }
} }
}
private async Task AddReferenceAsync( private async Task AddReferenceAsync(
ModuleInstallingContext context, ModuleInstallingContext context,
PackageInfo targetPackage, PackageInfo targetPackage,
PackageInfoWithAnalyze referencePackage) PackageInfoWithAnalyze referencePackage)
{
var _csprojFileManager = context.ServiceProvider.GetRequiredService<ICsprojFileManager>();
var csprojFilePath = targetPackage.Path.RemovePostFix(PackageConsts.FileExtension) + ".csproj";
if (context.WithSourceCode)
{ {
var _csprojFileManager = context.ServiceProvider.GetRequiredService<ICsprojFileManager>(); var referenceProjectPath = Directory.GetFiles(context.GetTargetSourceCodeFolder(),
var csprojFilePath = targetPackage.Path.RemovePostFix(PackageConsts.FileExtension) + ".csproj"; $"*{referencePackage.Name}.csproj",
SearchOption.AllDirectories).FirstOrDefault();
if (context.WithSourceCode) if (referenceProjectPath == null)
{
var referenceProjectPath = Directory.GetFiles(context.GetTargetSourceCodeFolder(),
$"*{referencePackage.Name}.csproj",
SearchOption.AllDirectories).FirstOrDefault();
if (referenceProjectPath == null)
{
return;
}
await _csprojFileManager.AddProjectReferenceAsync(
csprojFilePath,
referenceProjectPath);
}
else
{ {
await _csprojFileManager.AddPackageReferenceAsync( return;
csprojFilePath,
referencePackage.Name,
context.Version);
} }
}
private string FindAbpModuleFile(string targetPackagePath) await _csprojFileManager.AddProjectReferenceAsync(
csprojFilePath,
referenceProjectPath);
}
else
{ {
return Directory.GetFiles(Path.GetDirectoryName(targetPackagePath), "*Module.cs", await _csprojFileManager.AddPackageReferenceAsync(
SearchOption.AllDirectories) csprojFilePath,
.FirstOrDefault(); referencePackage.Name,
context.Version);
} }
}
private string FindAbpModuleName(PackageInfoWithAnalyze package) private string FindAbpModuleFile(string targetPackagePath)
{ {
var abpModuleModel = package.Analyze.Contents.Where(y => return Directory.GetFiles(Path.GetDirectoryName(targetPackagePath), "*Module.cs",
y.ContentType == AbpModuleModel.ContentTypeName SearchOption.AllDirectories)
).Cast<AbpModuleModel>().First(); .FirstOrDefault();
}
return abpModuleModel.Namespace + "." + abpModuleModel.Name; private string FindAbpModuleName(PackageInfoWithAnalyze package)
} {
var abpModuleModel = package.Analyze.Contents.Where(y =>
y.ContentType == AbpModuleModel.ContentTypeName
).Cast<AbpModuleModel>().First();
private List<PackageInfo> GetTargetPackages(List<PackageInfo> targetModulePackages, return abpModuleModel.Namespace + "." + abpModuleModel.Name;
PackageInfoWithAnalyze referencePackage) }
{
if (PackageTypes.IsHostProject(referencePackage.Role))
{
return new List<PackageInfo>();
}
if (PackageTypes.IsUiProject(referencePackage.Role)) private List<PackageInfo> GetTargetPackages(List<PackageInfo> targetModulePackages,
{ PackageInfoWithAnalyze referencePackage)
var useHostBlazorServerForMvcPackages = targetModulePackages.All(p => p.Role != PackageTypes.HostMvc); {
var targetHostType = if (PackageTypes.IsHostProject(referencePackage.Role))
PackageTypes.GetHostTypeOfUi(referencePackage.Role, useHostBlazorServerForMvcPackages); {
return new List<PackageInfo>();
}
return targetModulePackages.Where(p => p.Role == targetHostType).ToList(); if (PackageTypes.IsUiProject(referencePackage.Role))
} {
var useHostBlazorServerForMvcPackages = targetModulePackages.All(p => p.Role != PackageTypes.HostMvc);
var targetHostType =
PackageTypes.GetHostTypeOfUi(referencePackage.Role, useHostBlazorServerForMvcPackages);
return targetModulePackages.Where(p => p.Role == referencePackage.Role).ToList(); return targetModulePackages.Where(p => p.Role == targetHostType).ToList();
} }
return targetModulePackages.Where(p => p.Role == referencePackage.Role).ToList();
} }
} }

41
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/SourceCodeDownloadStep.cs

@ -6,34 +6,33 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Cli.ProjectBuilding; using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.Studio.Nuget; using Volo.Abp.Studio.Nuget;
namespace Volo.Abp.Studio.ModuleInstalling.Steps namespace Volo.Abp.Studio.ModuleInstalling.Steps;
public class SourceCodeDownloadStep : ModuleInstallingPipelineStep
{ {
public class SourceCodeDownloadStep : ModuleInstallingPipelineStep public override async Task ExecuteAsync(ModuleInstallingContext context)
{ {
public override async Task ExecuteAsync(ModuleInstallingContext context) var _nugetSourceCodeStoreManager = context.ServiceProvider.GetRequiredService<INugetSourceCodeStore>();
{
var _nugetSourceCodeStoreManager = context.ServiceProvider.GetRequiredService<INugetSourceCodeStore>();
var zipFilePath = await _nugetSourceCodeStoreManager.GetCachedSourceCodeFilePathAsync( var zipFilePath = await _nugetSourceCodeStoreManager.GetCachedSourceCodeFilePathAsync(
context.ModuleName, context.ModuleName,
SourceCodeTypes.Module, SourceCodeTypes.Module,
context.Version); context.Version);
if (zipFilePath == null) if (zipFilePath == null)
{ {
throw new AbpStudioException(message: $"Source code not found for {context.ModuleName} (v{context.Version})"); throw new AbpStudioException(message: $"Source code not found for {context.ModuleName} (v{context.Version})");
} }
var targetFolder = context.GetTargetSourceCodeFolder(); var targetFolder = context.GetTargetSourceCodeFolder();
if (Directory.Exists(targetFolder)) if (Directory.Exists(targetFolder))
{ {
return; return;
} }
Directory.CreateDirectory(targetFolder); Directory.CreateDirectory(targetFolder);
ZipFile.ExtractToDirectory(zipFilePath, targetFolder); ZipFile.ExtractToDirectory(zipFilePath, targetFolder);
}
} }
} }

Loading…
Cancel
Save