Skip to content

Commit

Permalink
fix: resolves CA1859 error
Browse files Browse the repository at this point in the history
  • Loading branch information
WeihanLi committed Feb 18, 2024
1 parent 5f6d8af commit d421f83
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ public async Task InvokeAsync(ExecOptions options, Func<ExecOptions, Task> next)
packageVersion = newPackageVersion;
}
}

IReference reference = new NuGetReference(packageId, packageVersion);
#pragma warning disable CA1859 // Use concrete types when possible for improved performance
IReference reference = new NuGetReference(packageId, packageVersion);
options.References.Add(reference.ReferenceWithSchema);
#pragma warning restore CA1859 // Use concrete types when possible for improved performance
}

if (File.Exists(projectPath))
Expand All @@ -127,8 +128,10 @@ public async Task InvokeAsync(ExecOptions options, Func<ExecOptions, Task> next)
if (!File.Exists(referenceProjectPath))
continue;

#pragma warning disable CA1859 // Use concrete types when possible for improved performance
IReference projectReference = new ProjectReference(referenceProjectFullPath);
options.References.Add(projectReference.ReferenceWithSchema);
#pragma warning restore CA1859 // Use concrete types when possible for improved performance
}

}
Expand Down
2 changes: 2 additions & 0 deletions tests/IntegrationTest/NuGetReferenceResolverTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public async Task Resolve()
[Fact]
public async Task ResolveReference()
{
#pragma warning disable CA1859 // Use concrete types when possible for improved performance
IReference reference = new NuGetReference("WeihanLi.Common", "1.0.60");
Assert.Equal($"nuget: {reference.Reference}", reference.ReferenceWithSchema);
#pragma warning restore CA1859 // Use concrete types when possible for improved performance

var references = await _resolver.Resolve(reference.Reference, ExecOptions.DefaultTargetFramework);
Assert.NotNull(references);
Expand Down
6 changes: 5 additions & 1 deletion tests/UnitTest/ReferenceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ public class ReferenceTest
[Fact]
public void FileReferenceTypeTest()
{
IReference reference = new FileReference("ReferenceResolver.dll");
#pragma warning disable CA1859 // Use concrete types when possible for improved performance
IReference reference = new FileReference("ReferenceResolver.dll");
Assert.Equal(ReferenceType.LocalFile, reference.ReferenceType);
Assert.Equal($"file: {reference.Reference}", reference.ReferenceWithSchema);
#pragma warning restore CA1859 // Use concrete types when possible for improved performance
}

[Fact]
public void NuGetReferenceTypeTest()
{
#pragma warning disable CA1859 // Use concrete types when possible for improved performance
IReference reference = new NuGetReference("ReferenceResolver", "1.0.0");
Assert.Equal(ReferenceType.NuGetPackage, reference.ReferenceType);
Assert.Equal($"nuget: {reference.Reference}", reference.ReferenceWithSchema);
#pragma warning restore CA1859 // Use concrete types when possible for improved performance
}

[Fact]
Expand Down

0 comments on commit d421f83

Please sign in to comment.