Skip to content

Commit

Permalink
Merge pull request #14 from seesharper/improve-whitespace-handling
Browse files Browse the repository at this point in the history
Improve whitespace handling
  • Loading branch information
seesharper authored Dec 21, 2022
2 parents cdd2e98 + 8c8d31a commit 1f0ead5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build/build.csx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/Dotnet.Deps.Core/Dotnet.Deps.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<RepositoryUrl>https://github.com/seesharper/dotnet-deps.git</RepositoryUrl>
<Authors>Bernhard Richter</Authors>
<Description>A simple library that can be used to analyze and update NuGet dependencies.</Description>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Configuration" Version="6.2.0" />
<PackageReference Include="NuGet.Packaging" Version="6.2.0" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.2.0" />
<PackageReference Include="NuGet.Protocol" Version="6.2.0" />
<PackageReference Include="ShellProgressBar" Version="5.1.0" />
<PackageReference Include="NuGet.Configuration" Version="6.4.0" />
<PackageReference Include="NuGet.Packaging" Version="6.4.0" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.4.0" />
<PackageReference Include="NuGet.Protocol" Version="6.4.0" />
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
</ItemGroup>
</Project>
21 changes: 17 additions & 4 deletions src/Dotnet.Deps.Core/ProjectSystem/ScriptProjectLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,8 +43,8 @@ public IProjectFile<NuGetPackageReference> Load(string path)
var packageReferences = new List<ScriptPackageReference>();
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))
{
Expand Down
12 changes: 6 additions & 6 deletions src/Dotnet.Deps.Tests/dotnet.deps.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="fluentassertions" Version="6.7.0" />
<PackageReference Include="LightInject" Version="6.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="fluentassertions" Version="6.8.0" />
<PackageReference Include="LightInject" Version="6.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
10 changes: 5 additions & 5 deletions src/Dotnet.Deps/Dotnet.Deps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/seesharper/dotnet-deps.git</RepositoryUrl>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.1" />
<PackageReference Include="NuGet.Configuration" Version="6.2.0" />
<PackageReference Include="NuGet.Packaging" Version="6.2.0" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.2.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
<PackageReference Include="NuGet.Configuration" Version="6.4.0" />
<PackageReference Include="NuGet.Packaging" Version="6.4.0" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dotnet.Deps.Core\Dotnet.Deps.Core.csproj" />
Expand Down

0 comments on commit 1f0ead5

Please sign in to comment.