diff --git a/src/Controls/src/BindingSourceGen/AccessExpressionBuilder.cs b/src/Controls/src/BindingSourceGen/AccessExpressionBuilder.cs index efca5060906c..bcc778c26a02 100644 --- a/src/Controls/src/BindingSourceGen/AccessExpressionBuilder.cs +++ b/src/Controls/src/BindingSourceGen/AccessExpressionBuilder.cs @@ -1,23 +1,18 @@ -using System; -using System.Linq; -using System.Text; +namespace Microsoft.Maui.Controls.BindingSourceGen; -namespace Microsoft.Maui.Controls.BindingSourceGen +public static class AccessExpressionBuilder { - public static class AccessExpressionBuilder - { - public static string Build(string previousExpression, IPathPart nextPart) - => nextPart switch - { - Cast { TargetType: var targetType } => $"({previousExpression} as {CastTargetName(targetType)})", - ConditionalAccess conditionalAccess => Build(previousExpression: $"{previousExpression}?", conditionalAccess.Part), - IndexAccess { Index: int numericIndex } => $"{previousExpression}[{numericIndex}]", - IndexAccess { Index: string stringIndex } => $"{previousExpression}[\"{stringIndex}\"]", - MemberAccess memberAccess => $"{previousExpression}.{memberAccess.MemberName}", - _ => throw new NotSupportedException($"Unsupported path part type: {nextPart.GetType()}"), - }; + public static string Build(string previousExpression, IPathPart nextPart) + => nextPart switch + { + Cast { TargetType: var targetType } => $"({previousExpression} as {CastTargetName(targetType)})", + ConditionalAccess conditionalAccess => Build(previousExpression: $"{previousExpression}?", conditionalAccess.Part), + IndexAccess { Index: int numericIndex } => $"{previousExpression}[{numericIndex}]", + IndexAccess { Index: string stringIndex } => $"{previousExpression}[\"{stringIndex}\"]", + MemberAccess memberAccess => $"{previousExpression}.{memberAccess.MemberName}", + _ => throw new NotSupportedException($"Unsupported path part type: {nextPart.GetType()}"), + }; - private static string CastTargetName(TypeDescription targetType) - => targetType.IsValueType ? $"{targetType.GlobalName}?" : targetType.GlobalName; - } + private static string CastTargetName(TypeDescription targetType) + => targetType.IsValueType ? $"{targetType.GlobalName}?" : targetType.GlobalName; } diff --git a/src/Controls/src/BindingSourceGen/BindingCodeWriter.cs b/src/Controls/src/BindingSourceGen/BindingCodeWriter.cs index 08ce6d270cfc..e1a639a3d93e 100644 --- a/src/Controls/src/BindingSourceGen/BindingCodeWriter.cs +++ b/src/Controls/src/BindingSourceGen/BindingCodeWriter.cs @@ -1,10 +1,5 @@ -using System; using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; -using System.IO; -using System.Text; namespace Microsoft.Maui.Controls.BindingSourceGen; @@ -77,9 +72,9 @@ private static bool ShouldUseSetter(BindingMode mode, BindableProperty bindableP } """; - private readonly List _bindings = new(); + private readonly List _bindings = new(); - public void AddBinding(CodeWriterBinding binding) + public void AddBinding(SetBindingInvocationDescription binding) { _bindings.Add(binding); } @@ -113,7 +108,7 @@ public BindingInterceptorCodeBuilder(int indent = 0) _indentedTextWriter = new IndentedTextWriter(_stringWriter, "\t") { Indent = indent }; } - public void AppendSetBindingInterceptor(int id, CodeWriterBinding binding) + public void AppendSetBindingInterceptor(int id, SetBindingInvocationDescription binding) { AppendBlankLine(); @@ -216,7 +211,7 @@ private void AppendInterceptorAttribute(InterceptorLocation location) AppendLine($"[InterceptsLocationAttribute(@\"{location.FilePath}\", {location.Line}, {location.Column})]"); } - private void AppendSetterAction(CodeWriterBinding binding, string sourceVariableName = "source", string valueVariableName = "value") + private void AppendSetterAction(SetBindingInvocationDescription binding, string sourceVariableName = "source", string valueVariableName = "value") { var assignedValueExpression = valueVariableName; diff --git a/src/Controls/src/BindingSourceGen/BindingSourceGenerator.cs b/src/Controls/src/BindingSourceGen/BindingSourceGenerator.cs index a92e86eec719..7e75bc170c24 100644 --- a/src/Controls/src/BindingSourceGen/BindingSourceGenerator.cs +++ b/src/Controls/src/BindingSourceGen/BindingSourceGenerator.cs @@ -96,13 +96,13 @@ static BindingDiagnosticsWrapper GetBindingForGeneration(GeneratorSyntaxContext return ReportDiagnostics(pathDiagnostics); } - var codeWriterBinding = new CodeWriterBinding( + var binding = new SetBindingInvocationDescription( Location: sourceCodeLocation.ToInterceptorLocation(), SourceType: BindingGenerationUtilities.CreateTypeNameFromITypeSymbol(lambdaSymbol.Parameters[0].Type, enabledNullable), PropertyType: BindingGenerationUtilities.CreateTypeNameFromITypeSymbol(lambdaTypeInfo.Type, enabledNullable), Path: new EquatableArray([.. parts]), SetterOptions: DeriveSetterOptions(lambdaBody, context.SemanticModel, enabledNullable)); - return new BindingDiagnosticsWrapper(codeWriterBinding, new EquatableArray([.. diagnostics])); + return new BindingDiagnosticsWrapper(binding, new EquatableArray([.. diagnostics])); } private static EquatableArray VerifyCorrectOverload(InvocationExpressionSyntax invocation, GeneratorSyntaxContext context, CancellationToken t) diff --git a/src/Controls/src/BindingSourceGen/GeneratorDataModels.cs b/src/Controls/src/BindingSourceGen/GeneratorDataModels.cs index b72128b51d63..e915571a39f0 100644 --- a/src/Controls/src/BindingSourceGen/GeneratorDataModels.cs +++ b/src/Controls/src/BindingSourceGen/GeneratorDataModels.cs @@ -1,4 +1,3 @@ - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; @@ -11,10 +10,10 @@ public class TrackingNames } public sealed record BindingDiagnosticsWrapper( - CodeWriterBinding? Binding, + SetBindingInvocationDescription? Binding, EquatableArray Diagnostics); -public sealed record CodeWriterBinding( +public sealed record SetBindingInvocationDescription( InterceptorLocation Location, TypeDescription SourceType, TypeDescription PropertyType, diff --git a/src/Controls/src/BindingSourceGen/HashCode.cs b/src/Controls/src/BindingSourceGen/HashCode.cs index 2c6ef6f80036..89ad0ec72460 100644 --- a/src/Controls/src/BindingSourceGen/HashCode.cs +++ b/src/Controls/src/BindingSourceGen/HashCode.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; diff --git a/src/Controls/src/BindingSourceGen/IsExternalInitCompat.cs b/src/Controls/src/BindingSourceGen/IsExternalInitCompat.cs index 8e104313cf39..97b7ffc4ecae 100644 --- a/src/Controls/src/BindingSourceGen/IsExternalInitCompat.cs +++ b/src/Controls/src/BindingSourceGen/IsExternalInitCompat.cs @@ -1,12 +1,11 @@ using System.ComponentModel; -namespace System.Runtime.CompilerServices +namespace System.Runtime.CompilerServices; + +/// +/// This dummy class is required to compile records when targeting .NET Standard +/// +[EditorBrowsable(EditorBrowsableState.Never)] +public static class IsExternalInit { - /// - /// This dummy class is required to compile records when targeting .NET Standard - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static class IsExternalInit - { - } } diff --git a/src/Controls/src/BindingSourceGen/PathParser.cs b/src/Controls/src/BindingSourceGen/PathParser.cs index 7073c4435eda..fcf05e577bda 100644 --- a/src/Controls/src/BindingSourceGen/PathParser.cs +++ b/src/Controls/src/BindingSourceGen/PathParser.cs @@ -2,7 +2,6 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - namespace Microsoft.Maui.Controls.BindingSourceGen; internal class PathParser diff --git a/src/Controls/src/BindingSourceGen/SetterBuilder.cs b/src/Controls/src/BindingSourceGen/SetterBuilder.cs index 5d138b44a33d..6b88ced4e297 100644 --- a/src/Controls/src/BindingSourceGen/SetterBuilder.cs +++ b/src/Controls/src/BindingSourceGen/SetterBuilder.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; - namespace Microsoft.Maui.Controls.BindingSourceGen; public sealed record Setter(string[] PatternMatchingExpressions, string AssignmentStatement) diff --git a/src/Controls/tests/BindingSourceGen.UnitTests/AssertExtensions.cs b/src/Controls/tests/BindingSourceGen.UnitTests/AssertExtensions.cs index a21a4da221a8..0bf594dffdd5 100644 --- a/src/Controls/tests/BindingSourceGen.UnitTests/AssertExtensions.cs +++ b/src/Controls/tests/BindingSourceGen.UnitTests/AssertExtensions.cs @@ -18,7 +18,7 @@ internal static void CodeIsEqual(string expectedCode, string actualCode) } } - internal static void BindingsAreEqual(CodeWriterBinding expectedBinding, CodeGeneratorResult codeGeneratorResult) + internal static void BindingsAreEqual(SetBindingInvocationDescription expectedBinding, CodeGeneratorResult codeGeneratorResult) { AssertNoDiagnostics(codeGeneratorResult); Assert.NotNull(codeGeneratorResult.Binding); diff --git a/src/Controls/tests/BindingSourceGen.UnitTests/BindingCodeWriterTests.cs b/src/Controls/tests/BindingSourceGen.UnitTests/BindingCodeWriterTests.cs index 833bc5a7b2ae..14df77ce33a3 100644 --- a/src/Controls/tests/BindingSourceGen.UnitTests/BindingCodeWriterTests.cs +++ b/src/Controls/tests/BindingSourceGen.UnitTests/BindingCodeWriterTests.cs @@ -10,7 +10,7 @@ public class BindingCodeWriterTests public void BuildsWholeDocument() { var codeWriter = new BindingCodeWriter(); - codeWriter.AddBinding(new CodeWriterBinding( + codeWriter.AddBinding(new SetBindingInvocationDescription( Location: new InterceptorLocation(FilePath: @"Path\To\Program.cs", Line: 20, Column: 30), SourceType: new TypeDescription("global::MyNamespace.MySourceClass", IsValueType: false, IsNullable: false, IsGenericParameter: false), PropertyType: new TypeDescription("global::MyNamespace.MyPropertyClass", IsValueType: false, IsNullable: false, IsGenericParameter: false), @@ -131,7 +131,7 @@ private static bool ShouldUseSetter(BindingMode mode, BindableProperty bindableP public void CorrectlyFormatsSimpleBinding() { var codeBuilder = new BindingCodeWriter.BindingInterceptorCodeBuilder(); - codeBuilder.AppendSetBindingInterceptor(id: 1, new CodeWriterBinding( + codeBuilder.AppendSetBindingInterceptor(id: 1, new SetBindingInvocationDescription( Location: new InterceptorLocation(FilePath: @"Path\To\Program.cs", Line: 20, Column: 30), SourceType: new TypeDescription("global::MyNamespace.MySourceClass", IsValueType: false, IsNullable: false, IsGenericParameter: false), PropertyType: new TypeDescription("global::MyNamespace.MyPropertyClass", IsValueType: false, IsNullable: false, IsGenericParameter: false), @@ -201,7 +201,7 @@ public static void SetBinding1( public void CorrectlyFormatsBindingWithoutAnyNullablesInPath() { var codeBuilder = new BindingCodeWriter.BindingInterceptorCodeBuilder(); - codeBuilder.AppendSetBindingInterceptor(id: 1, new CodeWriterBinding( + codeBuilder.AppendSetBindingInterceptor(id: 1, new SetBindingInvocationDescription( Location: new InterceptorLocation(FilePath: @"Path\To\Program.cs", Line: 20, Column: 30), SourceType: new TypeDescription("global::MyNamespace.MySourceClass", IsValueType: false, IsNullable: false, IsGenericParameter: false), PropertyType: new TypeDescription("global::MyNamespace.MyPropertyClass", IsValueType: false, IsNullable: false, IsGenericParameter: false), @@ -267,7 +267,7 @@ public static void SetBinding1( public void CorrectlyFormatsBindingWithoutSetter() { var codeBuilder = new BindingCodeWriter.BindingInterceptorCodeBuilder(); - codeBuilder.AppendSetBindingInterceptor(id: 1, new CodeWriterBinding( + codeBuilder.AppendSetBindingInterceptor(id: 1, new SetBindingInvocationDescription( Location: new InterceptorLocation(FilePath: @"Path\To\Program.cs", Line: 20, Column: 30), SourceType: new TypeDescription("global::MyNamespace.MySourceClass", IsNullable: false, IsGenericParameter: false, IsValueType: false), PropertyType: new TypeDescription("global::MyNamespace.MyPropertyClass", IsNullable: false, IsGenericParameter: false, IsValueType: false), @@ -330,7 +330,7 @@ public static void SetBinding1( public void CorrectlyFormatsBindingWithIndexers() { var codeBuilder = new BindingCodeWriter.BindingInterceptorCodeBuilder(); - codeBuilder.AppendSetBindingInterceptor(id: 1, new CodeWriterBinding( + codeBuilder.AppendSetBindingInterceptor(id: 1, new SetBindingInvocationDescription( Location: new InterceptorLocation(FilePath: @"Path\To\Program.cs", Line: 20, Column: 30), SourceType: new TypeDescription("global::MyNamespace.MySourceClass", IsNullable: false, IsGenericParameter: false), PropertyType: new TypeDescription("global::MyNamespace.MyPropertyClass", IsNullable: true, IsGenericParameter: false), @@ -404,7 +404,7 @@ public static void SetBinding1( public void CorrectlyFormatsBindingWithCasts() { var codeBuilder = new BindingCodeWriter.BindingInterceptorCodeBuilder(); - codeBuilder.AppendSetBindingInterceptor(id: 1, new CodeWriterBinding( + codeBuilder.AppendSetBindingInterceptor(id: 1, new SetBindingInvocationDescription( Location: new InterceptorLocation(FilePath: @"Path\To\Program.cs", Line: 20, Column: 30), SourceType: new TypeDescription("global::MyNamespace.MySourceClass", IsNullable: false, IsGenericParameter: false), PropertyType: new TypeDescription("global::MyNamespace.MyPropertyClass", IsNullable: false, IsGenericParameter: false), diff --git a/src/Controls/tests/BindingSourceGen.UnitTests/BindingRepresentationGenTests.cs b/src/Controls/tests/BindingSourceGen.UnitTests/BindingRepresentationGenTests.cs index d8684c81f8c8..8b12c2169aa6 100644 --- a/src/Controls/tests/BindingSourceGen.UnitTests/BindingRepresentationGenTests.cs +++ b/src/Controls/tests/BindingSourceGen.UnitTests/BindingRepresentationGenTests.cs @@ -17,7 +17,7 @@ public void GenerateSimpleBinding() """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("string"), new TypeDescription("int", IsValueType: true), @@ -39,7 +39,7 @@ public void GenerateBindingWithNestedProperties() """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Microsoft.Maui.Controls.Button"), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -67,7 +67,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -92,7 +92,7 @@ public void GenerateBindingWithNullableReferenceSourceWhenNullableEnabled() """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Microsoft.Maui.Controls.Button", IsNullable: true), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -120,7 +120,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -142,7 +142,7 @@ public void GenerateBindingWithNullableSourceReferenceAndNullableReferenceElemen """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Microsoft.Maui.Controls.Button", IsNullable: true), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -170,7 +170,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("string", IsNullable: true), @@ -198,7 +198,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 4, 7), new TypeDescription("global::Foo", IsNullable: true), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -227,7 +227,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 4, 7), new TypeDescription("global::Foo", IsNullable: true), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -254,7 +254,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true), @@ -283,7 +283,7 @@ class Foo } """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 4, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true), @@ -315,7 +315,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 6, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true), @@ -343,7 +343,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -376,7 +376,7 @@ class Bar """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -423,7 +423,7 @@ public class MyPropertyClass """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 6, 7), new TypeDescription("global::MyNamespace.MySourceClass"), new TypeDescription("global::MyNamespace.MyPropertyClass", IsNullable: true), @@ -455,7 +455,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 6, 7), new TypeDescription("global::Foo"), new TypeDescription("char", IsValueType: true), @@ -484,7 +484,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 4, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true), @@ -512,7 +512,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("string", IsNullable: true), @@ -540,7 +540,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("string"), @@ -573,7 +573,7 @@ class C """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true, IsNullable: true), @@ -607,7 +607,7 @@ class C """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true), @@ -644,7 +644,7 @@ class C """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsNullable: true, IsValueType: true), @@ -675,7 +675,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsNullable: true, IsValueType: true), @@ -704,7 +704,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsValueType: true), @@ -740,7 +740,7 @@ struct C """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("int", IsNullable: true, IsValueType: true), @@ -769,7 +769,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("char", IsValueType: true), @@ -797,7 +797,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("char", IsValueType: true), @@ -825,7 +825,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("string"), @@ -852,7 +852,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo"), new TypeDescription("string"), @@ -879,7 +879,7 @@ class Foo """; var codeGeneratorResult = SourceGenHelpers.Run(source); - var expectedBinding = new CodeWriterBinding( + var expectedBinding = new SetBindingInvocationDescription( new InterceptorLocation(@"Path\To\Program.cs", 3, 7), new TypeDescription("global::Foo", IsNullable: true), new TypeDescription("int", IsValueType: true, IsNullable: true), diff --git a/src/Controls/tests/BindingSourceGen.UnitTests/SourceGenHelpers.cs b/src/Controls/tests/BindingSourceGen.UnitTests/SourceGenHelpers.cs index 3c1b7ab74a2d..45e37bdd9a11 100644 --- a/src/Controls/tests/BindingSourceGen.UnitTests/SourceGenHelpers.cs +++ b/src/Controls/tests/BindingSourceGen.UnitTests/SourceGenHelpers.cs @@ -11,7 +11,7 @@ internal record CodeGeneratorResult( ImmutableArray SourceCompilationDiagnostics, ImmutableArray SourceGeneratorDiagnostics, ImmutableArray GeneratedCodeCompilationDiagnostics, - CodeWriterBinding? Binding); + SetBindingInvocationDescription? Binding); internal static class SourceGenHelpers { @@ -43,7 +43,7 @@ internal static CodeGeneratorResult Run(string source) var trackedSteps = result.TrackedSteps; var resultBinding = trackedSteps.TryGetValue("Bindings", out ImmutableArray value) - ? (CodeWriterBinding)value[0].Outputs[0].Value + ? (SetBindingInvocationDescription)value[0].Outputs[0].Value : null; return new CodeGeneratorResult(