Skip to content

Commit 0e6d2d2

Browse files
authored
Merge pull request #165 from chickensoft-games/fix/bindings
fix: allow bindings to be added and removed during bindings invocations
2 parents 4969094 + 45021f3 commit 0e6d2d2

File tree

22 files changed

+281
-151
lines changed

22 files changed

+281
-151
lines changed

.editorconfig

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ trim_trailing_whitespace = true
5151
# File Extension Settings
5252
##########################################
5353

54+
# GDScript Files
55+
[*.gd]
56+
indent_style = tab
57+
indent_size = 2
58+
5459
# Visual Studio Solution Files
5560
[*.sln]
5661
indent_style = tab
@@ -91,7 +96,7 @@ end_of_line = lf
9196
[Makefile]
9297
indent_style = tab
9398

94-
[*_Generated.cs, *.g.cs, *.generated.cs]
99+
[*{_Generated.cs,.g.cs,.generated.cs}]
95100
# Ignore a lack of documentation for generated code. Doesn't apply to builds,
96101
# just to viewing generation output.
97102
dotnet_diagnostic.CS1591.severity = none
@@ -100,7 +105,7 @@ dotnet_diagnostic.CS1591.severity = none
100105
# Default .NET Code Style Severities
101106
##########################################
102107

103-
[*.{cs,csx,cake,vb,vbx}]
108+
[*.cs]
104109
# Default Severity for all .NET Code Style rules below
105110
dotnet_analyzer_diagnostic.severity = warning
106111

@@ -109,7 +114,6 @@ dotnet_analyzer_diagnostic.severity = warning
109114
##########################################
110115

111116
# .NET Style Rules
112-
[*.{cs,csx,cake,vb,vbx}]
113117

114118
# "this." and "Me." qualifiers
115119
dotnet_style_qualification_for_field = false
@@ -122,7 +126,7 @@ dotnet_style_predefined_type_for_locals_parameters_members = true:warning
122126
dotnet_style_predefined_type_for_member_access = true:warning
123127

124128
# Modifier preferences
125-
dotnet_style_require_accessibility_modifiers = always:warning
129+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
126130
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
127131
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:warning
128132
dotnet_style_readonly_field = true:warning
@@ -155,7 +159,7 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
155159

156160
# File header preferences
157161
# Keep operators at end of line when wrapping.
158-
dotnet_style_operator_placement_when_wrapping = end_of_line:warning
162+
dotnet_style_operator_placement_when_wrapping = end_of_line
159163
csharp_style_prefer_null_check_over_type_check = true:warning
160164

161165
# Code block preferences
@@ -164,7 +168,7 @@ csharp_prefer_simple_using_statement = true:suggestion
164168
dotnet_diagnostic.IDE0063.severity = suggestion
165169

166170
# C# Style Rules
167-
[*.{cs,csx,cake}]
171+
168172
# 'var' preferences
169173
csharp_style_var_for_built_in_types = true:warning
170174
csharp_style_var_when_type_is_apparent = true:warning
@@ -195,10 +199,6 @@ csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
195199
# "Null" checking preferences
196200
csharp_style_throw_expression = true:warning
197201
csharp_style_conditional_delegate_call = true:warning
198-
# Code block preferences
199-
csharp_prefer_braces = true:warning
200-
csharp_prefer_simple_using_statement = true:suggestion
201-
dotnet_diagnostic.IDE0063.severity = suggestion
202202
# 'using' directive preferences
203203
csharp_using_directive_placement = inside_namespace:warning
204204
# Modifier preferences
@@ -212,14 +212,12 @@ dotnet_code_quality.CA1822.api_surface = private
212212
##########################################
213213

214214
# .NET Unnecessary code rules
215-
[*.{cs,csx,cake,vb,vbx}]
216215

217216
dotnet_code_quality_unused_parameters = non_public:suggestion
218217
dotnet_remove_unnecessary_suppression_exclusions = none
219218
dotnet_diagnostic.IDE0079.severity = warning
220219

221220
# C# Unnecessary code rules
222-
[*.{cs,csx,cake}]
223221

224222
# Chickensoft Unused Code Additions
225223
#
@@ -244,7 +242,6 @@ dotnet_diagnostic.RCS1213.severity = none
244242
csharp_style_unused_value_expression_statement_preference = discard_variable
245243

246244
# .NET formatting rules
247-
[*.{cs,csx,cake,vb,vbx}]
248245

249246
# Organize using directives
250247
dotnet_sort_system_directives_first = true
@@ -259,7 +256,6 @@ dotnet_style_namespace_match_folder = false
259256
dotnet_diagnostic.IDE0130.severity = none
260257

261258
# C# formatting rules
262-
[*.{cs,csx,cake}]
263259

264260
# Newline options
265261
csharp_new_line_before_open_brace = none
@@ -312,7 +308,6 @@ csharp_style_namespace_declarations = file_scoped:warning
312308
##########################################
313309
# .NET Naming Rules
314310
##########################################
315-
[*.{cs,csx,cake,vb,vbx}]
316311

317312
##########################################
318313
# Chickensoft Naming Conventions & Styles
@@ -347,7 +342,7 @@ dotnet_naming_rule.non_public_fields_under_camel.symbols = non_public_fields
347342
dotnet_naming_rule.non_public_fields_under_camel.style = camel_case_underscore_style
348343
dotnet_naming_symbols.non_public_fields.applicable_kinds = field
349344
dotnet_naming_symbols.non_public_fields.required_modifiers =
350-
dotnet_naming_symbols.non_public_fields.applicable_accessibilities = private,private_protected,protected,internal,protected,protected_internal
345+
dotnet_naming_symbols.non_public_fields.applicable_accessibilities = private,private_protected,internal,protected,protected_internal
351346

352347
# Public fields should be PascalCase
353348
dotnet_naming_rule.public_fields_pascal.severity = suggestion
@@ -414,8 +409,6 @@ dotnet_naming_symbols.unspecified.applicable_accessibilities = *
414409
# Chickensoft Rule Overrides
415410
##########################################
416411

417-
# Allow using keywords as names
418-
# dotnet_diagnostic.CA1716.severity = none
419412
# Don't require culture info for ToString()
420413
dotnet_diagnostic.CA1304.severity = none
421414
# Don't require a string comparison for comparing strings.
@@ -433,9 +426,9 @@ dotnet_diagnostic.IDE0059.severity = none
433426
# Switch/case should always have a default clause. Tell that to Roslynator.
434427
dotnet_diagnostic.RCS1070.severity = none
435428
# Tell roslynator not to eat unused parameters.
436-
dotnet_diagnostic.RCS1163.severity = none
429+
dotnet_diagnostic.RCS1163.severity = suggestion
437430
# Tell dotnet not to remove unused parameters.
438-
dotnet_diagnostic.IDE0060.severity = none
431+
dotnet_diagnostic.IDE0060.severity = suggestion
439432
# Tell roslynator not to remove `partial` modifiers.
440433
dotnet_diagnostic.RCS1043.severity = none
441434
# Tell roslynator not to make classes static so aggressively.
@@ -446,10 +439,6 @@ dotnet_diagnostic.RCS1170.severity = none
446439
# Allow expression values to go unused, even without discard variable.
447440
# Otherwise, using Moq would be way too verbose.
448441
dotnet_diagnostic.IDE0058.severity = none
449-
# Don't let roslynator turn every local variable into a const.
450-
# If we did, we'd have to specify the types of local variables far more often,
451-
# and this style prefers type inference.
452-
dotnet_diagnostic.RCS1118.severity = none
453442
# Enums don't need to declare explicit values. Everyone knows they start at 0.
454443
dotnet_diagnostic.RCS1161.severity = none
455444
# Allow unconstrained type parameter to be checked for null.
@@ -460,27 +449,33 @@ dotnet_diagnostic.CA1716.severity = none
460449
dotnet_diagnostic.RCS1194.severity = none
461450
# Allow abstract types to have public constructors.
462451
dotnet_diagnostic.RCS1160.severity = none
463-
# Don't warn about unused parameters in lambdas.
464-
# dotnet_diagnostic.RCS1163.severity = none
465452
# Don't warn about unused finalizers.
466453
dotnet_diagnostic.RCS1106.severity = none
467454
dotnet_diagnostic.CA1821.severity = none
468455
# Allow me to write silly (but easy to read) if statements!
469456
dotnet_diagnostic.IDE0046.severity = none
470-
# Allow me to put comments where I like without turning them into doc comments.
457+
# Let me put comments where I like
471458
dotnet_diagnostic.RCS1181.severity = none
472459
# Results in logic errors by trying to remove lambdas.
473460
dotnet_diagnostic.IDE0200.severity = none
474-
# Don't force me to use primary constructors.
461+
# Allow me to use the word Collection if I want.
462+
dotnet_diagnostic.CA1711.severity = none
463+
# No primary constructors — not supported well by tooling.
475464
dotnet_diagnostic.IDE0290.severity = none
476-
# Leave me alone about string builder optimizations
477-
dotnet_diagnostic.RCS1197.severity = none
465+
# Let me write dumb if statements for readability.
466+
dotnet_diagnostic.IDE0046.severity = none
467+
# Don't make me use expression bodies for methods
468+
dotnet_diagnostic.IDE0022.severity = none
478469
# Let me have empty destructors
479470
dotnet_diagnostic.RCS1259.severity = none
480-
# Leave me alone about static members in generic types.
481-
dotnet_diagnostic.RCS1158.severity = none
482-
# Fancy collection syntax doesn't work yet for compatibility.
483-
dotnet_diagnostic.IDE0028.severity = none
471+
# DO make me populate a *switch expression*
472+
dotnet_diagnostic.IDE0072.severity = warning
473+
# Don't make me populate a *switch statement*
474+
dotnet_diagnostic.IDE0010.severity = none
475+
# Make local functions static
476+
dotnet_diagnostic.IDE0062.severity = warning
477+
# Don't make me use properties if I don't want to.
478+
dotnet_diagnostic.IDE0032.severity = none
484479
# You're wrong about redundant constructors.
485480
dotnet_diagnostic.RCS1074.severity = none
486481
# Allow me to nest ternary operators
@@ -489,4 +484,3 @@ dotnet_diagnostic.RCS1238.severity = none
489484
dotnet_diagnostic.RCS1241.severity = none
490485
# Leave me alone about "useless" overrides.
491486
dotnet_diagnostic.RCS1132.severity = none
492-

Chickensoft.LogicBlocks.Analyzers/src/LogicBlockAttributeAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Chickensoft.LogicBlocks.Analyzers;
1212
public class LogicBlockAttributeAnalyzer : DiagnosticAnalyzer {
1313
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics {
1414
get;
15-
} = ImmutableArray.Create(Diagnostics.MissingLogicBlockAttributeDescriptor);
15+
} = [Diagnostics.MissingLogicBlockAttributeDescriptor];
1616

1717
public override void Initialize(AnalysisContext context) {
1818
context.EnableConcurrentExecution();

Chickensoft.LogicBlocks.CodeFixes/src/LogicBlockAttributeCodeFix.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ namespace Chickensoft.LogicBlocks.CodeFixes;
1818
public class LogicBlockAttributeCodeFixProvider : CodeFixProvider {
1919
public sealed override ImmutableArray<string> FixableDiagnosticIds {
2020
get;
21-
} = ImmutableArray.Create(
22-
Diagnostics.MissingLogicBlockAttributeDescriptor.Id
23-
);
21+
} = [Diagnostics.MissingLogicBlockAttributeDescriptor.Id];
2422

2523
public sealed override FixAllProvider GetFixAllProvider() =>
2624
WellKnownFixAllProviders.BatchFixer;

Chickensoft.LogicBlocks.DiagramGenerator.Tests/test/src/models/ModelsTest.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public void Equality() {
2929
"file",
3030
"id",
3131
"name",
32-
System.Array.Empty<string>().ToImmutableHashSet(),
32+
[],
3333
new LogicBlockGraph(
34-
"id", "name", "baseId", new List<LogicBlockGraph>()
34+
"id", "name", "baseId", []
3535
),
3636
new Dictionary<string, LogicBlockGraph>().ToImmutableDictionary()
3737
);
@@ -40,9 +40,9 @@ public void Equality() {
4040
"file",
4141
"id",
4242
"name",
43-
System.Array.Empty<string>().ToImmutableHashSet(),
43+
[],
4444
new LogicBlockGraph(
45-
"id", "name", "baseId", new List<LogicBlockGraph>()
45+
"id", "name", "baseId", []
4646
),
4747
new Dictionary<string, LogicBlockGraph>().ToImmutableDictionary()
4848
);
@@ -51,9 +51,9 @@ public void Equality() {
5151
"file",
5252
"id_other",
5353
"name",
54-
System.Array.Empty<string>().ToImmutableHashSet(),
54+
[],
5555
new LogicBlockGraph(
56-
"id", "name", "baseId", new List<LogicBlockGraph>()
56+
"id", "name", "baseId", []
5757
),
5858
new Dictionary<string, LogicBlockGraph>().ToImmutableDictionary()
5959
);
@@ -62,9 +62,9 @@ public void Equality() {
6262
"file",
6363
"id",
6464
"name_other",
65-
System.Array.Empty<string>().ToImmutableHashSet(),
65+
[],
6666
new LogicBlockGraph(
67-
"id", "name", "baseId", new List<LogicBlockGraph>()
67+
"id", "name", "baseId", []
6868
),
6969
new Dictionary<string, LogicBlockGraph>().ToImmutableDictionary()
7070
);
@@ -73,11 +73,11 @@ public void Equality() {
7373
"file",
7474
"id",
7575
"name_other",
76-
System.Array.Empty<string>().ToImmutableHashSet(),
76+
[],
7777
new LogicBlockGraph(
78-
"id", "name", "baseId", new List<LogicBlockGraph>() {
79-
new("id", "name", "baseId", new List<LogicBlockGraph>())
80-
}
78+
"id", "name", "baseId", [
79+
new("id", "name", "baseId", [])
80+
]
8181
),
8282
new Dictionary<string, LogicBlockGraph>().ToImmutableDictionary()
8383
);

Chickensoft.LogicBlocks.DiagramGenerator.Tests/test_cases/partial_split_across_files/PartialLogic1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Chickensoft.LogicBlocks.Generator.Tests;
2+
23
[LogicBlock(typeof(State), Diagram = true)]
34
public partial class PartialLogic : LogicBlock<PartialLogic.State> {
45
public override Transition GetInitialState() => To<State.A>();

Chickensoft.LogicBlocks.DiagramGenerator/src/Diagrammer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public void Initialize(IncrementalGeneratorInitializationContext context) {
7373
});
7474

7575
var logicBlockCandidates = context.SyntaxProvider.CreateSyntaxProvider(
76-
predicate: static (SyntaxNode node, CancellationToken _) =>
76+
predicate: static (node, _) =>
7777
IsLogicBlockCandidate(node),
78-
transform: (GeneratorSyntaxContext context, CancellationToken token) =>
78+
transform: (context, token) =>
7979
GetStateGraph(
8080
(ClassDeclarationSyntax)context.Node, context.SemanticModel, token
8181
)
@@ -94,8 +94,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) {
9494
context.RegisterImplementationSourceOutput(
9595
source: logicBlockCandidates,
9696
action: (
97-
SourceProductionContext context,
98-
GenerationData data
97+
context,
98+
data
9999
) => {
100100
var disabled = data.Options.LogicBlocksDiagramGeneratorDisabled;
101101
if (disabled) { return; }
@@ -268,7 +268,7 @@ CancellationToken token
268268
);
269269

270270
if (!subtypesByBaseType.ContainsKey(baseTypeId)) {
271-
subtypesByBaseType[baseTypeId] = new List<INamedTypeSymbol>();
271+
subtypesByBaseType[baseTypeId] = [];
272272
}
273273

274274
subtypesByBaseType[baseTypeId].Add(subtype);
@@ -281,7 +281,7 @@ CancellationToken token
281281
member.Name == Constants.LOGIC_BLOCK_GET_INITIAL_STATE
282282
);
283283

284-
HashSet<string> initialStateIds = new();
284+
HashSet<string> initialStateIds = [];
285285

286286
if (
287287
getInitialStateMethod is IMethodSymbol initialStateMethod &&
@@ -321,7 +321,7 @@ LogicBlockGraph buildGraph(
321321

322322
var subtypes = subtypesByBaseType.ContainsKey(typeId)
323323
? subtypesByBaseType[typeId]
324-
: new List<INamedTypeSymbol>();
324+
: [];
325325

326326
foreach (var subtype in subtypes) {
327327
graph.Children.Add(buildGraph(subtype, type));

Chickensoft.LogicBlocks.DiagramGenerator/src/models/Models.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public LogicBlockGraph(
2828
string id,
2929
string name,
3030
string baseId
31-
) : this(id, name, baseId, new()) { }
31+
) : this(id, name, baseId, []) { }
3232

3333
/// <summary>
3434
/// UML-friendly identifier for the logic block graph.

Chickensoft.LogicBlocks.DiagramGenerator/src/utils/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static string Clean(this string text, string? newLine = null) {
3535
newLine ??= Environment.NewLine;
3636
var value = text.NormalizeLineEndings();
3737

38-
var lines = value.Split(new[] { newLine }, StringSplitOptions.None);
38+
var lines = value.Split([newLine], StringSplitOptions.None);
3939
for (var i = 0; i < lines.Length; i++) {
4040
lines[i] = string.IsNullOrWhiteSpace(lines[i]) ? "" : lines[i];
4141
}

Chickensoft.LogicBlocks.DiagramGenerator/src/utils/SymbolExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Chickensoft.SourceGeneratorUtils;
2+
23
using System.Collections.Generic;
34
using System.Linq;
45
using Microsoft.CodeAnalysis;

Chickensoft.LogicBlocks.DiagramGenerator/src/visitors/OutputVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public override void VisitStructDeclaration(StructDeclarationSyntax node) { }
116116

117117
private void AddOutput(string id, string name) {
118118
if (!_outputTypes.TryGetValue(OutputContext, out var outputs)) {
119-
outputs = new HashSet<LogicBlockOutput>();
119+
outputs = [];
120120
_outputTypes.Add(OutputContext, outputs);
121121
}
122122

0 commit comments

Comments
 (0)