-
Notifications
You must be signed in to change notification settings - Fork 832
warning for mismatched param names #3527
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
|
|
||
| neg100.fs(9,12,9,16): typecheck error FS3218: The argument names in the signature 'xxxx' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(8,12,8,16): typecheck error FS3218: The argument names in the signature 'xxx' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(7,12,7,16): typecheck error FS3218: The argument names in the signature 'xx' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(6,12,6,16): typecheck error FS3218: The argument names in the signature 'x' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(15,17,15,22): typecheck error FS3218: The argument names in the signature 'xxxx' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(14,17,14,22): typecheck error FS3218: The argument names in the signature 'xxx' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(13,17,13,22): typecheck error FS3218: The argument names in the signature 'xx' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(12,17,12,22): typecheck error FS3218: The argument names in the signature 'x' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
|
||
| neg100.fs(11,9,11,14): typecheck error FS3218: The argument names in the signature 'aaa' and implementation 'qqqq2' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
|
|
||
| module M | ||
|
|
||
| let ffff ok = ok + 3 | ||
| let gggg1 (qqqq : int) = qqqq + 3 | ||
| let gggg2 (qqqq : int) = qqqq + 3 | ||
| let gggg3 (qqqq : int) = qqqq + 3 | ||
| let gggg4 (qqqq : int) = qqqq + 3 | ||
|
|
||
| type C( qqqq2: int) = | ||
| member __.M1 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
| member __.M2 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
| member __.M3 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
| member __.M4 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
|
|
||
| module M | ||
|
|
||
| val ffff : int -> int | ||
| val gggg1 : x: int -> int | ||
| val gggg2 : xx: int -> int | ||
| val gggg3 : xxx: int -> int | ||
| val gggg4 : xxxx: int -> int | ||
|
|
||
| type C = | ||
| new : aaa : int -> C | ||
| member M1 : x:int -> unit | ||
| member M2 : xx:int -> unit | ||
| member M3 : xxx:int -> unit | ||
| member M4 : xxxx:int -> unit |
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/AddNewKeywordToDisposableConstructorInvocation.fs
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
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs
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
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
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs
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
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/MissingReferenceCodeFixProvider.fs
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
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/ProposeUppercaseLabel.fs
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
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
64 changes: 64 additions & 0 deletions
64
vsintegration/src/FSharp.Editor/CodeFix/RenameParamToMatchSignature.fs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace Microsoft.VisualStudio.FSharp.Editor | ||
|
|
||
| open System | ||
| open System.Collections.Immutable | ||
| open System.Composition | ||
| open System.Threading.Tasks | ||
|
|
||
| open Microsoft.CodeAnalysis | ||
| open Microsoft.CodeAnalysis.Text | ||
| open Microsoft.CodeAnalysis.CodeFixes | ||
|
|
||
| open Microsoft.FSharp.Compiler | ||
| open Microsoft.FSharp.Compiler.SourceCodeServices | ||
| open Microsoft.VisualStudio.FSharp.Editor.SymbolHelpers | ||
| open Microsoft.FSharp.Compiler.SourceCodeServices.Keywords | ||
|
|
||
| [<ExportCodeFixProvider(FSharpConstants.FSharpLanguageName, Name = "FSharpRenameParamToMatchSignature"); Shared>] | ||
| type internal FSharpRenameParamToMatchSignature | ||
| [<ImportingConstructor>] | ||
| ( | ||
| checkerProvider: FSharpCheckerProvider, | ||
| projectInfoManager: FSharpProjectOptionsManager | ||
| ) = | ||
|
|
||
| inherit CodeFixProvider() | ||
| static let userOpName = "RenameParamToMatchSignature" | ||
| let fixableDiagnosticIds = ["FS3218"] | ||
|
|
||
|
|
||
| override __.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds | ||
|
|
||
| override __.RegisterCodeFixesAsync context : Task = | ||
| asyncMaybe { | ||
| match context.Diagnostics |> Seq.filter (fun x -> fixableDiagnosticIds |> List.contains x.Id) |> Seq.toList with | ||
| | [diagnostic] -> | ||
| let message = diagnostic.GetMessage() | ||
| let parts = System.Text.RegularExpressions.Regex.Match(message, ".+'(.+)'.+'(.+)'.+") | ||
| if parts.Success then | ||
|
|
||
| let diagnostics = ImmutableArray.Create diagnostic | ||
| let suggestion = parts.Groups.[1].Value | ||
| let replacement = QuoteIdentifierIfNeeded suggestion | ||
| let computeChanges() = | ||
| asyncMaybe { | ||
| let document = context.Document | ||
| let! cancellationToken = Async.CancellationToken |> liftAsync | ||
| let! sourceText = document.GetTextAsync(cancellationToken) | ||
| let! symbolUses = getSymbolUsesOfSymbolAtLocationInDocument (document, context.Span.Start, projectInfoManager, checkerProvider.Checker, userOpName) | ||
| let changes = | ||
| [| for symbolUse in symbolUses do | ||
| match RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, symbolUse.RangeAlternate) with | ||
| | None -> () | ||
| | Some span -> | ||
| let textSpan = Tokenizer.fixupSpan(sourceText, span) | ||
| yield TextChange(textSpan, replacement) |] | ||
| return changes | ||
| } | ||
| let title = FSComp.SR.replaceWithSuggestion suggestion | ||
| let codefix = createTextChangeCodeFix(title, context, computeChanges) | ||
| context.RegisterCodeFix(codefix, diagnostics) | ||
| | _ -> () | ||
| } |> Async.Ignore |> RoslynHelpers.StartAsyncUnitAsTask(context.CancellationToken) |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the comparison be locale aware, or be StringCompare.Ordinal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everywhere else in signature conformance checking we just use default F# string equality i.e.
System.String.Equals(string1,string2), e.g.If we change it in one place we'd need to change it everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ... but what is the right thing to do?
It may be that locale aware case sensitive is the right thing to do. It's not clear to me is all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can't change this at this stage - all the name lookups in the compiler are based on exact string equality.
Also, part of the intent of using the signature names is to make sure that the .NET/IL/C#/debug and F# views of named arguments are the same. We don't know what equality check is used by visual studio when you mouse-hover over an identifier and it tries to look it up.
In any case, it's an orthogonal issue to this PR