Skip to content

Commit

Permalink
Bumped version v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
FaustVX committed Nov 19, 2023
1 parent 48a29ca commit 4a05260
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FaustVX.PrimaryParameter.SG" Version="1.3.1" />
<PackageReference Include="FaustVX.PrimaryParameter.SG" Version="1.3.2" />
<!-- <ProjectReference Include="..\PrimaryParameter.SG\PrimaryParameter.SG.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="All" /> -->
</ItemGroup>

Expand Down
10 changes: 9 additions & 1 deletion PrimaryParameter.SG/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,15 @@ static IEnumerable<Parameter> GetTypesToGenerate(Compilation compilation, IEnume
}

static void GenerateFiles(IEnumerable<Parameter> parameters, SourceProductionContext context)
=> context.AddSource("FaustVX.PrimaryParameter.SG.g.cs", string.Concat(parameters.Select(static item => GetResource(item.Namespace, item.TypeName, item.FieldNames.Select(n => n.GenerateMember(item))))));
{
context.AddSource("FaustVX.PrimaryParameter.SG.g.cs", string.Concat(parameters.Where(Where).Select(Select)));

static bool Where(Parameter parameter)
=> parameter.FieldNames.Length > 0;

static string Select(Parameter parameter)
=> GetResource(parameter.Namespace, parameter.TypeName, parameter.FieldNames.Select(n => n.GenerateMember(parameter)));
}

static string GetResource(string nameSpace, ParentClass? parentClass, IEnumerable<string> inner)
{
Expand Down
2 changes: 1 addition & 1 deletion PrimaryParameter.SG/PrimaryParameter.SG.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>FaustVX.PrimaryParameter.SG</PackageId>
<Version>1.3.1</Version>
<Version>1.3.2</Version>
<Authors>FaustVX</Authors>
<RepositoryUrl>https://github.com/FaustVX/PrimaryParameter</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
28 changes: 21 additions & 7 deletions PrimaryParameter.Tests/PrimaryParameterSnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public Task GeneratesPC01WithDontUse()
// The source code to test
var source = """
using PrimaryParameter.SG;
public partial class C([DontUse] int i)
public class C([DontUse] int i)
{
int M() => i;
}
Expand All @@ -163,7 +163,7 @@ public Task DontGeneratesPC01WithDontUseOnMember_Simple()
// The source code to test
var source = """
using PrimaryParameter.SG;
public partial class C([DontUse(AllowInMemberInit = true)] int i)
public class C([DontUse(AllowInMemberInit = true)] int i)
{
int M = i;
}
Expand All @@ -179,7 +179,7 @@ public Task DontGeneratesPC01WithDontUseOnMember_Complex()
// The source code to test
var source = """
using PrimaryParameter.SG;
public partial class C([DontUse(AllowInMemberInit = true)] int i)
public class C([DontUse(AllowInMemberInit = true)] int i)
{
string L = i.ToString();
}
Expand All @@ -195,7 +195,7 @@ public Task DontGeneratesPC01WithDontUseOnPropertyInitializer()
// The source code to test
var source = """
using PrimaryParameter.SG;
public partial class C([DontUse(AllowInMemberInit = true)] int i)
public class C([DontUse(AllowInMemberInit = true)] int i)
{
string L { get; } = i.ToString();
}
Expand All @@ -211,7 +211,7 @@ public Task DoGeneratesPC01WithDontUseOnPropertyBody()
// The source code to test
var source = """
using PrimaryParameter.SG;
public partial class C([DontUse] int i)
public class C([DontUse] int i)
{
int M => i;
}
Expand All @@ -227,7 +227,7 @@ public Task DoGeneratesPC01WithDontUseOnPropertyGet()
// The source code to test
var source = """
using PrimaryParameter.SG;
public partial class C([DontUse] int i)
public class C([DontUse] int i)
{
int M
{
Expand All @@ -246,7 +246,7 @@ public Task DoGeneratesPC01WithDontUseOnMember()
// The source code to test
var source = """
using PrimaryParameter.SG;
public partial class C([DontUse(AllowInMemberInit = false)] int i)
public class C([DontUse(AllowInMemberInit = false)] int i)
{
int M = i;
}
Expand All @@ -255,4 +255,18 @@ public partial class C([DontUse(AllowInMemberInit = false)] int i)
// Pass the source code to our helper and snapshot test the output
return TestHelper.Verify(source);
}

[Fact]
public Task DontNeedPartialModifierOnType()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse] int i)
{ }
""";

// Pass the source code to our helper and snapshot test the output
return TestHelper.Verify(source);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
// <auto-generated/>
partial class C
{
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
// <auto-generated/>
partial class C
{
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
// <auto-generated/>
partial class C
{
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
// <auto-generated/>
partial class C
{
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
// <auto-generated/>
partial class C
{
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
// <auto-generated/>
partial class C
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//HintName: DontUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DontUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//HintName: FieldAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = true)]
sealed class FieldAttribute : Attribute
{
public string Name { get; init; }
public string AssignFormat { get; init; }
public Type Type { get; init; }
public bool IsReadonly { get; init; }
public string Scope { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//HintName: PropertyAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = true)]
sealed class PropertyAttribute : Attribute
{
public string Name { get; init; }
public string AssignFormat { get; init; }
public Type Type { get; init; }
public string Setter { get; init; }
public string Scope { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//HintName: RefFieldAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = true)]
sealed class RefFieldAttribute : Attribute
{
public string Name { get; init; }
public string Scope { get; init; }
public bool IsReadonlyRef { get; init; }
public bool IsRefReadonly { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
//HintName: FaustVX.PrimaryParameter.SG.g.cs
// <auto-generated/>
partial class C
{
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ You can type as many attributes as you want on a single parameter (Except for `D
## Versions
|Version|Date|Comments|
|-------|----|--------|
|v1.3.1|25/08/2023|fix a bug with member initialization|
|v1.3.2|19/11/2023|Don't generate the partial generated type if not needed|
|v1.3.1|19/11/2023|Fix a bug with member initialization|
|v1.3.0|19/11/2023|Added `DontUseAttribute`<br/>Add a code-fix for `CS0282`<br/>Changed `PropertyAttribute.WithInit` to `PropertyAttribute.Setter`|
|v1.2.0|25/08/2023|Support for default values customization|
|v1.1.0|15/08/2023|[dotnet/roslyn#67371](https://github.com/dotnet/roslyn/issues/67371) fixed<br/>(related to `v0.4.6`)|
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
- `set`
- `init`
- [x] Add `// <auto-generated/>` in `FaustVX.PrimaryParameter.SG.g.cs`
- [x] Don't generate empty partial types

0 comments on commit 4a05260

Please sign in to comment.