コード例 #1
0
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile("*.cs", file =>
        {
            file.Replace("TimeSpanPrecisionValidator", "TimePrecisionValidator");
        });

        uctx.ForeachCodeFile("*.csproj", file =>
        {
            file.UpdateNugetReference("Signum.MSBuildTask", "6.0.0");
            file.UpdateNugetReference("Selenium.WebDriver.ChromeDriver", "96.0.4664.4500");
            file.UpdateNugetReference("Microsoft.TypeScript.MSBuild", "4.5.2");
        });

        uctx.ChangeCodeFile(@"Southwind.React\Dockerfile", file =>
        {
            file.Replace("aspnet:5.0.9-buster-slim", "aspnet:6.0.0-bullseye-slim");
            file.Replace("sdk:5.0.400-buster-slim", "sdk:6.0.100-bullseye-slim");
        });

        uctx.ChangeCodeFile(@"Southwind.React\package.json", file =>
        {
            file.UpdateNpmPackage("typescript", "4.5.2");
        });

        uctx.ChangeCodeFile(".editorconfig", file =>
        {
            file.InsertAfterFirstLine(line => line.Contains("indent_size = 4"), "csharp_style_namespace_declarations = file_scoped:warning");
        });
    }
コード例 #2
0
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile("*.csproj", file =>
        {
            file.Replace(@"<TargetFramework>net5.0</TargetFramework>", @"<TargetFramework>net6.0</TargetFramework>");

            file.UpdateNugetReference("Microsoft.Extensions.Configuration", "6.0.0");
            file.UpdateNugetReference("Microsoft.Extensions.Configuration.Binder", "6.0.0");
            file.UpdateNugetReference("Microsoft.Extensions.Configuration.Json", "6.0.0");
            file.UpdateNugetReference("Microsoft.Extensions.Configuration.UserSecrets", "6.0.0");
            file.UpdateNugetReference("Signum.TSGenerator", "6.0.0");
            file.UpdateNugetReference("Selenium.WebDriver.ChromeDriver", "95.0.4638.6900");
        });

        uctx.ChangeCodeFile("Southwind.Terminal/Program.cs", file =>
        {
            file.Replace("AddUserSecrets<Program>()", "AddUserSecrets<Program>(optional: true)\n");
        });


        uctx.ForeachCodeFile("*.cs", file =>
        {
            file.Replace(new Regex(@"\bDate.Today\b"), "TimeZoneManager.Now");
            file.Replace(new Regex(@"\bDate\b"), "DateOnly");
        });
    }
コード例 #3
0
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile(@"*.csproj", file =>
        {
            file.Replace(@"\Extensions\", @"\Framework\");
        });

        uctx.ForeachCodeFile(@"*.sln", file =>
        {
            file.Replace(@"""Extensions\", @"""Framework\");
        });

        uctx.ChangeCodeFile(@"Southwind.React\webpack.config.js", file =>
        {
            file.Replace(@"/Extensions/", @"/Framework/");
        });

        uctx.ChangeCodeFile(@"Southwind.React/tsconfig.json", file =>
        {
            file.Replace(@"/Extensions/", @"/Framework/");
        });

        uctx.ChangeCodeFile(@"Southwind.React/package.json", file =>
        {
            file.Replace(@"/Extensions/", @"/Framework/");
        });

        uctx.ChangeCodeFile(@"Southwind.React/Dockerfile", file =>
        {
            file.Replace(@"""Extensions/", @"""Framework/");
        });

        uctx.ChangeCodeFile(@".gitmodules", file =>
        {
            file.RemoveAllLines(a => a.Contains("extensions", StringComparison.InvariantCultureIgnoreCase));
        });

        uctx.ForeachCodeFile(@"*.ts, *.tsx", file =>
        {
            file.Replace(@"../../../../Extensions/Signum.React.Extensions/", @"@extensions/");
            file.Replace(@"../../../Extensions/Signum.React.Extensions/", @"@extensions/");
            file.Replace(@"../../Extensions/Signum.React.Extensions/", @"@extensions/");

            file.Replace(@"../../../../Framework/Signum.React/Scripts/", @"@framework/");
            file.Replace(@"../../../Framework/Signum.React/Scripts/", @"@framework/");
            file.Replace(@"../../Framework/Signum.React/Scripts/", @"@framework/");
        });

        if (SafeConsole.Ask("Do you want to delete 'Extensions' folder with all his content?"))
        {
            Directory.Delete(Path.Combine(uctx.RootFolder, "Extensions"), true);
            Console.WriteLine("deleted");
        }
    }
コード例 #4
0
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile(@"*.cs", file =>
        {
            file.Replace("RetrieveAndForget", "Retrieve");
        });

        uctx.ForeachCodeFile(@"*.ts, *.tsx", file =>
        {
            file.Replace("fetchAndForget", "fetch");
        });
    }
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile(@"*.csproj", file =>
        {
            file.UpdateNugetReference("Microsoft.Data.SqlClient", "4.0.0");
            file.UpdateNugetReference("DocumentFormat.OpenXml", "2.14.0");
            file.UpdateNugetReference("Microsoft.Graph", "4.11.0");
        });

        uctx.ForeachCodeFile(@"*.json", file =>
        {
            file.Replace("Integrated Security=true", "Integrated Security=true;TrustServerCertificate=true");
        });
    }
コード例 #6
0
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile(@"*.csproj", file =>
        {
            file.ReplaceLine(a => a.Contains("System.Data.SqlClient"), @"<PackageReference Include=""Microsoft.Data.SqlClient"" Version=""3.0.0"" />");
            file.ReplaceLine(a => a.Contains("dotMorten.Microsoft.SqlServer.Types"), @"<PackageReference Include=""Unofficial.Microsoft.SqlServer.Types"" Version=""2.0.1"" />");
        });

        uctx.ForeachCodeFile(@"*.cs", file =>
        {
            file.ReplaceLine(a => a.Contains("using System.Data.SqlClient;"), @"using Microsoft.Data.SqlClient.Server;
using Microsoft.Data.SqlClient;");
        });
    }
コード例 #7
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile($@"*.tsx", uctx.ReactDirectory, file =>
     {
         file.Replace("eoc.defaultClick(", "/*TODO: fix*/ eoc.defaultClick(");
     });
 }
コード例 #8
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.UpdateNugetReference("Swashbuckle.AspNetCore", "6.2.2");
     });
 }
コード例 #9
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.RemoveAllLines(a => a.Contains("<LangVersion>"));
     });
 }
コード例 #10
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile("*.cs", file =>
     {
         file.Replace("TimeZoneManager", "Clock");
     });
 }
コード例 #11
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile($@"*.tsx, *.ts", uctx.ReactDirectory, file =>
     {
         file.Replace(new Regex(@"refreshKey\s*=\s*{(?<val>(?:[^{}]|(?<Open>[{])|(?<-Open>[}]))+)}"),
                      m => $@"deps={{[{m.Groups["val"].Value}]}}");
     });
 }
コード例 #12
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.UpdateNugetReference("Microsoft.Identity.Client", "4.40.0");
         file.UpdateNugetReference("Selenium.WebDriver.ChromeDriver", "98.0.4758.8000");
     });
 }
コード例 #13
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile("*.ts, *.tsx", file =>
     {
         file.Replace("Navigator.navigate(", "Navigator.view(");
         file.Replace("Navigator.isNavigable(", "Navigator.isViewable(");
     });
 }
コード例 #14
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.UpdateNugetReference("DocumentFormat.OpenXml", "2.15.0");
         file.UpdateNugetReference("Selenium.WebDriver.ChromeDriver", "97.0.4692.7100");
     });
 }
コード例 #15
0
    public override void Execute(UpgradeContext uctx)
    {
        Regex regex = new Regex(@"parentToken\s*:\s*(?<parentToken>[^,]+),(\s|\n)+parentValue\s*:\s*(?<parentValue>[^,}\r\n]+)");

        uctx.ForeachCodeFile(@"*.ts, *.tsx", file =>
        {
            file.Replace(regex, r => $"filterOptions: [{{ token: {r.Groups["parentToken"]}, value: {r.Groups["parentValue"]}}}] ");
        });
    }
コード例 #16
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.cs", file =>
     {
         file.Replace(".WithMin(", ".MinBy(");
         file.Replace(".WithMax(", ".MaxBy(");
         file.Replace(".GroupsOf(", ".Chunk(");
     });
 }
コード例 #17
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.cspoj", file =>
     {
         file.UpdateNugetReference("Swashbuckle.AspNetCore", "6.1.4");
         file.UpdateNugetReference("SciSharp.TensorFlow.Redist", "2.4.1");
         file.UpdateNugetReference("Microsoft.NET.Test.Sdk", "16.9.4");
     });
 }
コード例 #18
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile("*.tsx,*.ts", "Southwind.React", file =>
     {
         file.Replace(new Regex(@"token\(\).entity\((\w+) *=> *\1"), @"token($1 => $1.entity");
         file.Replace(new Regex(@"t.entity\((\w+) *=> *\1"), @"t.append($1 => $1.entity");
         file.Replace(@"token().entity()", @"token(a => a.entity)");
     });
 }
    public override void Execute(UpgradeContext uctx)
    {
        var regex = new Regex(@"QueryLogic\.Expressions\.Register\((?<lambda>\([^)]*\) *=> *[^,]*), \(\) *=> *(?<message>\w+Message\.\w+)\.NiceToString\(\)\)");

        uctx.ForeachCodeFile(@"*.cs", file =>
        {
            file.Replace(regex, match => $"QueryLogic.Expressions.Register({match.Groups["lambda"]}, {match.Groups["message"]})");
        });
    }
コード例 #20
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.cs", uctx.EntitiesDirectory, file =>
     {
         file.RemoveAllLines(a => a.Trim() == "[Serializable]");
         file.Replace(new Regex(@"\[\s*Serializable\s*\]\s*"), "");
         file.Replace(new Regex(@"Serializable\s*,\s*"), "");
     });
 }
コード例 #21
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.UpdateNugetReference("Microsoft.Graph", "4.5.0");
         file.UpdateNugetReference("Microsoft.Graph.Auth", "1.0.0-preview.7");
         file.UpdateNugetReference("Microsoft.Identity.Client", "4.36.1");
     });
 }
コード例 #22
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.UpdateNugetReference("Microsoft.TypeScript.MSBuild", "4.5.3");
         file.UpdateNugetReference("Microsoft.VisualStudio.Azure.Containers.Tools.Targets", "1.14.0");
         file.UpdateNugetReference("SciSharp.TensorFlow.Redist", "2.7.0");
         file.UpdateNugetReference("Selenium.WebDriver", "4.1.0");
     });
 }
コード例 #23
0
        public override void Execute(UpgradeContext uctx)
        {
            uctx.ChangeCodeFile(@"Southwind.React/App/MainPublic.tsx", file =>
            {
                file.Replace(
                    "../node_modules/react-widgets/lib/scss/react-widgets.scss",
                    "../node_modules/react-widgets/scss/styles.scss");
            });

            uctx.ForeachCodeFile("*.tsx", "Southwind.React", file =>
            {
                file.Replace(
                    "react-widgets/lib",
                    "react-widgets/cjs");
            });

            uctx.ChangeCodeFile(@"Southwind.React/package.json", file =>
            {
                file.UpdateNpmPackage("@fortawesome/fontawesome-svg-core", "1.2.35");
                file.UpdateNpmPackage("@fortawesome/free-regular-svg-icons", "5.15.3");
                file.UpdateNpmPackage("@fortawesome/free-solid-svg-icons", "5.15.3");
                file.UpdateNpmPackage("@fortawesome/free-brands-svg-icons", "5.15.3");
                file.UpdateNpmPackage("@fortawesome/react-fontawesome", "0.1.14");
                file.UpdateNpmPackage("@types/draft-js", "0.11.1");
                file.UpdateNpmPackage("@types/luxon", "1.26.2");

                file.UpdateNpmPackage("abortcontroller-polyfill", "1.7.1");
                file.UpdateNpmPackage("bootstrap", "4.6.0");
                file.UpdateNpmPackage("codemirror", "5.60.0");
                file.UpdateNpmPackage("core-js", "3.9.1");
                file.UpdateNpmPackage("d3", "6.6.2");

                file.UpdateNpmPackage("luxon", "1.26.0");
                file.UpdateNpmPackage("msal", "1.4.8");

                file.UpdateNpmPackage("react", "17.0.2");
                file.UpdateNpmPackage("react-bootstrap", "1.5.2");
                file.UpdateNpmPackage("react-dom", "17.0.2");

                file.UpdateNpmPackage("react-widgets", "5.0.0");
                file.UpdateNpmPackage("whatwg-fetch", "3.6.2");


                file.UpdateNpmPackage("css-loader", "5.2.0");

                file.ReplaceLine(a => a.Contains("node-sass"), @"""sass"": ""1.32.8"",");

                file.UpdateNpmPackage("sass-loader", "11.0.1");
                file.UpdateNpmPackage("ts-loader", "8.1.0");
                file.UpdateNpmPackage("typescript", "4.2.3");
                file.UpdateNpmPackage("webpack", "5.28.0");
                file.UpdateNpmPackage("webpack-cli", "4.6.0");
                file.UpdateNpmPackage("webpack-notifier", "1.13.0");
            });
        }
コード例 #24
0
    private void ProcessDirectory(UpgradeContext uctx, string directory, string usings)
    {
        var namespaces = usings.Lines().Select(a => a.Trim().After("using ").BeforeLast(";")).ToList();

        uctx.CreateCodeFile(Path.Combine(directory, "Properties", "GlobalUsings.cs"), namespaces.ToString(a => "global using " + a + ";", "\r\n"));

        uctx.ForeachCodeFile(@"*.cs", directory, file =>
        {
            file.RemoveAllLines(a => a.StartsWith("using ") && namespaces.Contains(a.After("using ").Before(";")));
        });
    }
コード例 #25
0
        public override void Execute(UpgradeContext uctx)
        {
            uctx.ChangeCodeFile($@"Southwind.React/App/MainPublic.tsx", file =>
            {
                file.Replace(
                    "import * as moment from \"moment\"",
                    "import * as luxon from \"luxon\"");

                file.RemoveAllLines(
                    l => l.Contains("require('moment/locale")
                    );

                file.RemoveAllLines(
                    l => l.Contains("ConfigureReactWidgets.asumeGlobalUtcMode(moment, false);")
                    );

                file.ReplaceBetweenExcluded(
                    l => l.Contains("const culture = ci.name"),
                    l => l.Contains("});"),
                    @"  luxon.Settings.defaultLocale = culture;
  numbro.setLanguage(culture);"
                    );
            });

            uctx.ForeachCodeFile($@"*.tsx, *.ts", uctx.ReactDirectory, file =>
            {
                file.Replace("import * as moment from 'moment'", "import { DateTime } from 'luxon'");
                file.Replace("format()", "toISO()");
                file.Replace("moment()", "DateTime.local()");
                file.Replace("moment(", "DateTime.fromISO(");
                file.Replace(".fromNow(true)", ".toRelative()");
            });

            uctx.ChangeCodeFile($@"Southwind.React/App/vendors.js", file =>
            {
                file.Replace(
                    "require(\"moment\");",
                    "require(\"luxon\");");
            });

            uctx.ChangeCodeFile($@"Southwind.React/package.json", file =>
            {
                file.ReplaceLine(a => a.Contains("\"moment\""),
                                 @"""@types/luxon"": ""1.24.4"",
""luxon"": ""1.25.0"","
                                 );
            });

            uctx.ChangeCodeFile($@"Southwind.React/webpack.config.js", file =>
            {
                file.RemoveAllLines(a => a.Contains("webpack.ContextReplacementPlugin"));
            });
        }
コード例 #26
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.UpdateNugetReference("Signum.Analyzer", "3.1.0");
         file.UpdateNugetReference("Microsoft.TypeScript.MSBuild", "4.3.5");
         file.UpdateNugetReference("Microsoft.VisualStudio.Azure.Containers.Tools.Targets", "1.11.1");
         file.UpdateNugetReference("Swashbuckle.AspNetCore", "6.1.5");
         file.UpdateNugetReference("SciSharp.TensorFlow.Redist", "2.6.0");
         file.UpdateNugetReference("Microsoft.NET.Test.Sdk", "16.11.0");
         file.UpdateNugetReference("DocumentFormat.OpenXml", "2.13.1");
     });
 }
コード例 #27
0
 public override void Execute(UpgradeContext uctx)
 {
     uctx.ForeachCodeFile(@"*.csproj", file =>
     {
         file.UpdateNugetReference("Azure.Storage.Files.Shares", "12.8.0");
         file.UpdateNugetReference("Microsoft.TypeScript.MSBuild", "4.4.4");
         file.UpdateNugetReference("Microsoft.NET.Test.Sdk", "17.0.0");
         file.UpdateNugetReference("Selenium.WebDriver", "4.0.1");
         file.UpdateNugetReference("Selenium.WebDriver.ChromeDriver", "95.0.4638.1700");
         file.ReplaceLine(a => a.Contains("Selenium.Chrome.WebDriver"), @"<PackageReference Include=""Selenium.WebDriver.ChromeDriver"" Version=""95.0.4638.1700"" />");
         file.UpdateNugetReference("Signum.Analyzer", "3.2.0");
         file.UpdateNugetReference("Swashbuckle.AspNetCore", "6.2.3");
     });
 }
コード例 #28
0
        public override void Execute(UpgradeContext uctx)
        {
            uctx.ForeachCodeFile("*.csproj", file =>
            {
                file.UpdateNugetReference(@"Microsoft.TypeScript.MSBuild", @"4.2.2");
                file.UpdateNugetReference(@"Microsoft.NET.Test.Sdk", @"16.9.1");
                file.UpdateNugetReference(@"Selenium.Chrome.WebDriver", @"85.0.0");
            });

            uctx.ChangeCodeFile("Southwind.React/package.json", file =>
            {
                file.UpdateNpmPackage("ts-loader", "8.0.17");
                file.UpdateNpmPackage("typescript", "4.2.2");
            });
        }
コード例 #29
0
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile(@"*.csproj", file =>
        {
            file.RemoveAllLines(a => a.Contains("<Platforms>"));
            file.ReplaceBetweenIncluded(
                a => a.Contains("<PropertyGroup Condition="),
                a => a.Contains("</PropertyGroup>"),
                "");
        });

        uctx.ChangeCodeFile(@"Southwind.sln", file =>
        {
            file.Replace("x64", "Any CPU");
        });
    }
コード例 #30
0
    public override void Execute(UpgradeContext uctx)
    {
        uctx.ForeachCodeFile(@"*.cs", file =>
        {
            file.WarningLevel = WarningLevel.Warning;
            file.ProcessLines(lines =>
            {
                var index = lines.FindIndex(a => a.StartsWith("namespace "));
                if (index == -1)
                {
                    file.Warning($"File {file.FilePath} has no namespace ?!?");
                    return(false);
                }

                var ns = lines[index].After("namespace ");

                var startIndex = lines.FindIndex(index, a => a.Trim() == "{");
                var endIndex   = lines.FindLastIndex(a => a.Trim() == "}");

                if (startIndex == -1 || endIndex == -1)
                {
                    file.Warning($"File {file.FilePath} has no namespace ?!?");
                    return(false);
                }

                for (int i = startIndex + 1; i < endIndex; i++)
                {
                    var line = lines[i];

                    lines[i] = line.StartsWith("\t") ? line.Substring(1) :
                               line.StartsWith("    ") ? line.Substring(4) :
                               line;
                }

                lines[index]      = "namespace " + ns + ";";
                lines[startIndex] = "";
                lines.RemoveAt(endIndex);

                return(true);
            });
        });
    }