From 59657c1f8fc941a95c7801230846b7eed49fba90 Mon Sep 17 00:00:00 2001 From: Bernhard Richter Date: Wed, 21 Dec 2022 14:55:19 +0100 Subject: [PATCH 1/2] Improve whitespace handling --- .../ProjectSystem/ScriptProjectLoader.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Dotnet.Deps.Core/ProjectSystem/ScriptProjectLoader.cs b/src/Dotnet.Deps.Core/ProjectSystem/ScriptProjectLoader.cs index e6748c7..45fd65a 100644 --- a/src/Dotnet.Deps.Core/ProjectSystem/ScriptProjectLoader.cs +++ b/src/Dotnet.Deps.Core/ProjectSystem/ScriptProjectLoader.cs @@ -8,8 +8,21 @@ namespace Dotnet.Deps.Core.ProjectSystem { public class ScriptProjectLoader : IProjectLoader { - const string ReferenceDirectivePattern = @"^(\s*#r\s*""nuget:\s*)(.*)(,\s*)(.*)(\s*""$)"; - const string LoadDirectivePattern = @"^(\s*#load\s*""nuget:\s*)(.*)(,\s*)(.*)(\s*""$)"; + const string Hws = @"[\x20\t]*"; // hws = horizontal whitespace + + const string NuGetPattern = @"nuget:" + // https://github.com/NuGet/docs.microsoft.com-nuget/issues/543#issue-270039223 + + Hws + @"(\w+(?:[_.-]\w+)*)" + + @"(?:" + Hws + "," + Hws + @"(.+?))?"; + + const string WholeNuGetPattern = @"^" + NuGetPattern + @"$"; + + const string NuGetDirectivePatternSuffix = Hws + @"""" + NuGetPattern + @""""; + + const string DirectivePatternPrefix = @"^" + Hws + @"#"; + + const string ReferenceDirectivePattern = DirectivePatternPrefix + "r" + NuGetDirectivePatternSuffix; + const string LoadDirectivePattern = DirectivePatternPrefix + "load" + NuGetDirectivePatternSuffix; private readonly AppConsole console; @@ -30,8 +43,8 @@ public IProjectFile Load(string path) var packageReferences = new List(); foreach (var match in matches) { - var packageName = match.Groups[2].Value; - var packageVersion = match.Groups[4].Value; + var packageName = match.Groups[1].Value; + var packageVersion = match.Groups[2].Value; if (FloatRange.TryParse(packageVersion, out var floatRange)) { From 8c8d31a1497198b3b6922d7b693385e47579b4a9 Mon Sep 17 00:00:00 2001 From: Bernhard Richter Date: Wed, 21 Dec 2022 15:04:49 +0100 Subject: [PATCH 2/2] Bumped deps --- build/build.csx | 2 +- src/Dotnet.Deps.Core/Dotnet.Deps.Core.csproj | 12 ++++++------ src/Dotnet.Deps.Tests/dotnet.deps.tests.csproj | 12 ++++++------ src/Dotnet.Deps/Dotnet.Deps.csproj | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/build.csx b/build/build.csx index 83d4b1c..a7025bd 100644 --- a/build/build.csx +++ b/build/build.csx @@ -1,4 +1,4 @@ -#load "nuget:Dotnet.Build, 0.15.0" +#load "nuget:Dotnet.Build, 0.16.1" #load "nuget:dotnet-steps, 0.0.2" BuildContext.CodeCoverageThreshold = 80; diff --git a/src/Dotnet.Deps.Core/Dotnet.Deps.Core.csproj b/src/Dotnet.Deps.Core/Dotnet.Deps.Core.csproj index 09b971b..0014321 100644 --- a/src/Dotnet.Deps.Core/Dotnet.Deps.Core.csproj +++ b/src/Dotnet.Deps.Core/Dotnet.Deps.Core.csproj @@ -10,13 +10,13 @@ https://github.com/seesharper/dotnet-deps.git Bernhard Richter A simple library that can be used to analyze and update NuGet dependencies. - 2.1.0 + 2.1.1 - - - - - + + + + + \ No newline at end of file diff --git a/src/Dotnet.Deps.Tests/dotnet.deps.tests.csproj b/src/Dotnet.Deps.Tests/dotnet.deps.tests.csproj index f248815..89051a8 100644 --- a/src/Dotnet.Deps.Tests/dotnet.deps.tests.csproj +++ b/src/Dotnet.Deps.Tests/dotnet.deps.tests.csproj @@ -6,15 +6,15 @@ false - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Dotnet.Deps/Dotnet.Deps.csproj b/src/Dotnet.Deps/Dotnet.Deps.csproj index d468dce..c298213 100644 --- a/src/Dotnet.Deps/Dotnet.Deps.csproj +++ b/src/Dotnet.Deps/Dotnet.Deps.csproj @@ -15,13 +15,13 @@ MIT git https://github.com/seesharper/dotnet-deps.git - 3.0.0 + 3.0.1 - - - - + + + +