Skip to content

Commit de2fc26

Browse files
Nikolay PianikovNikolayPianikov
authored andcommitted
Update TeamCity config, cllect changes before generation, update README.md
1 parent cce7ba2 commit de2fc26

File tree

6 files changed

+54
-46
lines changed

6 files changed

+54
-46
lines changed

.teamcity/settings.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ object DeployBuildType: BuildType({
8989
}
9090
vcs { root(Repo) }
9191
steps {
92-
/*csharpScript {
92+
csharpScript {
9393
name = "Evaluate a next NuGet package version"
9494
content = Settings.getNextVersionScript
9595
arguments = "%packageId%"
96-
}*/
96+
}
9797

9898
for (version in Settings.versions) {
9999
val versionArgs = version.args
@@ -127,12 +127,12 @@ object DeployBuildType: BuildType({
127127
projects = "Merge.csproj"
128128
}
129129

130-
/*dotnetNugetPush {
130+
dotnetNugetPush {
131131
name = "Push to NuGet"
132132
packages = "%packagePath%"
133133
serverUrl = "https://api.nuget.org/v3/index.json"
134134
apiKey = "%NuGetKey%"
135-
}*/
135+
}
136136
}
137137

138138
failureConditions {

Directory.Build.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<RepositoryUrl>https://github.com/DevTeam/Immutype.git</RepositoryUrl>
1212
<Copyright>Copyright (C) 2021 Nikolay Pianikov</Copyright>
1313

14-
<!--<AnalyzerRoslynVersion Condition="'$(AnalyzerRoslynVersion)'==''">4.0</AnalyzerRoslynVersion>
15-
<AnalyzerRoslynPackageVersion Condition="'$(AnalyzerRoslynPackageVersion)'==''">4.0.1</AnalyzerRoslynPackageVersion>-->
16-
<AnalyzerRoslynVersion Condition="'$(AnalyzerRoslynVersion)'==''">3.8</AnalyzerRoslynVersion>
17-
<AnalyzerRoslynPackageVersion Condition="'$(AnalyzerRoslynPackageVersion)'==''">3.8.0</AnalyzerRoslynPackageVersion>
14+
<AnalyzerRoslynVersion Condition="'$(AnalyzerRoslynVersion)'==''">4.0</AnalyzerRoslynVersion>
15+
<AnalyzerRoslynPackageVersion Condition="'$(AnalyzerRoslynPackageVersion)'==''">4.0.1</AnalyzerRoslynPackageVersion>
16+
<!--<AnalyzerRoslynVersion Condition="'$(AnalyzerRoslynVersion)'==''">3.8</AnalyzerRoslynVersion>
17+
<AnalyzerRoslynPackageVersion Condition="'$(AnalyzerRoslynPackageVersion)'==''">3.8.0</AnalyzerRoslynPackageVersion>-->
1818
<DefineConstants Condition="'$(AnalyzerRoslynVersion)'=='3.8'">$(DefineConstants);ROSLYN38</DefineConstants>
1919
<DefineConstants Condition="'$(AnalyzerRoslynVersion)'=='4.0'">$(DefineConstants);ROSLYN40</DefineConstants>
2020
</PropertyGroup>

Immutype/Core/SourceBuilder.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// ReSharper disable MemberCanBeMadeStatic.Global
33
// ReSharper disable LoopCanBeConvertedToQuery
44
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
5+
// ReSharper disable InvertIf
56
namespace Immutype.Core
67
{
78
using System.Collections.Generic;
@@ -27,28 +28,31 @@ public SourceBuilder(
2728
public IEnumerable<Source> Build(IEnumerable<SyntaxTree> trees, CancellationToken cancellationToken) =>
2829
from syntaxTree in trees
2930
where !cancellationToken.IsCancellationRequested
30-
from recordSyntax in syntaxTree.GetRoot().DescendantNodes().OfType<TypeDeclarationSyntax>()
31+
from typeDeclarationSyntax in syntaxTree.GetRoot().DescendantNodes().OfType<TypeDeclarationSyntax>()
3132
where !cancellationToken.IsCancellationRequested
32-
where _typeSyntaxFilter.IsAccepted(recordSyntax)
33-
from source in Build(recordSyntax, cancellationToken) select source;
33+
where _typeSyntaxFilter.IsAccepted(typeDeclarationSyntax)
34+
from source in Build(typeDeclarationSyntax, cancellationToken)
35+
select source;
3436

3537
public IEnumerable<Source> Build(TypeDeclarationSyntax typeDeclarationSyntax, CancellationToken cancellationToken)
3638
{
3739
IReadOnlyList<ParameterSyntax>? parameters = typeDeclarationSyntax switch
3840
{
3941
RecordDeclarationSyntax recordDeclarationSyntax => recordDeclarationSyntax.ParameterList?.Parameters,
4042
_ => (
41-
from ctor in typeDeclarationSyntax.Members.OfType<ConstructorDeclarationSyntax>()
42-
where !cancellationToken.IsCancellationRequested
43-
where ctor.Modifiers.Any(i => i.IsKind(SyntaxKind.PublicKeyword) || i.IsKind(SyntaxKind.InternalKeyword)) || !ctor.Modifiers.Any()
44-
orderby ctor.ParameterList.Parameters.Count descending select ctor
45-
)
43+
from ctor in typeDeclarationSyntax.Members.OfType<ConstructorDeclarationSyntax>()
44+
where !cancellationToken.IsCancellationRequested
45+
where ctor.Modifiers.Any(i => i.IsKind(SyntaxKind.PublicKeyword) || i.IsKind(SyntaxKind.InternalKeyword)) || !ctor.Modifiers.Any()
46+
orderby ctor.ParameterList.Parameters.Count descending
47+
select ctor)
4648
.FirstOrDefault()
4749
?.ParameterList
4850
.Parameters
4951
};
5052

51-
return parameters != default ? _unitFactory.Create(typeDeclarationSyntax, parameters, cancellationToken) : Enumerable.Empty<Source>();
53+
return parameters != default
54+
? _unitFactory.Create(typeDeclarationSyntax, parameters, cancellationToken)
55+
: Enumerable.Empty<Source>();
5256
}
5357
}
5458
}

Immutype/SourceGenerator4.0.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
2323
var typeSyntaxFilter = Composer.ResolveITypeSyntaxFilter();
2424
var changes = context.SyntaxProvider.CreateSyntaxProvider(
2525
(node, token) => node is TypeDeclarationSyntax typeDeclarationSyntax && typeSyntaxFilter.IsAccepted(typeDeclarationSyntax),
26-
(syntaxContext, token) => (TypeDeclarationSyntax)syntaxContext.Node);
26+
(syntaxContext, token) => (TypeDeclarationSyntax)syntaxContext.Node)
27+
.Collect();
2728

2829
context.RegisterSourceOutput(changes, (ctx, syntax) =>
2930
{
30-
foreach (var source in sourceBuilder.Build(syntax, ctx.CancellationToken))
31+
foreach (var typeDeclarationSyntax in syntax)
3132
{
32-
ctx.AddSource(source.HintName, source.Code);
33+
foreach (var source in sourceBuilder.Build(typeDeclarationSyntax, ctx.CancellationToken))
34+
{
35+
ctx.AddSource(source.HintName, source.Code);
36+
}
3337
}
3438
});
3539
}

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
# Pure DI for .NET
1+
# Immutype
22

33
[![NuGet](https://buildstats.info/nuget/Immutype)](https://www.nuget.org/packages/Immutype)
44
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
55
[<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)
66

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.
88

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:
1010

1111
| Method | Purpose |
1212
|------- | ------- |
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 |
1717

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:
1919

2020
| Method | Purpose |
2121
|------- | ------- |
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__* |
2424

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
2828

2929
_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:
3030

README_BODY.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
# Pure DI for .NET
1+
# Immutype
22

33
[![NuGet](https://buildstats.info/nuget/Immutype)](https://www.nuget.org/packages/Immutype)
44
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
55
[<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)
66

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.
88

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:
1010

1111
| Method | Purpose |
1212
|------- | ------- |
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 |
1717

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:
1919

2020
| Method | Purpose |
2121
|------- | ------- |
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__* |
2424

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
2828

2929
_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:
3030

0 commit comments

Comments
 (0)