Improvements/Fixes for Unused Declarations #998
Merged
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.
Change: Get Unused Declarations from FCS
UnusedDeclarationAnalyzer
Enhancement: mark more elements (like functions & members) as unused
Enhancement/Change: Unused Diagnostic now always contains Code
FSAC0003
FSAC0003
.Code was used to differentiate between
this
value (-> only replace with_
CodeFix) and other values (-> both Replace & prefix CodeFixes). That's now determined insideRenameUnusedValue
CodeFix -> all diags can beFSAC0003
NotificationEvent.UnusedDeclarations(file, decls)
->decls
is now justrange[]
(prev:(range*bool)[]
)Fixes for RenameUnusedValue CodeFix:
_
" CodeFix. Butlet _``hello world`` = ...
is invalid.-> Prefix CodeFix doesn't trigger any more for backticks. Replace with
_
still does._
" CodeFix. Butlet private _ = ...
is invalid (private
is part of named SynPat, not part of let binding or outer SynPat)SynPat.Named
range doesn't include access modifier. AndSynAccess
doesn't include a range. (At least in FCS version currently used in FSAC. Range was introduced in Add range of access to SyntaxTree. dotnet/fsharp#13304 )Once there is a FCS with ranges for
SynAccess
it should be trivial to enable Replace CodeFix again (-> see code and corresponding tests)_
CodeFix still only triggers for unused value bindings, but not functions or members.I don't think you ever want a
_
-prefixed function or member, but instead should either remove or make it public -> no prefix CodeFix (and replace with_
is invalid for functions/members)