Skip to content

Commit

Permalink
Bumped version v1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
FaustVX committed Dec 1, 2023
1 parent 4f0fa6d commit 0f138a7
Show file tree
Hide file tree
Showing 69 changed files with 184 additions and 183 deletions.
2 changes: 1 addition & 1 deletion ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DontUseAttribute : Attribute
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
Expand Down
2 changes: 1 addition & 1 deletion PrimaryParameter.SG/Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static class Diagnostics
public static readonly DiagnosticDescriptor ErrorWhenAccessingPrimaryParameter = new(
id: "PC01",
title: "Accessing a Primary Parameter",
messageFormat: "Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DontUse] attribute, use {1}",
messageFormat: "Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DoNotUse] attribute, use {1}",
category: "tests",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);
Expand Down
16 changes: 8 additions & 8 deletions PrimaryParameter.SG/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ sealed class PropertyAttribute : Attribute
}
""");
ctx.AddSource("DontUseAttribute.g.cs", """
ctx.AddSource("DoNotUseAttribute.g.cs", """
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DontUseAttribute : Attribute
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
Expand All @@ -92,7 +92,7 @@ sealed class DontUseAttribute : Attribute
var paramDeclarations = context.SyntaxProvider
.CreateSyntaxProvider(
predicate: IsSyntaxTargetForGeneration, // select params with attributes
transform: GetSemanticTargetForGeneration) // select the param with the [Field], [RefField], [Property] or [DontUse] attribute
transform: GetSemanticTargetForGeneration) // select the param with the [Field], [RefField], [Property] or [DoNotUse] attribute
.Where(static m => m is not null)!; // filter out attributed parameters that we don't care about

// Combine the selected parameters with the `Compilation`
Expand Down Expand Up @@ -170,8 +170,8 @@ static bool IsSyntaxTargetForGeneration(SyntaxNode s, CancellationToken token)

var fullName = attributeContainingTypeSymbol.ToDisplayString();

// Is the attribute the [Field], [RefField], [Property] or [DontUse] attribute?
if (fullName is "PrimaryParameter.SG.FieldAttribute" or "PrimaryParameter.SG.RefFieldAttribute" or "PrimaryParameter.SG.PropertyAttribute" or "PrimaryParameter.SG.DontUseAttribute")
// Is the attribute the [Field], [RefField], [Property] or [DoNotUse] attribute?
if (fullName is "PrimaryParameter.SG.FieldAttribute" or "PrimaryParameter.SG.RefFieldAttribute" or "PrimaryParameter.SG.PropertyAttribute" or "PrimaryParameter.SG.DoNotUseAttribute")
{
if (parameterSyntax is not { Parent.Parent: ClassDeclarationSyntax or StructDeclarationSyntax })
{
Expand Down Expand Up @@ -232,10 +232,10 @@ static IEnumerable<Parameter> GetTypesToGenerate(Compilation compilation, IEnume
if ((compilation.GetTypeByMetadataName("PrimaryParameter.SG.FieldAttribute"),
compilation.GetTypeByMetadataName("PrimaryParameter.SG.RefFieldAttribute"),
compilation.GetTypeByMetadataName("PrimaryParameter.SG.PropertyAttribute"),
compilation.GetTypeByMetadataName("PrimaryParameter.SG.DontUseAttribute")) is not (INamedTypeSymbol fieldAttributeSymbol,
compilation.GetTypeByMetadataName("PrimaryParameter.SG.DoNotUseAttribute")) is not (INamedTypeSymbol fieldAttributeSymbol,
INamedTypeSymbol refFieldAttributeSymbol,
INamedTypeSymbol propertyAttributeSymbol,
INamedTypeSymbol dontUseAttributeSymbol))
INamedTypeSymbol doNotUseAttributeSymbol))
{
// If this is null, the compilation couldn't find the marker attribute type
// which suggests there's something very wrong! Bail out..
Expand Down Expand Up @@ -311,7 +311,7 @@ static IEnumerable<Parameter> GetTypesToGenerate(Compilation compilation, IEnume
else if (!memberNames.Add(new GenerateProperty(name, setter, scope, format, type)))
context.ReportDiagnostic(Diagnostic.Create(Diagnostics.WarningOnUsedMember, nameLocation, name));
}
else if (dontUseAttributeSymbol.Equals(objectCreationOperation.Type, SymbolEqualityComparer.Default))
else if (doNotUseAttributeSymbol.Equals(objectCreationOperation.Type, SymbolEqualityComparer.Default))
allowInMemberInit &= GetAttributeProperty<bool>(operation, "AllowInMemberInit", out _, defaultValue: true);
}
var parameter = new Parameter(GetNamespace(containingType), ParentClass.GetParentClasses(containingType)!, paramSyntax.Identifier.Text, semanticModel.GetTypeInfo(paramSyntax.Type!).Type!.ToDisplayString(), [.. memberNames]);
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 @@ -30,7 +30,7 @@

<PropertyGroup>
<PackageId>FaustVX.PrimaryParameter.SG</PackageId>
<Version>1.3.2</Version>
<Version>1.3.3</Version>
<Authors>FaustVX</Authors>
<RepositoryUrl>https://github.com/FaustVX/PrimaryParameter</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
30 changes: 15 additions & 15 deletions PrimaryParameter.Tests/PrimaryParameterSnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public partial class C([Property] int i)
}

[Fact]
public Task GeneratesPC01WithDontUse()
public Task GeneratesPC01WithDoNotUse()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse] int i)
public class C([DoNotUse] int i)
{
int M() => i;
}
Expand All @@ -158,12 +158,12 @@ public class C([DontUse] int i)
}

[Fact]
public Task DontGeneratesPC01WithDontUseOnMember_Simple()
public Task DontGeneratesPC01WithDoNotUseOnMember_Simple()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse(AllowInMemberInit = true)] int i)
public class C([DoNotUse(AllowInMemberInit = true)] int i)
{
int M = i;
}
Expand All @@ -174,12 +174,12 @@ public class C([DontUse(AllowInMemberInit = true)] int i)
}

[Fact]
public Task DontGeneratesPC01WithDontUseOnMember_Complex()
public Task DontGeneratesPC01WithDoNotUseOnMember_Complex()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse(AllowInMemberInit = true)] int i)
public class C([DoNotUse(AllowInMemberInit = true)] int i)
{
string L = i.ToString();
}
Expand All @@ -190,12 +190,12 @@ public class C([DontUse(AllowInMemberInit = true)] int i)
}

[Fact]
public Task DontGeneratesPC01WithDontUseOnPropertyInitializer()
public Task DontGeneratesPC01WithDoNotUseOnPropertyInitializer()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse(AllowInMemberInit = true)] int i)
public class C([DoNotUse(AllowInMemberInit = true)] int i)
{
string L { get; } = i.ToString();
}
Expand All @@ -206,12 +206,12 @@ public class C([DontUse(AllowInMemberInit = true)] int i)
}

[Fact]
public Task DoGeneratesPC01WithDontUseOnPropertyBody()
public Task DoGeneratesPC01WithDoNotUseOnPropertyBody()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse] int i)
public class C([DoNotUse] int i)
{
int M => i;
}
Expand All @@ -222,12 +222,12 @@ public class C([DontUse] int i)
}

[Fact]
public Task DoGeneratesPC01WithDontUseOnPropertyGet()
public Task DoGeneratesPC01WithDoNotUseOnPropertyGet()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse] int i)
public class C([DoNotUse] int i)
{
int M
{
Expand All @@ -241,12 +241,12 @@ int M
}

[Fact]
public Task DoGeneratesPC01WithDontUseOnMember()
public Task DoGeneratesPC01WithDoNotUseOnMember()
{
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse(AllowInMemberInit = false)] int i)
public class C([DoNotUse(AllowInMemberInit = false)] int i)
{
int M = i;
}
Expand All @@ -262,7 +262,7 @@ public Task DontNeedPartialModifierOnType()
// The source code to test
var source = """
using PrimaryParameter.SG;
public class C([DontUse] int i)
public class C([DoNotUse] int i)
{ }
""";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//HintName: DontUseAttribute.g.cs
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DontUseAttribute : Attribute
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//HintName: DontUseAttribute.g.cs
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DontUseAttribute : Attribute
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//HintName: DontUseAttribute.g.cs
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DontUseAttribute : Attribute
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//HintName: DontUseAttribute.g.cs
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DontUseAttribute : Attribute
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Severity: Error,
WarningLevel: 0,
Location: : (3,12)-(3,13),
MessageFormat: Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DontUse] attribute, use {1},
Message: Can't access a primary parameter ('i') with a [Field] [RefField], [Property] or [DontUse] attribute, use ,
MessageFormat: Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DoNotUse] attribute, use {1},
Message: Can't access a primary parameter ('i') with a [Field] [RefField], [Property] or [DoNotUse] attribute, use ,
Category: tests
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Severity: Error,
WarningLevel: 0,
Location: : (3,13)-(3,14),
MessageFormat: Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DontUse] attribute, use {1},
Message: Can't access a primary parameter ('i') with a [Field] [RefField], [Property] or [DontUse] attribute, use ,
MessageFormat: Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DoNotUse] attribute, use {1},
Message: Can't access a primary parameter ('i') with a [Field] [RefField], [Property] or [DoNotUse] attribute, use ,
Category: tests
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Severity: Error,
WarningLevel: 0,
Location: : (5,15)-(5,16),
MessageFormat: Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DontUse] attribute, use {1},
Message: Can't access a primary parameter ('i') with a [Field] [RefField], [Property] or [DontUse] attribute, use ,
MessageFormat: Can't access a primary parameter ('{0}') with a [Field] [RefField], [Property] or [DoNotUse] attribute, use {1},
Message: Can't access a primary parameter ('i') with a [Field] [RefField], [Property] or [DoNotUse] attribute, use ,
Category: tests
}
]
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//HintName: DoNotUseAttribute.g.cs
// <auto-generated/>
using global::System;
namespace PrimaryParameter.SG
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
sealed class DoNotUseAttribute : Attribute
{
public bool AllowInMemberInit { get; init; }
}
}

This file was deleted.

Loading

0 comments on commit 0f138a7

Please sign in to comment.