Skip to content

Commit

Permalink
add NoCommands option to SiaPropertyAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sicusa committed Oct 29, 2023
1 parent 1254575 commit fd83aea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sia.CodeGenerators/SiaPropertyGenerator.Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Sia;
Inherited = false, AllowMultiple = false)]
internal sealed class SiaPropertyAttribute : global::System.Attribute
{
public bool NoCommands { get; set; }
public bool GenerateSetCommand { get; set; } = true;
public bool GenerateAddItemCommand { get; set; } = true;
public bool GenerateSetItemCommand { get; set; } = true;
Expand Down
4 changes: 3 additions & 1 deletion Sia.CodeGenerators/SiaPropertyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ private static string GenerateFileName(CodeGenerationInfo info)
private static void GenerateSource(CodeGenerationInfo info, IndentedTextWriter source)
{
var componentType = info.ComponentType;

using (GenerateInNamespace(source, info.Namespace)) {
using (GenerateInPartialTypes(source, info.ParentTypes.Append(componentType))) {
var compTypeStr = componentType.Identifier.ToString();
Expand All @@ -119,6 +118,9 @@ public static void GeneratePropertyCommands(
IndentedTextWriter source, in PropertyInfo property,
string componentType, TypeParameterListSyntax? componentTypeParams = null)
{
if (property.GetArgument("NoCommands", false)) {
return;
}
if (property.GetArgument("GenerateSetCommand", true)) {
GenerateSetCommand(source, property, componentType, componentTypeParams);
}
Expand Down

0 comments on commit fd83aea

Please sign in to comment.