@@ -1046,4 +1046,212 @@ public class TestAttribute(int X, string Y) : Attribute;
10461046
10471047 await test . RunAsync ( ) ;
10481048 }
1049+
1050+ // Using 'object' for dependency properties is sometimes needed to work around an 'IReference<T>' issue in some binding scenarios
1051+ [ TestMethod ]
1052+ public async Task MultipleProperties_WithInterspersedNonFixableProprty_HandlesAllPossibleProperties ( )
1053+ {
1054+ const string original = """
1055+ using System;
1056+ using Windows.UI.Xaml;
1057+ using Windows.UI.Xaml.Controls;
1058+
1059+ #nullable enable
1060+
1061+ namespace MyApp;
1062+
1063+ public partial class MyObject : DependencyObject
1064+ {
1065+ /// <summary>
1066+ /// Identifies the <see cref="DisableAnimation" /> dependency property.
1067+ /// </summary>
1068+ public static readonly DependencyProperty DisableAnimationProperty = DependencyProperty.Register(
1069+ nameof(DisableAnimation),
1070+ typeof(bool),
1071+ typeof(MyObject),
1072+ new PropertyMetadata(false));
1073+
1074+ /// <summary>
1075+ /// Identifies the <see cref="HorizontalOffset" /> dependency property.
1076+ /// </summary>
1077+ public static readonly DependencyProperty HorizontalOffsetProperty = DependencyProperty.Register(
1078+ nameof(HorizontalOffset),
1079+ typeof(object),
1080+ typeof(MyObject),
1081+ null);
1082+
1083+ /// <summary>
1084+ /// Identifies the <see cref="IsHorizontalOffsetRelative" /> dependency property.
1085+ /// </summary>
1086+ public static readonly DependencyProperty IsHorizontalOffsetRelativeProperty = DependencyProperty.Register(
1087+ nameof(IsHorizontalOffsetRelative),
1088+ typeof(bool),
1089+ typeof(MyObject),
1090+ new PropertyMetadata(false));
1091+
1092+ /// <summary>
1093+ /// Identifies the <see cref="IsVerticalOffsetRelative" /> dependency property.
1094+ /// </summary>
1095+ public static readonly DependencyProperty IsVerticalOffsetRelativeProperty = DependencyProperty.Register(
1096+ nameof(IsVerticalOffsetRelative),
1097+ typeof(bool),
1098+ typeof(MyObject),
1099+ new PropertyMetadata(false));
1100+
1101+ /// <summary>
1102+ /// Identifies the <see cref="TargetScrollViewer" /> dependency property.
1103+ /// </summary>
1104+ public static readonly DependencyProperty TargetScrollViewerProperty = DependencyProperty.Register(
1105+ nameof(TargetScrollViewer),
1106+ typeof(ScrollViewer),
1107+ typeof(MyObject),
1108+ null);
1109+
1110+ /// <summary>
1111+ /// Identifies the <see cref="VerticalOffset" /> dependency property.
1112+ /// </summary>
1113+ public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.Register(
1114+ nameof(VerticalOffset),
1115+ typeof(object),
1116+ typeof(MyObject),
1117+ null);
1118+
1119+ /// <summary>
1120+ /// Gets or sets a value indicating whether the animation is disabled. The default value is <see langword="false" />.
1121+ /// </summary>
1122+ public bool [|DisableAnimation|]
1123+ {
1124+ get => (bool)GetValue(DisableAnimationProperty);
1125+ set => SetValue(DisableAnimationProperty, value);
1126+ }
1127+
1128+ /// <summary>
1129+ /// Gets or sets the distance should be scrolled horizontally.
1130+ /// </summary>
1131+ public double? HorizontalOffset
1132+ {
1133+ get => (double?)GetValue(HorizontalOffsetProperty);
1134+ set => SetValue(HorizontalOffsetProperty, value);
1135+ }
1136+
1137+ /// <summary>
1138+ /// Gets or sets a value indicating whether the horizontal offset is relative to the current offset. The default value is <see langword="false" />.
1139+ /// </summary>
1140+ public bool [|IsHorizontalOffsetRelative|]
1141+ {
1142+ get => (bool)GetValue(IsHorizontalOffsetRelativeProperty);
1143+ set => SetValue(IsHorizontalOffsetRelativeProperty, value);
1144+ }
1145+
1146+ /// <summary>
1147+ /// Gets or sets a value indicating whether the vertical offset is relative to the current offset. The default value is <see langword="false" />.
1148+ /// </summary>
1149+ public bool [|IsVerticalOffsetRelative|]
1150+ {
1151+ get => (bool)GetValue(IsVerticalOffsetRelativeProperty);
1152+ set => SetValue(IsVerticalOffsetRelativeProperty, value);
1153+ }
1154+
1155+ /// <summary>
1156+ /// Gets or sets the target <see cref="ScrollViewer" />.
1157+ /// </summary>
1158+ public ScrollViewer? [|TargetScrollViewer|]
1159+ {
1160+ get => (ScrollViewer?)GetValue(TargetScrollViewerProperty);
1161+ set => SetValue(TargetScrollViewerProperty, value);
1162+ }
1163+
1164+ /// <summary>
1165+ /// Gets or sets the distance should be scrolled vertically.
1166+ /// </summary>
1167+ public double? VerticalOffset
1168+ {
1169+ get => (double?)GetValue(VerticalOffsetProperty);
1170+ set => SetValue(VerticalOffsetProperty, value);
1171+ }
1172+ }
1173+ """ ;
1174+
1175+ const string @fixed = """
1176+ using System;
1177+ using CommunityToolkit.WinUI;
1178+ using Windows.UI.Xaml;
1179+ using Windows.UI.Xaml.Controls;
1180+
1181+ #nullable enable
1182+
1183+ namespace MyApp;
1184+
1185+ public partial class MyObject : DependencyObject
1186+ {
1187+ /// <summary>
1188+ /// Identifies the <see cref="HorizontalOffset" /> dependency property.
1189+ /// </summary>
1190+ public static readonly DependencyProperty HorizontalOffsetProperty = DependencyProperty.Register(
1191+ nameof(HorizontalOffset),
1192+ typeof(object),
1193+ typeof(MyObject),
1194+ null);
1195+
1196+ /// <summary>
1197+ /// Identifies the <see cref="VerticalOffset" /> dependency property.
1198+ /// </summary>
1199+ public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.Register(
1200+ nameof(VerticalOffset),
1201+ typeof(object),
1202+ typeof(MyObject),
1203+ null);
1204+
1205+ /// <summary>
1206+ /// Gets or sets a value indicating whether the animation is disabled. The default value is <see langword="false" />.
1207+ /// </summary>
1208+ [GeneratedDependencyProperty]
1209+ public partial bool {|CS9248:DisableAnimation|} { get; set; }
1210+
1211+ /// <summary>
1212+ /// Gets or sets the distance should be scrolled horizontally.
1213+ /// </summary>
1214+ public double? HorizontalOffset
1215+ {
1216+ get => (double?)GetValue(HorizontalOffsetProperty);
1217+ set => SetValue(HorizontalOffsetProperty, value);
1218+ }
1219+
1220+ /// <summary>
1221+ /// Gets or sets a value indicating whether the horizontal offset is relative to the current offset. The default value is <see langword="false" />.
1222+ /// </summary>
1223+ [GeneratedDependencyProperty]
1224+ public partial bool {|CS9248:IsHorizontalOffsetRelative|} { get; set; }
1225+
1226+ /// <summary>
1227+ /// Gets or sets a value indicating whether the vertical offset is relative to the current offset. The default value is <see langword="false" />.
1228+ /// </summary>
1229+ [GeneratedDependencyProperty]
1230+ public partial bool {|CS9248:IsVerticalOffsetRelative|} { get; set; }
1231+
1232+ /// <summary>
1233+ /// Gets or sets the target <see cref="ScrollViewer" />.
1234+ /// </summary>
1235+ [GeneratedDependencyProperty]
1236+ public partial ScrollViewer? {|CS9248:TargetScrollViewer|} { get; set; }
1237+
1238+ /// <summary>
1239+ /// Gets or sets the distance should be scrolled vertically.
1240+ /// </summary>
1241+ public double? VerticalOffset
1242+ {
1243+ get => (double?)GetValue(VerticalOffsetProperty);
1244+ set => SetValue(VerticalOffsetProperty, value);
1245+ }
1246+ }
1247+ """ ;
1248+
1249+ CSharpCodeFixTest test = new ( LanguageVersion . Preview )
1250+ {
1251+ TestCode = original ,
1252+ FixedCode = @fixed
1253+ } ;
1254+
1255+ await test . RunAsync ( ) ;
1256+ }
10491257}
0 commit comments