fsprojects / fsprojects/FSharpLint
(FL0034): ReimplementsFunction shown error, but after implementing suggestion build fails
Nobody has claimed this yet.
- Dominant language
- F#
- Stars
- 327
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
Description
Please provide a succinct description of your issue.
I have a C# class with constructor accepting Func... as parameter.
Creation of object in F# and using applied function as argument gives Lint error, but after fixing it based on suggestion code does not compile.
In order to compile I need to instantiate instance of Func
So, the question is: Is it really more preferable way of writing?
FuncClass(fun str -> myLocalFunc str) - compile but Lint is angry
FuncClass(myLocalFunc) - do not compile
FuncClass(Func<_,_>(myLocalFunc)) - compile
Repro steps
- Have C# class:
public class FuncClass
{
public FuncClass(Func<string, string> func)
{
Func = func;
}
public Func<string, string> Func { get; }
}
- Have local function as string -> string:
let myLocalFunc str = sprintf "%s" str - Create instance:
let createNotComplientClass () =
FuncClass(fun str -> myLocalFunc str)
Expected behavior
Probably it is OK to have re-implemented function here
Actual behavior
Lint gives error, but suggested fix do not compile
Known workarounds
This do not give Lint issue, and compile. But is it best F# approach?
let createComplientClass () =
FuncClass(Func<_,_>(myLocalFunc))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce FL0034 with the provided C# FuncClass and F# function examples, then inspect the lint rule that reports the reimplemented function. Check the suggested rewrite against the compilation failure and the Func<_ , _> workaround; done means the diagnostic and fix agree with valid F#/.NET interop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, fsharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100