1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-04-10 11:15:45 +02:00

Fixed an issue with base type list formatting

This commit is contained in:
Sergio Pedri 2021-03-22 01:51:57 +01:00
parent 6f9a2f4ed9
commit 0aae5ffe93
2 changed files with 10 additions and 1 deletions
Microsoft.Toolkit.Mvvm.SourceGenerators
Microsoft.Toolkit.Mvvm/ComponentModel/Attributes

View File

@ -81,7 +81,7 @@ private void OnExecute(
{
ClassDeclarationSyntax sourceDeclaration = sourceSyntaxTree.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>().First();
UsingDirectiveSyntax[] usingDirectives = sourceSyntaxTree.GetRoot().DescendantNodes().OfType<UsingDirectiveSyntax>().ToArray();
BaseListSyntax baseListSyntax = BaseList(SeparatedList(
BaseListSyntax? baseListSyntax = BaseList(SeparatedList(
sourceDeclaration.BaseList?.Types
.OfType<SimpleBaseTypeSyntax>()
.Select(static t => t.Type)
@ -91,6 +91,11 @@ private void OnExecute(
.ToArray()
?? Array.Empty<BaseTypeSyntax>()));
if (baseListSyntax.Types.Count == 0)
{
baseListSyntax = null;
}
// Create the class declaration for the user type. This will produce a tree as follows:
//
// <MODIFIERS> <CLASS_NAME> : <BASE_TYPES>

View File

@ -26,6 +26,10 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
/// </code>
/// </para>
/// And with this, the same APIs from <see cref="ObservableRecipient"/> will be available on this type as well.
/// <para>
/// To avoid conflicts with other APIs in types where the new members are being generated, constructors are omitted. Make sure to
/// properly initialize the <see cref="ObservableRecipient.Messenger"/> property from the constructors in the type being annotated.
/// </para>
/// </summary>
/// <remarks>
/// In order to work, <see cref="ObservableRecipientAttribute"/> needs to be applied to a type that inherits from