Internal error when type checking extension method defined in C#
See original GitHub issuePlease provide a succinct description of the issue.
Repro steps
Using the latest .NET 7 preview, I cannot compile F# that invokes an extension method which was defined in C#. Using my local compiler build, I have the same problem.
Sample: TcExprCopyRepro.zip msbuild-binlog.zip
Changing the .NET SDK to 6.0.302
(and changing the <TargetFramework>
) does allow this sample to compile.
Related information
The error happens somewhere in https://github.com/dotnet/fsharp/blob/0c1eba0671d0edb86e97618e0a7678a7550befe4/src/Compiler/TypedTree/TypedTreeOps.fs#L877
Provide any related information (optional):
- Operating system: Windows
- .NET Runtime kind: .NET 7.0.100-preview.6.22352.1
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Extension methods must be defined in a non-generic static ...
I ran into this when converting a project to use dependency injection. If a method declaration contains the “this” keyword, VS will give...
Read more >Extension Methods - C# Programming Guide
Extension methods in C# enable you to add methods to existing types without creating a new derived type, recompiling, or otherwise modifying ...
Read more >How the extension methods working internally?
Inside this class GetFirstThreeCh method has been compiled as static public method which has string type parameter. NOTE that in here there is ......
Read more >C# Error CS1110 - Cannot define a new extension method ...
CS1110 – Cannot define a new extension method because the compiler required type '{0}' cannot be found. Are you missing a reference to...
Read more >Extension methods must be defined in a top level static class ...
Reason for the Error & Solution. Extension Methods must be defined on top level static classes, 'name' is a nested class.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I used this unit test to debug the problem,
What is really going on here, is a bit beyond me at this time.
@vzarytovskii . Thanks for fixing this .