FuGetGallery icon indicating copy to clipboard operation
FuGetGallery copied to clipboard

Use syntactic sugar for special operator methods

Open Rekkonnect opened this issue 3 years ago • 5 comments

Special methods like operators, implicit or explicit type conversion methods are displayed as op_XXX.

For example, a class that implements the + operator will have its method displayed as op_Addition.

The exact special names that could be detected and replaced are certainly documented somewhere.

Rekkonnect avatar Mar 10 '21 23:03 Rekkonnect

Here is the list of overload names from the framework design guidelines: https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/operator-overloads

praeclarum avatar May 27 '21 17:05 praeclarum

Here's a good example of a type implementing many of these operators. http://fuget.org/packages/Genumerics/1.0.3/lib/netcoreapp3.0/Genumerics.dll/Genumerics/Number%601

TylerBrinkley avatar May 28 '21 12:05 TylerBrinkley

There is a class that I believe is publicly available, containing the names of several special symbols, which is this.

Rekkonnect avatar Jul 08 '21 15:07 Rekkonnect

Hey @TylerBrinkley, great library! I’ll get this fixed up.

@AlFasGD Thanks for the reference. Somewhere inside ILSpy is this table too. But it shouldn’t be hard for me to just write it out by hand.

praeclarum avatar Jul 08 '21 19:07 praeclarum

It's not about it being hard to use a reference, it's about good practice. After all, those are constants that are well-defined by the compiler itself, handed over to you publicly.

Rekkonnect avatar Jul 08 '21 19:07 Rekkonnect