From 9e77efa8ae42d8501b5bd9fbdfd63f2f267f89be Mon Sep 17 00:00:00 2001 From: Marty T <120425148+tippmar-nr@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:44:38 -0600 Subject: [PATCH] chore: Update Dotty project and package lists, other fixes (#2883) --- .../nugetSlackNotifications/CsprojHandler.cs | 46 +++++++++++++++---- .../nugetSlackNotifications/Program.cs | 3 +- .../nugetSlackNotifications.csproj | 6 ++- .../nugetSlackNotifications/packageInfo.json | 26 ++++++++++- .../nugetSlackNotifications/projectInfo.json | 18 ++++++++ build/NugetValidator/NugetValidator.csproj | 2 +- .../NugetVersionDeprecator.csproj | 2 +- 7 files changed, 88 insertions(+), 15 deletions(-) diff --git a/.github/workflows/scripts/nugetSlackNotifications/CsprojHandler.cs b/.github/workflows/scripts/nugetSlackNotifications/CsprojHandler.cs index cb907621ab..b4aa59eb55 100644 --- a/.github/workflows/scripts/nugetSlackNotifications/CsprojHandler.cs +++ b/.github/workflows/scripts/nugetSlackNotifications/CsprojHandler.cs @@ -13,28 +13,30 @@ public class CsprojHandler { public static async Task> UpdatePackageReferences(string csprojPath, List versionDatas) { + Log.Information("Processing {CSProj}...", csprojPath); var updateLog = new List(); var csprojLines = await File.ReadAllLinesAsync(csprojPath); - var packages = Parse(csprojLines); + var packages = Parse(csprojPath, csprojLines); if (packages.Count == 0) { Log.Warning("No packages found in csproj file " + csprojPath); return updateLog; } + var updatedCsProj = false; foreach (var versionData in versionDatas) { var matchingPackages = packages.Where(p => p.Include == versionData.PackageName).ToList(); if (matchingPackages.Count == 0) { - Log.Warning($"No matching packages found in csproj file for {versionData.PackageName}"); + //Log.Warning($"No matching packages found in csproj file for {versionData.PackageName}"); continue; } foreach (var package in matchingPackages) { - if(package.VersionAsVersion < versionData.NewVersionAsVersion && package.Pin) + if (package.VersionAsVersion < versionData.NewVersionAsVersion && package.Pin) { Log.Warning($"Not updating {package.Include} for {package.TargetFramework}, it is pinned to {package.Version}. Manual verification recommended."); continue; @@ -46,6 +48,7 @@ public static async Task> UpdatePackageReferences(string csprojPath var pattern = @"\d+(\.\d+){2,3}"; var result = Regex.Replace(csprojLines[package.LineNumber], pattern, versionData.NewVersion); csprojLines[package.LineNumber] = result; + updatedCsProj = true; updateLog.Add($"- Package [{versionData.PackageName}]({versionData.Url}) " + $"for {package.TargetFramework} " + @@ -55,38 +58,61 @@ public static async Task> UpdatePackageReferences(string csprojPath } } - await File.WriteAllLinesAsync(csprojPath, csprojLines); - updateLog.Add(""); + if (updatedCsProj) + { + await File.WriteAllLinesAsync(csprojPath, csprojLines); + updateLog.Add(""); + } + return updateLog; } - private static List Parse(string[] csprojLines) + private static List Parse(string csProjPath, string[] csprojLines) { var packages = new List(); try { + var unclosed = false; + var curLine = ""; for (int i = 0; i < csprojLines.Length; i++) { - var line = csprojLines[i]; - if (!line.Contains("PackageReference")) + curLine += csprojLines[i]; + if (!unclosed && !curLine.Contains("PackageReference")) + { + curLine = ""; + continue; + } + + if (unclosed && curLine.Contains("")) { + unclosed = false; + } + else if (!curLine.EndsWith("/>")) + { + unclosed = true; + curLine += Environment.NewLine; continue; } + else + unclosed = false; var serializer = new XmlSerializer(typeof(PackageReference)); - using (var reader = new StringReader(line)) + using (var reader = new StringReader(curLine)) { var packageReference = (PackageReference)serializer.Deserialize(reader); packageReference.LineNumber = i; packages.Add(packageReference); } + + if (!unclosed) + curLine = ""; } return packages; } catch (Exception e) { - Log.Error(e, "XML issue"); + Log.Error(e, $"XML issue while parsing {csProjPath}"); return packages; } } diff --git a/.github/workflows/scripts/nugetSlackNotifications/Program.cs b/.github/workflows/scripts/nugetSlackNotifications/Program.cs index 432088134c..1a0bde7426 100644 --- a/.github/workflows/scripts/nugetSlackNotifications/Program.cs +++ b/.github/workflows/scripts/nugetSlackNotifications/Program.cs @@ -68,7 +68,8 @@ static async Task Main() catch (Exception ex) { Log.Error(ex, $"Caught exception while checking {package.PackageName} for updates."); - await SendSlackNotification($"Dotty: caught exception while checking {package.PackageName} for updates: {ex}"); + if (!_testMode) + await SendSlackNotification($"Dotty: caught exception while checking {package.PackageName} for updates: {ex}"); } } diff --git a/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj b/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj index 2e92fcd341..e8f11a87c8 100644 --- a/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj +++ b/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj @@ -10,7 +10,7 @@ - + @@ -25,4 +25,8 @@ + + + + diff --git a/.github/workflows/scripts/nugetSlackNotifications/packageInfo.json b/.github/workflows/scripts/nugetSlackNotifications/packageInfo.json index a0b9618f48..2e379a2488 100644 --- a/.github/workflows/scripts/nugetSlackNotifications/packageInfo.json +++ b/.github/workflows/scripts/nugetSlackNotifications/packageInfo.json @@ -41,6 +41,9 @@ "ignoreMinor": false, "ignoreReason": "frequent patch releases create too much noise" }, + { + "packageName": "awssdk.dynamodbv2" + }, { "packageName": "confluent.kafka" }, @@ -53,6 +56,9 @@ "ignoreMinor": false, "ignoreReason": "frequent patch releases create too much noise" }, + { + "packageName": "enyimmemcachedcore" + }, { "packageName": "log4net", "ignorePatch": true, @@ -60,6 +66,21 @@ "ignoreMajor": true, "ignoreReason": "Breaking major update. See https://github.com/newrelic/newrelic-dotnet-agent/issues/2764" }, + { + "packageName": "microsoft.azure.functions.worker" + }, + { + "packageName": "microsoft.azure.functions.worker.extensions.http" + }, + { + "packageName": "microsoft.azure.functions.worker.extensions.http.aspnetcore" + }, + { + "packageName": "microsoft.azure.functions.worker.extensions.storage.queues" + }, + { + "packageName": "microsoft.azure.functions.worker.sdk" + }, { "packageName": "microsoft.extensions.logging" }, @@ -85,10 +106,13 @@ { "packageName": "nest" }, + { + "packageName": "newrelic.agent.api" + }, { "packageName": "nlog" }, - { + { "packageName": "nservicebus" }, { diff --git a/.github/workflows/scripts/nugetSlackNotifications/projectInfo.json b/.github/workflows/scripts/nugetSlackNotifications/projectInfo.json index 3cfb1def2c..a0c625af93 100644 --- a/.github/workflows/scripts/nugetSlackNotifications/projectInfo.json +++ b/.github/workflows/scripts/nugetSlackNotifications/projectInfo.json @@ -1,5 +1,23 @@ [ { "projectFile": "tests/Agent/IntegrationTests/SharedApplications/Common/MFALatestPackages/MFALatestPackages.csproj" + }, + { + "projectFile": "tests/Agent/IntegrationTests/Applications/AzureFunctionApplication/AzureFunctionApplication.csproj" + }, + { + "projectFile": "tests/Agent/IntegrationTests/Applications/LambdaSelfExecutingAssembly/LambdaSelfExecutingAssembly.csproj" + }, + { + "projectFile": "tests/Agent/IntegrationTests/ContainerApplications/AwsSdkTestApp/AwsSdkTestApp.csproj" + }, + { + "projectFile": "tests/Agent/IntegrationTests/ContainerApplications/KafkaTestApp/KafkaTestApp.csproj" + }, + { + "projectFile": "tests/Agent/IntegrationTests/ContainerApplications/MemcachedTestApp/MemcachedTestApp.csproj" + }, + { + "projectFile": "tests/Agent/IntegrationTests/ContainerApplications/SmokeTestApp/SmokeTestApp.csproj" } ] diff --git a/build/NugetValidator/NugetValidator.csproj b/build/NugetValidator/NugetValidator.csproj index 3b04504c77..8c88d5d066 100644 --- a/build/NugetValidator/NugetValidator.csproj +++ b/build/NugetValidator/NugetValidator.csproj @@ -14,7 +14,7 @@ - + diff --git a/build/NugetVersionDeprecator/NugetVersionDeprecator.csproj b/build/NugetVersionDeprecator/NugetVersionDeprecator.csproj index 4c789093a1..c73a5872a5 100644 --- a/build/NugetVersionDeprecator/NugetVersionDeprecator.csproj +++ b/build/NugetVersionDeprecator/NugetVersionDeprecator.csproj @@ -19,7 +19,7 @@ - +