|
1 | | -# Pure DI for .NET |
| 1 | +# Immutype |
2 | 2 |
|
3 | 3 | [](https://www.nuget.org/packages/Immutype) |
4 | 4 | [](LICENSE) |
5 | 5 | [<img src="http://tcavs2015.cloudapp.net/app/rest/builds/buildType:(id:DevTeam_Immutype_BuildAndTestBuildType)/statusIcon"/>](http://tcavs2015.cloudapp.net/viewType.html?buildTypeId=DevTeam_Immutype_BuildAndTestBuildType&guest=1) |
6 | 6 |
|
7 | | -_Immutype_ is [.NET code generator](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview). It generates extension methods for records, structures, and classes marked by the attribute *__[Immutype.Target]__* to easily use instances of these types as immutable. _Immutype_ chooses a general constructor for records or a constructor with maximum number of parameters ofr other types.and use it to create a modified clone for an instance using generated static extension methods per each constructor parameter. |
| 7 | +_Immutype_ is [.NET code generator](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview) creating extension methods for records, structures, and classes marked by the attribute `````[Immutype.Target]````` to efficiently operate with instances of these types like with immutable ones. |
8 | 8 |
|
9 | | -For instance, for the type Foo for the constructor parameter *__values__* of type *__IEnumerable<int>__* following extension methods are generated: |
| 9 | +For instance, for the type Foo for the constructor parameter *__values__* of type ```IEnumerable<int>``` following extension methods are generated: |
10 | 10 |
|
11 | 11 | | Method | Purpose | |
12 | 12 | |------- | ------- | |
13 | | -| *__Foo WithValues(this Foo it, params int[] values)__* | replaces values by the new ones using a method with variable number of arguments | |
14 | | -| *__Foo WithValues(this Foo it, IEnumerable<int> values)__* | replaces values by the new ones | |
15 | | -| *__Foo AddValues(this Foo it, params int[] values)__* | adds values using a method with variable number of arguments | |
16 | | -| *__Foo RemoveValues(this Foo it, params int[] values)__* | removes values using a method with variable number of arguments | |
| 13 | +| ```Foo WithValues(this Foo it, params int[] values)``` | replaces values by the new ones using a method with variable number of arguments | |
| 14 | +| ```Foo WithValues(this Foo it, IEnumerable<int> values)``` | replaces values by the new ones | |
| 15 | +| ```Foo AddValues(this Foo it, params int[] values)``` | adds values using a method with variable number of arguments | |
| 16 | +| ```Foo RemoveValues(this Foo it, params int[] values)``` | removes values using a method with variable number of arguments | |
17 | 17 |
|
18 | | -For the type Foo for the constructor parameter *__value__* of other types, like *__int__*, with default value *__99__* following extension methods are generated: |
| 18 | +For the type Foo for the constructor parameter *__value__* of other types, like ```int```, with default value ```99``` following extension methods are generated: |
19 | 19 |
|
20 | 20 | | Method | Purpose | |
21 | 21 | |------- | ------- | |
22 | | -| *__Foo WithValue(this Foo it, int value)__* | replaces a value by the new one | |
23 | | -| *__Foo WithDefaultValue(this Foo it)__* | replaces a value by the default value *__99__* | |
| 22 | +| ```Foo WithValue(this Foo it, int value)``` | replaces a value by the new one | |
| 23 | +| ```Foo WithDefaultValue(this Foo it)``` | replaces a value by the default value *__99__* | |
24 | 24 |
|
25 | | -The extensions methods above are generating automatically for each *__public__* or *__internal__* type, like *__Foo__* marked by the attribute *__[Immutype.Target]__* in the static class named as *__FooExtensions__*. This generated class *__FooExtensions__* is static, has the same accessibility level and the same namespace like a target class *__Foo__*. Each generated static extension method has two attributes: |
26 | | -- [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - to improve performance |
27 | | -- [Pure] - to indicates that this method is pure, that is, it does not make any visible state changes |
| 25 | +The extensions methods above are generating automatically for each ```public``` or ```internal``` type, like *__Foo__* marked by the attribute ```[Immutype.Target]``` in the static class named as *__FooExtensions__*. This generated class *__FooExtensions__* is static, has the same accessibility level and the same namespace like a target class *__Foo__*. Each generated static extension method has two attributes: |
| 26 | +- ```[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]``` - to improve performance |
| 27 | +- ```[Pure]``` - to indicates that this method is pure, that is, it does not make any visible state changes |
28 | 28 |
|
29 | 29 | _Immutype_ supports nullable [reference](https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references) and [value](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types) types and the following list of enumerable types: |
30 | 30 |
|
|
0 commit comments