Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use assembly references to detect Test projects #966

Closed
pavel-mikula-sonarsource opened this issue Mar 15, 2021 · 1 comment
Closed

Use assembly references to detect Test projects #966

pavel-mikula-sonarsource opened this issue Mar 15, 2021 · 1 comment
Assignees
Milestone

Comments

@pavel-mikula-sonarsource
Copy link
Contributor

As part of MMF-2298, we need to extend test project detection to assembly references as well. Projects referencing any assembly from known list will be also classified as a Test projects.

C# and VB.NET analyzers will use project type from the Scanner as an authoritative information and will not perform own detection afterwards.

List of test assemblies should be copied from https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/src/SonarAnalyzer.Common/Helpers/ProjectTypeHelper.cs

@pavel-mikula-sonarsource
Copy link
Contributor Author

This feature will be supported only for MsBuild 15 and 16.

MsBuild14: Target ResolveAssemblyReferences produces @(ReferencePath)

          C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
                  CopyLocal=false
                  FrameworkFile=true
                  FusionName=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                  ImageRuntime=v2.0.50727
                  OriginalItemSpec=C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
                  ReferenceSourceTarget=ResolveAssemblyReference
                  ResolvedFrom=C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
                  Version=2.0.0.0

MsBuild15: Target FindReferenceAssembliesForReferences produces @(ReferencePathWithRefAssemblies)

        C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
                CopyLocal=false
                FrameworkFile=true
                FusionName=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                ImageRuntime=v2.0.50727
                OriginalItemSpec=C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
                ReferenceAssembly=C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
                ReferenceSourceTarget=ResolveAssemblyReference
                ResolvedFrom=C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
                Version=2.0.0.0

MsBuild16: Target FindReferenceAssembliesForReferences produces @(ReferencePathWithRefAssemblies)
Example from NuGet:

        C:\Users\Pavel.Mikula\.nuget\packages\automapper\10.1.1\lib\netstandard2.0\AutoMapper.dll
                CopyLocal=false
                ExternallyResolved=true
                FusionName=AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005
                HintPath=C:\Users\Pavel.Mikula\.nuget\packages\automapper\10.1.1\lib\netstandard2.0\AutoMapper.dll
                ImageRuntime=v4.0.30319
                NuGetPackageId=AutoMapper
                NuGetPackageVersion=10.1.1
                NuGetSourceType=Package
                OriginalItemSpec=C:\Users\Pavel.Mikula\.nuget\packages\automapper\10.1.1\lib\netstandard2.0\AutoMapper.dll
                PathInPackage=lib/netstandard2.0/AutoMapper.dll
                Private=false
                ReferenceAssembly=C:\Users\Pavel.Mikula\.nuget\packages\automapper\10.1.1\lib\netstandard2.0\AutoMapper.dll
                ReferenceSourceTarget=ResolveAssemblyReference
                ResolvedFrom={HintPathFromItem}
                Version=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants