Skip to content
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

Rework Extension Usage #13

Open
Dirk-Peters opened this issue Nov 17, 2021 · 2 comments
Open

Rework Extension Usage #13

Dirk-Peters opened this issue Nov 17, 2021 · 2 comments

Comments

@Dirk-Peters
Copy link
Contributor

Dirk-Peters commented Nov 17, 2021

Problem: Some IDEs like Rider are now showing a lot more extension methods in IntelliSense, even those, that are not imported in the current file. On the one side this makes it much easier to use them on the other side it causes the IDE to potentially overwhelm the developer with the amount of suggestions.
This will only get worse with dotnet 6 and C# 10 with global using directives, where you might not even be able to see which extensions are displayed because of a global or local using.

Suggested Solution: To prevent intellisense pollution there should be a more deliberate choice which methods, especially variants of "return" methods are actually provided as extension Methods and which only as normal static methods, usable with static imports to have more control over when these methods are found by current IDEs.

@janekx21
Copy link

Could a simple pipe extention fix this?

https://www.nuget.org/packages/WinstonPuckett.PipeExtensions/1.0.0

@apfohl
Copy link
Contributor

apfohl commented Sep 3, 2023

Tho I like the pipe operator (I love it in F#) for it‘s obvious reasons, it‘s not helping with reducing suggestions through the IDE. In order for the IDE to suggest less methods, they can‘t be extension methods. So, they would need to be reworked anyways to be just static function. Of cause they then could be used with a pipelining operator like in F#. But that‘s a whole other discussion of why then not just using F# after all.

to all of that Bind() is basically your Pipe(). You can simply chain methods returning monads together. But there is an even cooler thing to approach the railway oriented style of pipe. Use LINQ query syntax:

var result =
    from file in SearchFile()
    from value in ReadFromFile(file)
    select value.text;

The signatures for the methods would look like:

Maybe<IFile> SearchFile();
Maybe<Content> ReadFromFile(IFile file);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants