https://github.com/emik03/emik.sourcegenerators.implicit
Source-generates implicit conversion operators that map to the respective constructors.
https://github.com/emik03/emik.sourcegenerators.implicit
Last synced: 6 months ago
JSON representation
Source-generates implicit conversion operators that map to the respective constructors.
- Host: GitHub
- URL: https://github.com/emik03/emik.sourcegenerators.implicit
- Owner: Emik03
- License: mpl-2.0
- Created: 2023-08-07T18:21:54.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-15T21:42:31.000Z (almost 2 years ago)
- Last Synced: 2025-01-13T02:08:26.548Z (over 1 year ago)
- Language: C#
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Emik.SourceGenerators.Implicit
[](https://www.nuget.org/packages/Emik.SourceGenerators.Implicit)
[](https://github.com/Emik03/Emik.SourceGenerators.Implicit/blob/main/LICENSE)
Source-generates implicit conversion operators that map to the respective constructors.
This project has a dependency to [Emik.Morsels](https://github.com/Emik03/Emik.Morsels), if you are building this
project, refer to its [README](https://github.com/Emik03/Emik.Morsels/blob/main/README.md) first.
---
- [Example](#example)
- [Contribute](#contribute)
- [License](#license)
---
## Example
```csharp
A singularValuesWork = 1; // Valid!
A tuplesWorkToo = (2, 3); // Valid!
// Won't generate: annotated NoImplicitOperator.
// A butThisDoesNot = (4, 5, 6);
// Won't generate: would change visibility of constructor.
// A andNeitherDoesThis = (7, 8, 9, 10);
// Won't generate: annotated NoImplicitOperator.
// B andNeitherDoesThisToo = 11;
// B orThis = (12, 13);
public class A(int i)
{
public A(int i, int j)
: this(0) { }
[NoImplicitOperator]
public A(int i, int j, int k)
: this(0) { }
private A(int i, int j, int k, int l)
: this(0) { }
}
[NoImplicitOperator]
public class B(int i)
{
public B(int i, int j)
: this(0) { }
}
```
## Contribute
Issues and pull requests are welcome to help this repository be the best it can be.
## License
This repository falls under the [MPL-2 license](https://www.mozilla.org/en-US/MPL/2.0/).