From 317a72898a819a5c23e0356684e9fb0e96910110 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Fri, 15 Jul 2022 12:48:15 +0300 Subject: [PATCH 1/2] refactoring --- common/ASC.Resource.Manager/GlobalUsings.cs | 4 +- common/ASC.Resource.Manager/JsonManager.cs | 26 ---------- common/ASC.Resource.Manager/ResourceData.cs | 31 +----------- .../AutoMigrationCreator.csproj | 7 +-- .../AutoMigrationCreator.sln | 31 ++++++++++++ .../Core/AssemblyContextFinder.cs | 5 -- .../Core/ContextFinder.cs | 6 --- .../Core/MigrationCreator.cs | 7 --- .../Core/MigrationGenerator.cs | 12 ----- .../Core/ModelDifferenceChecker.cs | 9 ---- .../Core/ProjectInfoContextFinder.cs | 5 -- .../AutoMigrationCreator/Core/Solution.cs | 7 --- .../AutoMigrationCreator/GlobalUsings.cs | 49 +++++++++++++++++++ common/Tools/AutoMigrationCreator/Program.cs | 2 - .../AutoMigrationCreator/Utils/ArgsParser.cs | 2 - .../Utils/DbContextActivator.cs | 5 -- .../Utils/EFCoreDesignTimeServices.cs | 8 --- 17 files changed, 87 insertions(+), 129 deletions(-) create mode 100644 common/Tools/AutoMigrationCreator/AutoMigrationCreator.sln create mode 100644 common/Tools/AutoMigrationCreator/GlobalUsings.cs diff --git a/common/ASC.Resource.Manager/GlobalUsings.cs b/common/ASC.Resource.Manager/GlobalUsings.cs index e0a952f1d9..470e071ec9 100644 --- a/common/ASC.Resource.Manager/GlobalUsings.cs +++ b/common/ASC.Resource.Manager/GlobalUsings.cs @@ -46,8 +46,8 @@ global using System.Xml.Linq; global using ASC.Common; global using ASC.Common.Utils; global using ASC.Core.Common.EF; -global using ASC.Core.Common.EF.Context; -global using ASC.Core.Common.EF.Model.Resource; +global using ASC.Resource.Manager.EF.Context; +global using ASC.Resource.Manager.EF.Model; global using Autofac; diff --git a/common/ASC.Resource.Manager/JsonManager.cs b/common/ASC.Resource.Manager/JsonManager.cs index ad30014e45..6b2a22014b 100644 --- a/common/ASC.Resource.Manager/JsonManager.cs +++ b/common/ASC.Resource.Manager/JsonManager.cs @@ -24,32 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -/* - * - * (c) Copyright Ascensio System Limited 2010-2018 - * - * This program is freeware. You can redistribute it and/or modify it under the terms of the GNU - * General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html). - * In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that - * Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. - * - * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html - * - * You can contact Ascensio System SIA by email at sales@onlyoffice.com - * - * The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display - * Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3. - * - * Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains - * relevant author attributions when distributing the software. If the display of the logo in its graphic - * form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE" - * in every copy of the program you distribute. - * Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks. - * -*/ - - namespace ASC.Resource.Manager; public static class JsonManager diff --git a/common/ASC.Resource.Manager/ResourceData.cs b/common/ASC.Resource.Manager/ResourceData.cs index 1e133a1e5b..7933defff1 100644 --- a/common/ASC.Resource.Manager/ResourceData.cs +++ b/common/ASC.Resource.Manager/ResourceData.cs @@ -24,31 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -/* - * - * (c) Copyright Ascensio System Limited 2010-2018 - * - * This program is freeware. You can redistribute it and/or modify it under the terms of the GNU - * General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html). - * In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that - * Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. - * - * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR - * FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html - * - * You can contact Ascensio System SIA by email at sales@onlyoffice.com - * - * The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display - * Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3. - * - * Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains - * relevant author attributions when distributing the software. If the display of the logo in its graphic - * form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE" - * in every copy of the program you distribute. - * Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks. - * -*/ - namespace ASC.Resource.Manager; [Scope] @@ -56,11 +31,7 @@ public class ResourceData { private const string Dbid = "tmresource"; -using ASC.Common; -using ASC.Core.Common.EF; -using ASC.Resource.Manager.EF.Context; -using ASC.Resource.Manager.EF.Model; - + private ResourceDbContext DbContext { get; } public ResourceData(DbContextManager dbContext) { DbContext = dbContext.Get(Dbid); diff --git a/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj b/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj index d428c936ad..d5bddd6925 100644 --- a/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj +++ b/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj @@ -11,9 +11,6 @@ - - - all @@ -21,4 +18,8 @@ + + + + diff --git a/common/Tools/AutoMigrationCreator/AutoMigrationCreator.sln b/common/Tools/AutoMigrationCreator/AutoMigrationCreator.sln new file mode 100644 index 0000000000..7b73a81c1d --- /dev/null +++ b/common/Tools/AutoMigrationCreator/AutoMigrationCreator.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32616.157 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoMigrationCreator", "AutoMigrationCreator.csproj", "{C80E803C-96DE-44FB-B9D8-8C75219FD8C3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Core.Common", "..\..\ASC.Core.Common\ASC.Core.Common.csproj", "{A51D0454-4AFA-46DE-89D4-B03D37E1816C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C80E803C-96DE-44FB-B9D8-8C75219FD8C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C80E803C-96DE-44FB-B9D8-8C75219FD8C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C80E803C-96DE-44FB-B9D8-8C75219FD8C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C80E803C-96DE-44FB-B9D8-8C75219FD8C3}.Release|Any CPU.Build.0 = Release|Any CPU + {A51D0454-4AFA-46DE-89D4-B03D37E1816C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A51D0454-4AFA-46DE-89D4-B03D37E1816C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A51D0454-4AFA-46DE-89D4-B03D37E1816C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A51D0454-4AFA-46DE-89D4-B03D37E1816C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F78EB357-DACF-4759-83BB-C9767C317894} + EndGlobalSection +EndGlobal diff --git a/common/Tools/AutoMigrationCreator/Core/AssemblyContextFinder.cs b/common/Tools/AutoMigrationCreator/Core/AssemblyContextFinder.cs index d3a452fccf..a6483c859c 100644 --- a/common/Tools/AutoMigrationCreator/Core/AssemblyContextFinder.cs +++ b/common/Tools/AutoMigrationCreator/Core/AssemblyContextFinder.cs @@ -24,11 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System; -using System.Reflection; - -using AutoMigrationCreator.Core; - namespace AutoMigrationCreator; public class AssemblyContextFinder : ContextFinder diff --git a/common/Tools/AutoMigrationCreator/Core/ContextFinder.cs b/common/Tools/AutoMigrationCreator/Core/ContextFinder.cs index 3c98c05c64..9a2a9e563a 100644 --- a/common/Tools/AutoMigrationCreator/Core/ContextFinder.cs +++ b/common/Tools/AutoMigrationCreator/Core/ContextFinder.cs @@ -24,12 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System; -using System.Collections.Generic; -using System.Linq; - -using ASC.Core.Common.EF; - namespace AutoMigrationCreator.Core; public abstract class ContextFinder { diff --git a/common/Tools/AutoMigrationCreator/Core/MigrationCreator.cs b/common/Tools/AutoMigrationCreator/Core/MigrationCreator.cs index e8ea34b8a9..522305864e 100644 --- a/common/Tools/AutoMigrationCreator/Core/MigrationCreator.cs +++ b/common/Tools/AutoMigrationCreator/Core/MigrationCreator.cs @@ -24,13 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; - -using AutoMigrationCreator.Core; - namespace AutoMigrationCreator; public static class MigrationCreator diff --git a/common/Tools/AutoMigrationCreator/Core/MigrationGenerator.cs b/common/Tools/AutoMigrationCreator/Core/MigrationGenerator.cs index 25101c35d5..51fbd2c4dc 100644 --- a/common/Tools/AutoMigrationCreator/Core/MigrationGenerator.cs +++ b/common/Tools/AutoMigrationCreator/Core/MigrationGenerator.cs @@ -24,18 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; - -using ASC.Core.Common.EF; - -using AutoMigrationCreator.Core; - -using Microsoft.EntityFrameworkCore.Migrations.Design; -using Microsoft.Extensions.DependencyInjection; - namespace AutoMigrationCreator; public class MigrationGenerator diff --git a/common/Tools/AutoMigrationCreator/Core/ModelDifferenceChecker.cs b/common/Tools/AutoMigrationCreator/Core/ModelDifferenceChecker.cs index 7290a225cc..a5db8e06fd 100644 --- a/common/Tools/AutoMigrationCreator/Core/ModelDifferenceChecker.cs +++ b/common/Tools/AutoMigrationCreator/Core/ModelDifferenceChecker.cs @@ -24,15 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System.Collections.Generic; - -using ASC.Core.Common.EF; - -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Migrations.Design; -using Microsoft.EntityFrameworkCore.Migrations.Operations; -using Microsoft.Extensions.DependencyInjection; - namespace AutoMigrationCreator; public class ModelDifferenceChecker diff --git a/common/Tools/AutoMigrationCreator/Core/ProjectInfoContextFinder.cs b/common/Tools/AutoMigrationCreator/Core/ProjectInfoContextFinder.cs index ad554a39cb..c3916bf214 100644 --- a/common/Tools/AutoMigrationCreator/Core/ProjectInfoContextFinder.cs +++ b/common/Tools/AutoMigrationCreator/Core/ProjectInfoContextFinder.cs @@ -24,11 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System; -using System.Reflection; - -using AutoMigrationCreator.Core; - namespace AutoMigrationCreator; public class ProjectInfoContextFinder : ContextFinder diff --git a/common/Tools/AutoMigrationCreator/Core/Solution.cs b/common/Tools/AutoMigrationCreator/Core/Solution.cs index c09af21250..755e44d973 100644 --- a/common/Tools/AutoMigrationCreator/Core/Solution.cs +++ b/common/Tools/AutoMigrationCreator/Core/Solution.cs @@ -24,13 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; - -using Microsoft.Build.Construction; - namespace AutoMigrationCreator.Core; public static class Solution diff --git a/common/Tools/AutoMigrationCreator/GlobalUsings.cs b/common/Tools/AutoMigrationCreator/GlobalUsings.cs new file mode 100644 index 0000000000..512123bbdf --- /dev/null +++ b/common/Tools/AutoMigrationCreator/GlobalUsings.cs @@ -0,0 +1,49 @@ +// (c) Copyright Ascensio System SIA 2010-2022 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +global using System; +global using System.Collections.Generic; +global using System.Configuration; +global using System.IO; +global using System.Linq; +global using System.Reflection; +global using System.Text.RegularExpressions; + +global using ASC.Core.Common.EF; + +global using Autofac; + +global using AutoMigrationCreator.Core; +global using AutoMigrationCreator.Utils; + +global using Microsoft.Build.Construction; +global using Microsoft.EntityFrameworkCore; +global using Microsoft.EntityFrameworkCore.Design; +global using Microsoft.EntityFrameworkCore.Infrastructure; +global using Microsoft.EntityFrameworkCore.Migrations.Design; +global using Microsoft.EntityFrameworkCore.Migrations.Operations; +global using Microsoft.EntityFrameworkCore.Storage; +global using Microsoft.Extensions.DependencyInjection; diff --git a/common/Tools/AutoMigrationCreator/Program.cs b/common/Tools/AutoMigrationCreator/Program.cs index d682e07bf5..21da746163 100644 --- a/common/Tools/AutoMigrationCreator/Program.cs +++ b/common/Tools/AutoMigrationCreator/Program.cs @@ -24,8 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using AutoMigrationCreator.Utils; - namespace AutoMigrationCreator; class Program diff --git a/common/Tools/AutoMigrationCreator/Utils/ArgsParser.cs b/common/Tools/AutoMigrationCreator/Utils/ArgsParser.cs index 7111981ac1..adc2010caf 100644 --- a/common/Tools/AutoMigrationCreator/Utils/ArgsParser.cs +++ b/common/Tools/AutoMigrationCreator/Utils/ArgsParser.cs @@ -24,8 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System; - namespace AutoMigrationCreator.Utils; public static class ArgsParser { diff --git a/common/Tools/AutoMigrationCreator/Utils/DbContextActivator.cs b/common/Tools/AutoMigrationCreator/Utils/DbContextActivator.cs index 2cea89b78c..916b8e15ca 100644 --- a/common/Tools/AutoMigrationCreator/Utils/DbContextActivator.cs +++ b/common/Tools/AutoMigrationCreator/Utils/DbContextActivator.cs @@ -24,11 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using System; -using System.Configuration; - -using ASC.Core.Common.EF; - namespace AutoMigrationCreator; public class DbContextActivator diff --git a/common/Tools/AutoMigrationCreator/Utils/EFCoreDesignTimeServices.cs b/common/Tools/AutoMigrationCreator/Utils/EFCoreDesignTimeServices.cs index 12a02e0107..145448b00f 100644 --- a/common/Tools/AutoMigrationCreator/Utils/EFCoreDesignTimeServices.cs +++ b/common/Tools/AutoMigrationCreator/Utils/EFCoreDesignTimeServices.cs @@ -24,14 +24,6 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using ASC.Core.Common.EF; - -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations.Design; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.DependencyInjection; - namespace AutoMigrationCreator; public static class EFCoreDesignTimeServices From b72f441029abdf2c7704f3f77c9da1cc2ca96518 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Fri, 15 Jul 2022 13:14:09 +0300 Subject: [PATCH 2/2] AutoMigrationCreator: fixed project type --- .../AutoMigrationCreator/AutoMigrationCreator.csproj | 4 +++- common/Tools/AutoMigrationCreator/GlobalUsings.cs | 9 ++------- .../AutoMigrationCreator/Properties/launchSettings.json | 8 ++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 common/Tools/AutoMigrationCreator/Properties/launchSettings.json diff --git a/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj b/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj index d5bddd6925..e8d0922a00 100644 --- a/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj +++ b/common/Tools/AutoMigrationCreator/AutoMigrationCreator.csproj @@ -1,9 +1,11 @@ - + Exe net6.0 AutoMigrationCreator.Program + false + enable diff --git a/common/Tools/AutoMigrationCreator/GlobalUsings.cs b/common/Tools/AutoMigrationCreator/GlobalUsings.cs index 512123bbdf..63dc8280a4 100644 --- a/common/Tools/AutoMigrationCreator/GlobalUsings.cs +++ b/common/Tools/AutoMigrationCreator/GlobalUsings.cs @@ -24,12 +24,8 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -global using System; -global using System.Collections.Generic; -global using System.Configuration; -global using System.IO; -global using System.Linq; -global using System.Reflection; +global using System.Configuration; +global using System.Reflection; global using System.Text.RegularExpressions; global using ASC.Core.Common.EF; @@ -37,7 +33,6 @@ global using ASC.Core.Common.EF; global using Autofac; global using AutoMigrationCreator.Core; -global using AutoMigrationCreator.Utils; global using Microsoft.Build.Construction; global using Microsoft.EntityFrameworkCore; diff --git a/common/Tools/AutoMigrationCreator/Properties/launchSettings.json b/common/Tools/AutoMigrationCreator/Properties/launchSettings.json new file mode 100644 index 0000000000..a2ec651314 --- /dev/null +++ b/common/Tools/AutoMigrationCreator/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "AutoMigrationCreator": { + "commandName": "Project", + "launchBrowser": false + } + } +} \ No newline at end of file