ScaffoldProjFile() private method

private ScaffoldProjFile ( ILogger, logger, FileInfo, projectCsProjFile, string fileDisplayLocation, ProjectType, projectType, bool createAsWeb, bool createAsTestProject, string projectName, string targetFramework, IList? frameworkReferences, IList>? packageReferences, IList? projectReferences, bool includeApiSpecification, bool usingCodingRules ) : void
logger ILogger,
projectCsProjFile FileInfo,
fileDisplayLocation string
projectType ProjectType,
createAsWeb bool
createAsTestProject bool
projectName string
targetFramework string
frameworkReferences IList?
packageReferences IList>?
projectReferences IList?
includeApiSpecification bool
usingCodingRules bool
return void
示例#1
0
        private static List <LogKeyValueItem> ScaffoldSrc(DomainProjectOptions domainProjectOptions)
        {
            if (domainProjectOptions == null)
            {
                throw new ArgumentNullException(nameof(domainProjectOptions));
            }

            if (!Directory.Exists(domainProjectOptions.PathForSrcGenerate.FullName))
            {
                Directory.CreateDirectory(domainProjectOptions.PathForSrcGenerate.FullName);
            }

            var logItems = new List <LogKeyValueItem>();

            if (domainProjectOptions.PathForSrcGenerate.Exists && domainProjectOptions.ProjectSrcCsProj.Exists)
            {
                var element = XElement.Load(domainProjectOptions.ProjectSrcCsProj.FullName);
                var originalNullableValue = SolutionAndProjectHelper.GetBoolFromNullableString(SolutionAndProjectHelper.GetNullableValueFromProject(element));

                bool hasUpdates = false;
                if (domainProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes != originalNullableValue)
                {
                    var newNullableValue = SolutionAndProjectHelper.GetNullableStringFromBool(domainProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes);
                    SolutionAndProjectHelper.SetNullableValueForProject(element, newNullableValue);
                    element.Save(domainProjectOptions.ProjectSrcCsProj.FullName);
                    logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileUpdate", "#", $"Update domain csproj - Nullable value={newNullableValue}"));
                    hasUpdates = true;
                }

                if (!hasUpdates)
                {
                    logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileSkip", "#", "No updates for domain csproj"));
                }
            }
            else
            {
                var projectReferences = new List <FileInfo>();
                if (domainProjectOptions.ApiProjectSrcCsProj != null)
                {
                    projectReferences.Add(domainProjectOptions.ApiProjectSrcCsProj);
                }

                logItems.Add(SolutionAndProjectHelper.ScaffoldProjFile(
                                 domainProjectOptions.ProjectSrcCsProj,
                                 false,
                                 false,
                                 domainProjectOptions.ProjectName,
                                 domainProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes,
                                 new List <string> {
                    "Microsoft.AspNetCore.App"
                },
                                 null,
                                 projectReferences,
                                 false));
            }

            ScaffoldBasicFileDomainRegistration(domainProjectOptions);

            return(logItems);
        }
        private List <LogKeyValueItem> ScaffoldSrc()
        {
            if (!Directory.Exists(projectOptions.PathForSrcGenerate.FullName))
            {
                Directory.CreateDirectory(projectOptions.PathForSrcGenerate.FullName);
            }

            var logItems = new List <LogKeyValueItem>();

            if (projectOptions.PathForSrcGenerate.Exists && projectOptions.ProjectSrcCsProj.Exists)
            {
                logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileSkip", "#", "No updates for csproj"));
            }
            else
            {
                logItems.Add(SolutionAndProjectHelper.ScaffoldProjFile(
                                 projectOptions.ProjectSrcCsProj,
                                 createAsWeb: false,
                                 createAsTestProject: false,
                                 projectName: projectOptions.ProjectName,
                                 "netcoreapp3.1",
                                 useNullableReferenceTypes: projectOptions.ApiOptions.Generator.UseNullableReferenceTypes,
                                 frameworkReferences: null,
                                 packageReferences: NugetPackageReferenceHelper.CreateForApiProject(),
                                 projectReferences: null,
                                 includeApiSpecification: false));
            }

            return(logItems);
        }
示例#3
0
        private static List <LogKeyValueItem> ScaffoldSrc(ApiProjectOptions apiProjectOptions)
        {
            if (apiProjectOptions == null)
            {
                throw new ArgumentNullException(nameof(apiProjectOptions));
            }

            if (!Directory.Exists(apiProjectOptions.PathForSrcGenerate.FullName))
            {
                Directory.CreateDirectory(apiProjectOptions.PathForSrcGenerate.FullName);
            }

            var logItems = new List <LogKeyValueItem>();

            if (apiProjectOptions.PathForSrcGenerate.Exists && apiProjectOptions.ProjectSrcCsProj.Exists)
            {
                var element = XElement.Load(apiProjectOptions.ProjectSrcCsProj.FullName);
                var originalNullableValue = SolutionAndProjectHelper.GetBoolFromNullableString(SolutionAndProjectHelper.GetNullableValueFromProject(element));

                bool hasUpdates = false;
                if (apiProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes != originalNullableValue)
                {
                    var newNullableValue = SolutionAndProjectHelper.GetNullableStringFromBool(apiProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes);
                    SolutionAndProjectHelper.SetNullableValueForProject(element, newNullableValue);
                    element.Save(apiProjectOptions.ProjectSrcCsProj.FullName);
                    logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileUpdate", "#", $"Update API csproj - Nullable value={newNullableValue}"));
                    hasUpdates = true;
                }

                if (!hasUpdates)
                {
                    logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileSkip", "#", "No updates for API csproj"));
                }
            }
            else
            {
                logItems.Add(SolutionAndProjectHelper.ScaffoldProjFile(
                                 apiProjectOptions.ProjectSrcCsProj,
                                 false,
                                 false,
                                 apiProjectOptions.ProjectName,
                                 apiProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes,
                                 new List <string> {
                    "Microsoft.AspNetCore.App"
                },
                                 NugetPackageReferenceHelper.CreateForApiProject(),
                                 null,
                                 true));
            }

            ScaffoldBasicFileApiGenerated(apiProjectOptions);
            DeleteLegacyScaffoldBasicFileResultFactory(apiProjectOptions);
            DeleteLegacyScaffoldBasicFilePagination(apiProjectOptions);

            return(logItems);
        }
        private List <LogKeyValueItem> ScaffoldSrc()
        {
            if (!Directory.Exists(projectOptions.PathForSrcGenerate.FullName))
            {
                Directory.CreateDirectory(projectOptions.PathForSrcGenerate.FullName);
            }

            var logItems = new List <LogKeyValueItem>();

            if (projectOptions.PathForSrcGenerate.Exists && projectOptions.ProjectSrcCsProj.Exists)
            {
                var element = XElement.Load(projectOptions.ProjectSrcCsProj.FullName);
                var originalNullableValue = SolutionAndProjectHelper.GetBoolFromNullableString(SolutionAndProjectHelper.GetNullableValueFromProject(element));

                bool hasUpdates = false;
                if (projectOptions.ApiOptions.Generator.UseNullableReferenceTypes != originalNullableValue)
                {
                    var newNullableValue = SolutionAndProjectHelper.GetNullableStringFromBool(projectOptions.ApiOptions.Generator.UseNullableReferenceTypes);
                    SolutionAndProjectHelper.SetNullableValueForProject(element, newNullableValue);
                    element.Save(projectOptions.ProjectSrcCsProj.FullName);
                    logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileUpdate", "#", $"Update API csproj - Nullable value={newNullableValue}"));
                    hasUpdates = true;
                }

                if (!hasUpdates)
                {
                    logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileSkip", "#", "No updates for API csproj"));
                }
            }
            else
            {
                logItems.Add(SolutionAndProjectHelper.ScaffoldProjFile(
                                 projectOptions.ProjectSrcCsProj,
                                 createAsWeb: false,
                                 createAsTestProject: false,
                                 projectOptions.ProjectName,
                                 "netcoreapp3.1",
                                 projectOptions.ApiOptions.Generator.UseNullableReferenceTypes,
                                 new List <string> {
                    "Microsoft.AspNetCore.App"
                },
                                 NugetPackageReferenceHelper.CreateForApiProject(),
                                 projectReferences: null,
                                 includeApiSpecification: true));
            }

            ScaffoldBasicFileApiGenerated();
            DeleteLegacyScaffoldBasicFileResultFactory();
            DeleteLegacyScaffoldBasicFilePagination();

            return(logItems);
        }
    private void ScaffoldTest()
    {
        if (projectOptions.PathForTestGenerate is null ||
            projectOptions.ProjectTestCsProj is null)
        {
            return;
        }

        if (projectOptions.PathForTestGenerate.Exists &&
            projectOptions.ProjectTestCsProj.Exists)
        {
            var hasUpdates = SolutionAndProjectHelper.EnsureLatestPackageReferencesVersionInProjFile(
                logger,
                projectOptions.ProjectTestCsProj,
                projectOptions.ProjectTestCsProjDisplayLocation,
                ProjectType.ServerDomain,
                isTestProject: true);
            if (!hasUpdates)
            {
                logger.LogDebug($"{EmojisConstants.FileNotUpdated}   No updates for csproj");
            }
        }
        else
        {
            if (!Directory.Exists(projectOptions.PathForTestGenerate.FullName))
            {
                Directory.CreateDirectory(projectOptions.PathForTestGenerate.FullName);
            }

            var projectReferences = new List <FileInfo>();
            if (projectOptions.ApiProjectSrcCsProj is not null)
            {
                projectReferences.Add(projectOptions.ApiProjectSrcCsProj);
                projectReferences.Add(projectOptions.ProjectSrcCsProj);
            }

            SolutionAndProjectHelper.ScaffoldProjFile(
                logger,
                projectOptions.ProjectTestCsProj,
                projectOptions.ProjectTestCsProjDisplayLocation,
                ProjectType.ServerDomain,
                createAsWeb: false,
                createAsTestProject: true,
                $"{projectOptions.ProjectName}.Tests",
                "net6.0",
                frameworkReferences: null,
                NugetPackageReferenceHelper.CreateForTestProject(false),
                projectReferences,
                includeApiSpecification: true,
                usingCodingRules: projectOptions.UsingCodingRules);
        }
    }
    private void ScaffoldSrc()
    {
        if (!Directory.Exists(projectOptions.PathForSrcGenerate.FullName))
        {
            Directory.CreateDirectory(projectOptions.PathForSrcGenerate.FullName);
        }

        if (projectOptions.PathForSrcGenerate.Exists &&
            projectOptions.ProjectSrcCsProj.Exists)
        {
            var hasUpdates = SolutionAndProjectHelper.EnsureLatestPackageReferencesVersionInProjFile(
                logger,
                projectOptions.ProjectSrcCsProj,
                projectOptions.ProjectSrcCsProjDisplayLocation,
                ProjectType.ServerDomain,
                isTestProject: false);
            if (!hasUpdates)
            {
                logger.LogDebug($"{EmojisConstants.FileNotUpdated}   No updates for csproj");
            }
        }
        else
        {
            var projectReferences = new List <FileInfo>();
            if (projectOptions.ApiProjectSrcCsProj is not null)
            {
                projectReferences.Add(projectOptions.ApiProjectSrcCsProj);
            }

            SolutionAndProjectHelper.ScaffoldProjFile(
                logger,
                projectOptions.ProjectSrcCsProj,
                projectOptions.ProjectSrcCsProjDisplayLocation,
                ProjectType.ServerDomain,
                createAsWeb: false,
                createAsTestProject: false,
                projectOptions.ProjectName,
                "net6.0",
                new List <string> {
                "Microsoft.AspNetCore.App"
            },
                packageReferences: null,
                projectReferences,
                includeApiSpecification: false,
                usingCodingRules: projectOptions.UsingCodingRules);

            ScaffoldBasicFileDomainRegistration();
        }
    }
示例#7
0
        private static List <LogKeyValueItem> ScaffoldTest(DomainProjectOptions domainProjectOptions)
        {
            if (domainProjectOptions == null)
            {
                throw new ArgumentNullException(nameof(domainProjectOptions));
            }

            var logItems = new List <LogKeyValueItem>();

            if (domainProjectOptions.PathForTestGenerate == null || domainProjectOptions.ProjectTestCsProj == null)
            {
                return(logItems);
            }

            if (domainProjectOptions.PathForTestGenerate.Exists && domainProjectOptions.ProjectTestCsProj.Exists)
            {
                // Update
            }
            else
            {
                if (!Directory.Exists(domainProjectOptions.PathForTestGenerate.FullName))
                {
                    Directory.CreateDirectory(domainProjectOptions.PathForTestGenerate.FullName);
                }

                var projectReferences = new List <FileInfo>();
                if (domainProjectOptions.ApiProjectSrcCsProj != null)
                {
                    projectReferences.Add(domainProjectOptions.ApiProjectSrcCsProj);
                    projectReferences.Add(domainProjectOptions.ProjectSrcCsProj);
                }

                logItems.Add(SolutionAndProjectHelper.ScaffoldProjFile(
                                 domainProjectOptions.ProjectTestCsProj,
                                 false,
                                 true,
                                 $"{domainProjectOptions.ProjectName}.Tests",
                                 domainProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes,
                                 null,
                                 NugetPackageReferenceHelper.CreateForTestProject(false),
                                 projectReferences,
                                 true));
            }

            return(logItems);
        }
示例#8
0
    private void ScaffoldSrc()
    {
        if (!Directory.Exists(projectOptions.PathForSrcGenerate.FullName))
        {
            Directory.CreateDirectory(projectOptions.PathForSrcGenerate.FullName);
        }

        if (projectOptions.PathForSrcGenerate.Exists &&
            projectOptions.ProjectSrcCsProj.Exists)
        {
            var hasUpdates = SolutionAndProjectHelper.EnsureLatestPackageReferencesVersionInProjFile(
                logger,
                projectOptions.ProjectSrcCsProj,
                projectOptions.ProjectSrcCsProjDisplayLocation,
                ProjectType.ServerApi,
                isTestProject: false);
            if (!hasUpdates)
            {
                logger.LogDebug($"{EmojisConstants.FileNotUpdated}   No updates for csproj");
            }
        }
        else
        {
            SolutionAndProjectHelper.ScaffoldProjFile(
                logger,
                projectOptions.ProjectSrcCsProj,
                projectOptions.ProjectSrcCsProjDisplayLocation,
                ProjectType.ServerApi,
                createAsWeb: false,
                createAsTestProject: false,
                projectOptions.ProjectName,
                "net6.0",
                new List <string> {
                "Microsoft.AspNetCore.App"
            },
                NugetPackageReferenceHelper.CreateForApiProject(),
                projectReferences: null,
                includeApiSpecification: true,
                usingCodingRules: projectOptions.UsingCodingRules);

            ScaffoldBasicFileApiGenerated();
            DeleteLegacyScaffoldBasicFileResultFactory();
            DeleteLegacyScaffoldBasicFilePagination();
        }
    }
示例#9
0
        private static List <LogKeyValueItem> ScaffoldTest(ApiProjectOptions apiProjectOptions)
        {
            if (apiProjectOptions == null)
            {
                throw new ArgumentNullException(nameof(apiProjectOptions));
            }

            var logItems = new List <LogKeyValueItem>();

            if (apiProjectOptions.PathForTestGenerate == null || apiProjectOptions.ProjectTestCsProj == null)
            {
                return(logItems);
            }

            if (apiProjectOptions.PathForTestGenerate.Exists && apiProjectOptions.ProjectTestCsProj.Exists)
            {
                logItems.Add(new LogKeyValueItem(LogCategoryType.Debug, "FileSkip", "#", "No updates for API test csproj"));
            }
            else
            {
                if (!Directory.Exists(apiProjectOptions.PathForTestGenerate.FullName))
                {
                    Directory.CreateDirectory(apiProjectOptions.PathForTestGenerate.FullName);
                }

                var projectReferences = new List <FileInfo>
                {
                    apiProjectOptions.ProjectSrcCsProj
                };

                logItems.Add(SolutionAndProjectHelper.ScaffoldProjFile(
                                 apiProjectOptions.ProjectTestCsProj,
                                 false,
                                 true,
                                 $"{apiProjectOptions.ProjectName}.Tests",
                                 apiProjectOptions.ApiOptions.Generator.UseNullableReferenceTypes,
                                 null,
                                 NugetPackageReferenceHelper.CreateForTestProject(false),
                                 projectReferences,
                                 true));
            }

            return(logItems);
        }
示例#10
0
        private List <LogKeyValueItem> ScaffoldTest()
        {
            var logItems = new List <LogKeyValueItem>();

            if (projectOptions.PathForTestGenerate == null || projectOptions.ProjectTestCsProj == null)
            {
                return(logItems);
            }

            if (projectOptions.PathForTestGenerate.Exists && projectOptions.ProjectTestCsProj.Exists)
            {
                // Update
            }
            else
            {
                if (!Directory.Exists(projectOptions.PathForTestGenerate.FullName))
                {
                    Directory.CreateDirectory(projectOptions.PathForTestGenerate.FullName);
                }

                var projectReferences = new List <FileInfo>();
                if (projectOptions.ApiProjectSrcCsProj != null)
                {
                    projectReferences.Add(projectOptions.ApiProjectSrcCsProj);
                    projectReferences.Add(projectOptions.ProjectSrcCsProj);
                }

                logItems.Add(SolutionAndProjectHelper.ScaffoldProjFile(
                                 projectOptions.ProjectTestCsProj,
                                 false,
                                 true,
                                 $"{projectOptions.ProjectName}.Tests",
                                 "netcoreapp3.1",
                                 projectOptions.ApiOptions.Generator.UseNullableReferenceTypes,
                                 null,
                                 NugetPackageReferenceHelper.CreateForTestProject(false),
                                 projectReferences,
                                 true));
            }

            return(logItems);
        }
示例#11
0
    private void ScaffoldSrc()
    {
        if (!Directory.Exists(projectOptions.PathForSrcGenerate.FullName))
        {
            Directory.CreateDirectory(projectOptions.PathForSrcGenerate.FullName);
        }

        if (projectOptions.PathForSrcGenerate.Exists &&
            projectOptions.ProjectSrcCsProj.Exists)
        {
            var hasUpdates = SolutionAndProjectHelper.EnsureLatestPackageReferencesVersionInProjFile(
                logger,
                projectOptions.ProjectSrcCsProj,
                projectOptions.ProjectSrcCsProjDisplayLocation,
                ProjectType.ClientApi,
                isTestProject: false);
            if (!hasUpdates)
            {
                logger.LogDebug($"{EmojisConstants.FileNotUpdated}   No updates for csproj");
            }
        }
        else
        {
            SolutionAndProjectHelper.ScaffoldProjFile(
                logger,
                projectOptions.ProjectSrcCsProj,
                projectOptions.ProjectSrcCsProjDisplayLocation,
                ProjectType.ClientApi,
                createAsWeb: false,
                createAsTestProject: false,
                projectName: projectOptions.ProjectName,
                "netstandard2.1",
                frameworkReferences: null,
                packageReferences: NugetPackageReferenceHelper.CreateForClientApiProject(),
                projectReferences: null,
                includeApiSpecification: false,
                usingCodingRules: projectOptions.UsingCodingRules);
        }
    }