Skip to content

Commit c0dbe67

Browse files
committed
Add docs pages for source generators
1 parent db4f2ee commit c0dbe67

12 files changed

+274
-3
lines changed

msdocs-communitytoolkit

samples/MvvmSampleUwp/MvvmSampleUwp.csproj

+44
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,21 @@
143143
<Compile Include="Views\BuildingTheUIPage.xaml.cs">
144144
<DependentUpon>BuildingTheUIPage.xaml</DependentUpon>
145145
</Compile>
146+
<Compile Include="Views\INotifyPropertyChangedAttributePage.xaml.cs">
147+
<DependentUpon>INotifyPropertyChangedAttributePage.xaml</DependentUpon>
148+
</Compile>
149+
<Compile Include="Views\RelayCommandAttributePage.xaml.cs">
150+
<DependentUpon>RelayCommandAttributePage.xaml</DependentUpon>
151+
</Compile>
146152
<Compile Include="Views\ObservableValidatorPage.xaml.cs">
147153
<DependentUpon>ObservableValidatorPage.xaml</DependentUpon>
148154
</Compile>
155+
<Compile Include="Views\ObservablePropertyAttributePage.xaml.cs">
156+
<DependentUpon>ObservablePropertyAttributePage.xaml</DependentUpon>
157+
</Compile>
158+
<Compile Include="Views\SourceGeneratorsPage.xaml.cs">
159+
<DependentUpon>SourceGeneratorsPage.xaml</DependentUpon>
160+
</Compile>
149161
<Compile Include="Views\RedditServicePage.xaml.cs">
150162
<DependentUpon>RedditServicePage.xaml</DependentUpon>
151163
</Compile>
@@ -391,10 +403,26 @@
391403
<Generator>MSBuild:Compile</Generator>
392404
<SubType>Designer</SubType>
393405
</Page>
406+
<Page Include="Views\INotifyPropertyChangedAttributePage.xaml">
407+
<Generator>MSBuild:Compile</Generator>
408+
<SubType>Designer</SubType>
409+
</Page>
410+
<Page Include="Views\RelayCommandAttributePage.xaml">
411+
<Generator>MSBuild:Compile</Generator>
412+
<SubType>Designer</SubType>
413+
</Page>
394414
<Page Include="Views\ObservableValidatorPage.xaml">
395415
<Generator>MSBuild:Compile</Generator>
396416
<SubType>Designer</SubType>
397417
</Page>
418+
<Page Include="Views\ObservablePropertyAttributePage.xaml">
419+
<Generator>MSBuild:Compile</Generator>
420+
<SubType>Designer</SubType>
421+
</Page>
422+
<Page Include="Views\SourceGeneratorsPage.xaml">
423+
<Generator>MSBuild:Compile</Generator>
424+
<SubType>Designer</SubType>
425+
</Page>
398426
<Page Include="Views\RedditServicePage.xaml">
399427
<Generator>MSBuild:Compile</Generator>
400428
<SubType>Designer</SubType>
@@ -505,6 +533,22 @@
505533
<Link>Assets\docs\ObservableGroupedCollections.md</Link>
506534
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
507535
</Content>
536+
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\Overview.md">
537+
<Link>Assets\docs\Overview.md</Link>
538+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
539+
</Content>
540+
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\ObservableProperty.md">
541+
<Link>Assets\docs\ObservablePropertyAttribute.md</Link>
542+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
543+
</Content>
544+
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\RelayCommand.md">
545+
<Link>Assets\docs\RelayCommandAttribute.md</Link>
546+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
547+
</Content>
548+
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\INotifyPropertyChanged.md">
549+
<Link>Assets\docs\INotifyPropertyChangedAttribute.md</Link>
550+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
551+
</Content>
508552
</ItemGroup>
509553
<ItemGroup>
510554
<ProjectReference Include="..\MvvmSample.Core\MvvmSample.Core.csproj">

samples/MvvmSampleUwp/Shell.xaml

+23-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,29 @@
5757
IsExpanded="True"
5858
ToolTipService.ToolTip="A showcase of all the individual building blocks available in the MVVM Toolkit.">
5959
<muxc:NavigationViewItem.MenuItems>
60+
<muxc:NavigationViewItem
61+
x:Name="SourceGeneratorsItem"
62+
Content="Source generators"
63+
Icon="ClearSelection"
64+
ToolTipService.ToolTip="Brand new incremental Roslyn source generators to power MVVM scenarios.">
65+
<muxc:NavigationViewItem.MenuItems>
66+
<muxc:NavigationViewItem
67+
x:Name="ObservablePropertyAttributeItem"
68+
Content="[ObservableProperty]"
69+
Icon="ReShare"
70+
ToolTipService.ToolTip="An attribute that allows generating observable properties from annotated fields." />
71+
<muxc:NavigationViewItem
72+
x:Name="RelayCommandAttributeItem"
73+
Content="[RelayCommand]"
74+
Icon="Directions"
75+
ToolTipService.ToolTip="An attribute to generate relay command properties from annotated methods." />
76+
<muxc:NavigationViewItem
77+
x:Name="INotifyPropertyChangedAttributeItem"
78+
Content="[INotifyPropertyChanged]"
79+
Icon="Orientation"
80+
ToolTipService.ToolTip="Attributes to inject MVVM support into partial classes using composition." />
81+
</muxc:NavigationViewItem.MenuItems>
82+
</muxc:NavigationViewItem>
6083
<muxc:NavigationViewItem
6184
x:Name="ObservableObjectItem"
6285
Content="ObservableObject"
@@ -70,7 +93,6 @@
7093
<muxc:NavigationViewItem
7194
Content="Commands"
7295
Icon="Calendar"
73-
IsExpanded="True"
7496
ToolTipService.ToolTip="A collection of types implementing the ICommand interface.">
7597
<muxc:NavigationViewItem.MenuItems>
7698
<muxc:NavigationViewItem
@@ -89,7 +111,6 @@
89111
x:Name="MessengerItem"
90112
Content="Messenger"
91113
Icon="Comment"
92-
IsExpanded="True"
93114
ToolTipService.ToolTip="An easy to use and powerful type to exchange messages between different app modules.">
94115
<muxc:NavigationViewItem.MenuItems>
95116
<muxc:NavigationViewItem

samples/MvvmSampleUwp/Shell.xaml.cs

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public Shell()
2929
NavigationItems = new[]
3030
{
3131
new SampleEntry(IntroductionItem, typeof(IntroductionPage)),
32+
new SampleEntry(SourceGeneratorsItem, typeof(SourceGeneratorsPage), "MVVM source generators", "observable inotify property changed propertychanging changing roslyn source generators"),
33+
new SampleEntry(ObservablePropertyAttributeItem, typeof(ObservablePropertyAttributePage), "[ObservableProperty]", "observable inotify property changed propertychanging changing roslyn source generators"),
34+
new SampleEntry(RelayCommandAttributeItem, typeof(RelayCommandAttributePage), "[RelayCommand]", "observable inotify property changed propertychanging changing command icommand relay roslyn source generators"),
35+
new SampleEntry(INotifyPropertyChangedAttributeItem, typeof(INotifyPropertyChangedAttributePage), "[INotifyPropertyChanged]", "observable inotify property changed propertychanging changing roslyn source generators"),
3236
new SampleEntry(ObservableObjectItem, typeof(ObservableObjectPage), "ObservableObject", "observable inotify property changed propertychanging changing"),
3337
new SampleEntry(ObservableValidatorItem, typeof(ObservableValidatorPage), "ObservableValidator", "observable form validation validate data error inotify property changed propertychanging changing"),
3438
new SampleEntry(CommandsItem, typeof(RelayCommandPage), "RelayCommand and RelayCommand<T>", "commands icommand relaycommand binding"),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Page
2+
x:Class="MvvmSampleUwp.Views.INotifyPropertyChangedAttributePage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:MvvmSampleUwp.Controls"
6+
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
NavigationCacheMode="Enabled"
11+
mc:Ignorable="d">
12+
<interactivity:Interaction.Behaviors>
13+
<core:EventTriggerBehavior EventName="Loaded">
14+
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="INotifyPropertyChangedAttribute" />
15+
</core:EventTriggerBehavior>
16+
</interactivity:Interaction.Behaviors>
17+
18+
<ScrollViewer Padding="{StaticResource DocumentationPageContentPadding}" CanContentRenderOutsideBounds="True">
19+
<StackPanel Spacing="16">
20+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('INotifyPropertyChanged attributes'), Mode=OneWay}" />
21+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('How to use them'), Mode=OneWay}" />
22+
</StackPanel>
23+
</ScrollViewer>
24+
</Page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.DependencyInjection;
6+
using MvvmSample.Core.ViewModels;
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace MvvmSampleUwp.Views;
10+
11+
/// <summary>
12+
/// An empty page that can be used on its own or navigated to within a Frame.
13+
/// </summary>
14+
public sealed partial class INotifyPropertyChangedAttributePage : Page
15+
{
16+
public INotifyPropertyChangedAttributePage()
17+
{
18+
this.InitializeComponent();
19+
20+
DataContext = Ioc.Default.GetRequiredService<SamplePageViewModel>();
21+
}
22+
23+
public SamplePageViewModel ViewModel => (SamplePageViewModel)DataContext;
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Page
2+
x:Class="MvvmSampleUwp.Views.ObservablePropertyAttributePage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:MvvmSampleUwp.Controls"
6+
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
NavigationCacheMode="Enabled"
11+
mc:Ignorable="d">
12+
<interactivity:Interaction.Behaviors>
13+
<core:EventTriggerBehavior EventName="Loaded">
14+
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="ObservablePropertyAttribute" />
15+
</core:EventTriggerBehavior>
16+
</interactivity:Interaction.Behaviors>
17+
18+
<ScrollViewer Padding="{StaticResource DocumentationPageContentPadding}" CanContentRenderOutsideBounds="True">
19+
<StackPanel Spacing="16">
20+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('ObservableProperty attribute'), Mode=OneWay}" />
21+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('How it works'), Mode=OneWay}" />
22+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Running code upon changes'), Mode=OneWay}" />
23+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Notifying dependent properties'), Mode=OneWay}" />
24+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Notifying dependent commands'), Mode=OneWay}" />
25+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Requesting property validation'), Mode=OneWay}" />
26+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Sending notification messages'), Mode=OneWay}" />
27+
</StackPanel>
28+
</ScrollViewer>
29+
</Page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.DependencyInjection;
6+
using MvvmSample.Core.ViewModels;
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace MvvmSampleUwp.Views;
10+
11+
/// <summary>
12+
/// An empty page that can be used on its own or navigated to within a Frame.
13+
/// </summary>
14+
public sealed partial class ObservablePropertyAttributePage : Page
15+
{
16+
public ObservablePropertyAttributePage()
17+
{
18+
this.InitializeComponent();
19+
20+
DataContext = Ioc.Default.GetRequiredService<SamplePageViewModel>();
21+
}
22+
23+
public SamplePageViewModel ViewModel => (SamplePageViewModel)DataContext;
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Page
2+
x:Class="MvvmSampleUwp.Views.RelayCommandAttributePage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:MvvmSampleUwp.Controls"
6+
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
NavigationCacheMode="Enabled"
11+
mc:Ignorable="d">
12+
<interactivity:Interaction.Behaviors>
13+
<core:EventTriggerBehavior EventName="Loaded">
14+
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="RelayCommandAttribute" />
15+
</core:EventTriggerBehavior>
16+
</interactivity:Interaction.Behaviors>
17+
18+
<ScrollViewer Padding="{StaticResource DocumentationPageContentPadding}" CanContentRenderOutsideBounds="True">
19+
<StackPanel Spacing="16">
20+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('RelayCommand attribute'), Mode=OneWay}" />
21+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('How it works'), Mode=OneWay}" />
22+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Command parameters'), Mode=OneWay}" />
23+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Asynchronous commands'), Mode=OneWay}" />
24+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Enabling and disabling commands'), Mode=OneWay}" />
25+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Handling concurrent executions'), Mode=OneWay}" />
26+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Handling asynchronous exceptions'), Mode=OneWay}" />
27+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('Cancel commands for asynchronous operations'), Mode=OneWay}" />
28+
</StackPanel>
29+
</ScrollViewer>
30+
</Page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.DependencyInjection;
6+
using MvvmSample.Core.ViewModels;
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace MvvmSampleUwp.Views;
10+
11+
/// <summary>
12+
/// An empty page that can be used on its own or navigated to within a Frame.
13+
/// </summary>
14+
public sealed partial class RelayCommandAttributePage : Page
15+
{
16+
public RelayCommandAttributePage()
17+
{
18+
this.InitializeComponent();
19+
20+
DataContext = Ioc.Default.GetRequiredService<SamplePageViewModel>();
21+
}
22+
23+
public SamplePageViewModel ViewModel => (SamplePageViewModel)DataContext;
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Page
2+
x:Class="MvvmSampleUwp.Views.SourceGeneratorsPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:MvvmSampleUwp.Controls"
6+
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
NavigationCacheMode="Enabled"
11+
mc:Ignorable="d">
12+
<interactivity:Interaction.Behaviors>
13+
<core:EventTriggerBehavior EventName="Loaded">
14+
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="Overview" />
15+
</core:EventTriggerBehavior>
16+
</interactivity:Interaction.Behaviors>
17+
18+
<ScrollViewer Padding="{StaticResource DocumentationPageContentPadding}" CanContentRenderOutsideBounds="True">
19+
<StackPanel Spacing="16">
20+
<controls:DocumentationBlock Text="{x:Bind ViewModel.GetParagraph('MVVM source generators'), Mode=OneWay}" />
21+
</StackPanel>
22+
</ScrollViewer>
23+
</Page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.DependencyInjection;
6+
using MvvmSample.Core.ViewModels;
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace MvvmSampleUwp.Views;
10+
11+
/// <summary>
12+
/// An empty page that can be used on its own or navigated to within a Frame.
13+
/// </summary>
14+
public sealed partial class SourceGeneratorsPage : Page
15+
{
16+
public SourceGeneratorsPage()
17+
{
18+
this.InitializeComponent();
19+
20+
DataContext = Ioc.Default.GetRequiredService<SamplePageViewModel>();
21+
}
22+
23+
public SamplePageViewModel ViewModel => (SamplePageViewModel)DataContext;
24+
}

0 commit comments

Comments
 (0)