Skip to content

Potentially dead InternalsVisibleTo #5869

Closed

Description

While analyzing the repository, I came across a number of AssemblyInfo.cs files that contain InternalsVisibleTo attributes that are referencing what seem to be long gone assemblies (almost all have Whidbey in the name). I made a little script to find them all:

$friendAssebmlies =
Get-ChildItem src\*AssemblyInfo.cs -Recurse |
Select-String "InternalsVisibleTo" -SimpleMatch -Raw |
ForEach-Object { $_.Remove($_.IndexOf(",")).Replace("[assembly: InternalsVisibleTo(`"", "") } |
Select-Object -Unique |
Sort-Object

foreach ($friendAssebmly in $friendAssebmlies)
{
    Write-Output "Analyzing all usages of $friendAssebmly"
    Write-Output ""
    $actualUsages = Get-ChildItem * -Recurse -Exclude *.dll, *.exe, AssemblyInfo.cs $_ | Select-String $friendAssebmly -SimpleMatch
	
    if ($actualUsages.Length -eq 0)
    {
        Write-Output "Found no usages outside of AssemblyInfo.cs files"
    }	
}

Which gave me this output:

Analyzing all usages of Microsoft.Build

Analyzing all usages of Microsoft.Build.CommandLine.UnitTests

Analyzing all usages of Microsoft.Build.Conversion.Core

Analyzing all usages of Microsoft.Build.Conversion.Unittest

Analyzing all usages of Microsoft.Build.Conversion.Whidbey.Unittest
Found no usages outside of AssemblyInfo.cs files

Analyzing all usages of Microsoft.Build.Engine.BackEndUnitTests
Found no usages outside of AssemblyInfo.cs files

Analyzing all usages of Microsoft.Build.Engine.Unittest

Analyzing all usages of Microsoft.Build.Engine.UnitTests

Analyzing all usages of Microsoft.Build.Engine.Whidbey.Unittest
Found no usages outside of AssemblyInfo.cs files

Analyzing all usages of Microsoft.Build.Framework.Unittest

Analyzing all usages of Microsoft.Build.Framework.UnitTests

Analyzing all usages of Microsoft.Build.Framework.Whidbey.Unittest
Found no usages outside of AssemblyInfo.cs files

Analyzing all usages of Microsoft.Build.Tasks.Cop

Analyzing all usages of Microsoft.Build.Tasks.Core

Analyzing all usages of Microsoft.Build.Tasks.UnitTests

Analyzing all usages of Microsoft.Build.Tasks.Whidbey.Unittest
Found no usages outside of AssemblyInfo.cs files

Analyzing all usages of Microsoft.Build.Unittest

Analyzing all usages of Microsoft.Build.UnitTesting.Targets
Found no usages outside of AssemblyInfo.cs files

Analyzing all usages of Microsoft.Build.Utilities.Core

Analyzing all usages of Microsoft.Build.Utilities.UnitTests

Analyzing all usages of Microsoft.Build.Utilities.Whidbey.Unittest
Found no usages outside of AssemblyInfo.cs files

Analyzing all usages of MSBuild

Analyzing all usages of MSBuild.Whidbey.Unittest
Found no usages outside of AssemblyInfo.cs files

I think these references can be safely deleted, but, given the history of the project, I may well be missing something.
If this is indeed a change that can be taken, I will prepare a PR (that builds and has tests passing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions