Skip to content

Commit

Permalink
Reproduce GlobalPackageReference issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel committed Apr 11, 2024
1 parent ffe7787 commit 4ec8279
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 3 deletions.
12 changes: 12 additions & 0 deletions tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,18 @@ public void GetsAdditionalFile()

}

[Test]
public void Global_package_references()
{
var analyzer = GetProjectAnalyzer("GlobalPackageReference/GlobalPackageReference.csproj", new());

var references = analyzer.Build().Single().PackageReferences;
var reference = references["StyleCop.Analyzers"];
var version = reference["Version"];

version.Should().Be("1.2.0-beta.556");

Check failure on line 722 in tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs

View workflow job for this annotation

GitHub Actions / Test Results (ubuntu-latest)

Buildalyzer.Tests.Integration.SimpleProjectsFixture ► Global_package_references

Failed test found in: tests/Buildalyzer.Tests/TestResults/test-results.trx Error: Expected version to be "1.2.0-beta.556" with a length of 14, but "" has a length of 0, differs near "" (index 0).
Raw output
Expected version to be "1.2.0-beta.556" with a length of 14, but "" has a length of 0, differs near "" (index 0).
   at FluentAssertions.Execution.LateBoundTestFramework.Throw(String message)
   at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
   at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message)
   at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
   at FluentAssertions.Primitives.StringEqualityValidator.ValidateAgainstLengthDifferences()
   at FluentAssertions.Primitives.StringValidator.Validate()
   at FluentAssertions.Primitives.StringAssertions`1.Be(String expected, String because, Object[] becauseArgs)
   at Buildalyzer.Tests.Integration.SimpleProjectsFixture.Global_package_references() in /home/runner/work/Buildalyzer/Buildalyzer/tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs:line 722

}

private static IProjectAnalyzer GetProjectAnalyzer(string projectFile, StringWriter log)
{
IProjectAnalyzer analyzer = new AnalyzerManager(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<EnablePackageVersionOverride>false</EnablePackageVersionOverride>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\Placeholder.cs" Link="Placeholder.cs" />
</ItemGroup>

<ItemGroup>
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions tests/projects/Shared/Placeholder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Internals;

internal static class Placeholder
{
public static readonly string Label = nameof(Placeholder);
}
Loading

0 comments on commit 4ec8279

Please sign in to comment.