Repository navigation
Match name-only project reference identities by simple name - #157
Open
jackdemori wants to merge 1 commit into
Open
jackdemori wants to merge 1 commit into
jackdemori wants to merge 1 commit into
Conversation
When the referenced project has not been built yet, its resolved FusionName holds only the simple name, while the CompilationReference carries the full identity (for example Version=1.0.0.0), so RT0002 reported every used project reference in a workspace opened before a build. A declared identity without a version now matches a used assembly of the same simple name; one with a version keeps the full identity comparison.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #149 and #150.
RT0002 reports every project reference as removable when a solution is opened in an editor before it has been built. After the first build, the diagnostics go away.
Why
For each project reference, #150 compares two identities of the referenced assembly:
Before the referenced project is built, the build can only write its simple name,
Dep. The assembly the code uses has the full identity,Dep, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. The two never match, so every project reference looks unused.A design-time build of two projects,
AppreferencingDep, shows the identity the build writes before and afterDepis built:Fix
If the declared identity has no version, compare by simple name only. If it has a version, compare the full identity as before, so the behaviour from #150 does not change.
Tests
UsedCompilationReferenceMatchesNameOnlyAssemblyIdentity: a used reference declared by simple name is not reported. Fails onmain.UnusedCompilationReferenceWithNameOnlyAssemblyIdentityStillReportsDiagnostic: with one used and one unused reference, both declared by simple name, only the unused one is reported. Fails onmain.All tests pass on macOS: 197 passed, 0 failed, 9 skipped (they need Windows).