Skip to content

Commit 7d5c559

Browse files
committed
Add more test coverage for XML docs
1 parent 74919d5 commit 7d5c559

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.Tests/Test_UseGeneratedDependencyPropertyOnManualPropertyCodeFixer.cs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,89 @@ public partial class MyControl : Control
441441
await test.RunAsync();
442442
}
443443

444+
[TestMethod]
445+
public async Task MultipleProperties_WithXmlDocs_HandlesSpacingCorrectly()
446+
{
447+
const string original = """
448+
using Windows.UI.Xaml;
449+
450+
#nullable enable
451+
452+
namespace MyApp;
453+
454+
public abstract partial class MyObject<TElement, TValue> : DependencyObject
455+
{
456+
/// <summary>
457+
/// Blah.
458+
/// </summary>
459+
public static readonly DependencyProperty TargetObjectProperty = DependencyProperty.Register(
460+
nameof(TargetObject),
461+
typeof(TElement?),
462+
typeof(MyObject<TElement, TValue>),
463+
null);
464+
465+
/// <summary>
466+
/// Blah.
467+
/// </summary>
468+
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
469+
nameof(Value),
470+
typeof(TValue?),
471+
typeof(MyObject<TElement, TValue>),
472+
null);
473+
474+
/// <summary>
475+
/// Blah.
476+
/// </summary>
477+
public TValue? [|Value|]
478+
{
479+
get => (TValue?)GetValue(ValueProperty);
480+
set => SetValue(ValueProperty, value);
481+
}
482+
483+
/// <summary>
484+
/// Blah.
485+
/// </summary>
486+
public TElement? [|TargetObject|]
487+
{
488+
get => (TElement?)GetValue(TargetObjectProperty);
489+
set => SetValue(TargetObjectProperty, value);
490+
}
491+
}
492+
""";
493+
494+
const string @fixed = """
495+
using CommunityToolkit.WinUI;
496+
using Windows.UI.Xaml;
497+
498+
#nullable enable
499+
500+
namespace MyApp;
501+
502+
public abstract partial class MyObject<TElement, TValue> : DependencyObject
503+
{
504+
/// <summary>
505+
/// Blah.
506+
/// </summary>
507+
[GeneratedDependencyProperty]
508+
public partial TValue? {|CS9248:Value|} { get; set; }
509+
510+
/// <summary>
511+
/// Blah.
512+
/// </summary>
513+
[GeneratedDependencyProperty]
514+
public partial TElement? {|CS9248:TargetObject|} { get; set; }
515+
}
516+
""";
517+
518+
CSharpCodeFixTest test = new(LanguageVersion.Preview)
519+
{
520+
TestCode = original,
521+
FixedCode = @fixed
522+
};
523+
524+
await test.RunAsync();
525+
}
526+
444527
[TestMethod]
445528
public async Task MultipleProperties_WithInterspersedMembers_HandlesSpacingCorrectly()
446529
{

0 commit comments

Comments
 (0)