Skip to content

Commit

Permalink
Merge branch 'main' into dev/brettfo/nuspec-missing-targetFramework
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulapopoola authored Jan 26, 2024
2 parents e90c777 + a87eb60 commit 9493bd6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion npm_and_yarn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM ghcr.io/dependabot/dependabot-updater-core
ARG COREPACK_VERSION=0.24.0

# Check for updates at https://github.com/pnpm/pnpm/releases
ARG PNPM_VERSION=8.11.0
ARG PNPM_VERSION=8.14.3

# Check for updates at https://github.com/yarnpkg/berry/releases
ARG YARN_VERSION=3.7.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,32 @@ public static IEnumerable<object[]> GetTopLevelPackageDependenyInfosTestData()
}
};

// version is a property not triggered by a quoted condition
yield return new object[]
{
// build file contents
new[]
{
("project.csproj", """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NewtonsoftJsonVersion>12.0.1</NewtonsoftJsonVersion>
<NewtonsoftJsonVersion Condition="'$(PropertyThatDoesNotExist)' == 'true'">13.0.1</NewtonsoftJsonVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
</ItemGroup>
</Project>
""")
},
// expected dependencies
new Dependency[]
{
new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
}
};

// version is a property with a condition checking for an empty string
yield return new object[]
{
Expand All @@ -488,6 +514,32 @@ public static IEnumerable<object[]> GetTopLevelPackageDependenyInfosTestData()
}
};

// version is a property with a quoted condition checking for an empty string
yield return new object[]
{
// build file contents
new[]
{
("project.csproj", """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NewtonsoftJsonVersion Condition="'$(NewtonsoftJsonVersion)' == ''">12.0.1</NewtonsoftJsonVersion>
<NewtonsoftJsonVersion Condition="'$(PropertyThatDoesNotExist)' == 'true'">13.0.1</NewtonsoftJsonVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
</ItemGroup>
</Project>
""")
},
// expected dependencies
new Dependency[]
{
new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
}
};

// version is set in one file, used in another
yield return new object[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ public static IEnumerable<Dependency> GetTopLevelPackageDependenyInfos(Immutable
// going to be used, and even then we might not be able to update it. As a best guess, we'll simply
// skip any property that has a condition _or_ where the condition is checking for an empty string.
var hasEmptyCondition = string.IsNullOrEmpty(property.Condition);
var conditionIsCheckingForEmptyString = string.Equals(property.Condition, $"$({property.Name}) == ''", StringComparison.OrdinalIgnoreCase);
var conditionIsCheckingForEmptyString = string.Equals(property.Condition, $"$({property.Name}) == ''", StringComparison.OrdinalIgnoreCase) ||
string.Equals(property.Condition, $"'$({property.Name})' == ''", StringComparison.OrdinalIgnoreCase);
if (hasEmptyCondition || conditionIsCheckingForEmptyString)
{
propertyInfo[property.Name] = property.Value;
Expand Down

0 comments on commit 9493bd6

Please sign in to comment.