diff --git a/BeaKona.AutoInterfaceGenerator/BeaKona.AutoInterfaceGenerator.csproj b/BeaKona.AutoInterfaceGenerator/BeaKona.AutoInterfaceGenerator.csproj
index 92e65cf..94561fa 100644
--- a/BeaKona.AutoInterfaceGenerator/BeaKona.AutoInterfaceGenerator.csproj
+++ b/BeaKona.AutoInterfaceGenerator/BeaKona.AutoInterfaceGenerator.csproj
@@ -13,7 +13,7 @@
https://github.com/beakona/AutoInterface
git
$(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput
- 1.0.39
+ 1.0.40
true
true
diff --git a/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs b/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs
index ec4b62a..dafa0c9 100644
--- a/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs
+++ b/BeaKona.AutoInterfaceGenerator/CSharpCodeTextWriter.cs
@@ -214,7 +214,7 @@ public void WriteParameterAttributes(SourceBuilder builder, ScopeInfo scope, IPa
foreach (var attribute in GetParameterAttributes(parameter))
{
- this.WriteAttribute(builder, scope, attribute);
+ this.WriteAttribute(builder, scope, attribute, false);
any = true;
}
@@ -288,7 +288,7 @@ private void WriteForwardAttributes(SourceBuilder builder, ScopeInfo scope, ISym
foreach (var attribute in this.GetForwardAttributes(member))
{
builder.AppendIndentation();
- this.WriteAttribute(builder, scope, attribute);
+ this.WriteAttribute(builder, scope, attribute, true);
builder.AppendLine();
}
}
@@ -300,60 +300,69 @@ private void WriteReturnAttributes(SourceBuilder builder, ScopeInfo scope, IEnum
foreach (var attribute in attributes)
{
builder.AppendIndentation();
- this.WriteAttribute(builder, scope, attribute, true);
+ this.WriteAttribute(builder, scope, attribute, false, true);
builder.AppendLine();
}
}
}
- private void WriteAttributeReference(SourceBuilder builder, ScopeInfo scope, AttributeData attribute)
+ private void WriteAttributeReference(SourceBuilder builder, ScopeInfo scope, AttributeData attribute, bool strict)
{
- if (attribute.AttributeClass is INamedTypeSymbol attributeTypeSymbol)
+ if (attribute.AttributeClass is INamedTypeSymbol attributeClass)
{
- if (Helpers.IsPublicAccess(attributeTypeSymbol) == false)
- {
- builder.MissingAttributesRegistry.Add(attributeTypeSymbol);
- }
+ bool publicAccess = Helpers.IsPublicAccess(attributeClass);
- this.WriteTypeReference(builder, attributeTypeSymbol, scope);
-
- if (attribute.ConstructorArguments.Any() || attribute.NamedArguments.Any())
+ if (strict || publicAccess)
{
- builder.Append('(');
+ if (publicAccess == false)
+ {
+ builder.MissingAttributesRegistry.Add(attributeClass);
+ }
- bool first = true;
+ this.WriteTypeReference(builder, attributeClass, scope);
- foreach (var constructorArgument in attribute.ConstructorArguments)
+ if (attribute.ConstructorArguments.Any() || attribute.NamedArguments.Any())
{
- if (first)
- {
- first = false;
- }
- else
- {
- builder.Append(", ");
- }
+ builder.Append('(');
- builder.Append(constructorArgument.ToCSharpString());
- }
+ bool first = true;
- foreach (var namedArgument in attribute.NamedArguments)
- {
- if (first)
+ foreach (var constructorArgument in attribute.ConstructorArguments)
{
- first = false;
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ builder.Append(", ");
+ }
+
+ builder.Append(constructorArgument.ToCSharpString());
}
- else
+
+ foreach (var namedArgument in attribute.NamedArguments)
{
- builder.Append(", ");
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ builder.Append(", ");
+ }
+
+ builder.Append(namedArgument.Key);
+ builder.Append(" = ");
+ builder.Append(namedArgument.Value.ToCSharpString());
}
- builder.Append(namedArgument.Key);
- builder.Append(" = ");
- builder.Append(namedArgument.Value.ToCSharpString());
+ builder.Append(')');
}
-
- builder.Append(')');
+ }
+ else
+ {
+ builder.Append(attribute.ToString());
}
}
else
@@ -362,14 +371,14 @@ private void WriteAttributeReference(SourceBuilder builder, ScopeInfo scope, Att
}
}
- private void WriteAttribute(SourceBuilder builder, ScopeInfo scope, AttributeData attribute, bool isReturn = false)
+ private void WriteAttribute(SourceBuilder builder, ScopeInfo scope, AttributeData attribute, bool strict, bool isReturn = false)
{
builder.Append('[');
if (isReturn)
{
builder.Append("return: ");
}
- this.WriteAttributeReference(builder, scope, attribute);
+ this.WriteAttributeReference(builder, scope, attribute, strict);
builder.Append(']');
}