Skip to content

Commit

Permalink
Merge pull request #80 from egvijayanand/working
Browse files Browse the repository at this point in the history
VS Extension updated to support .NET MAUI on .NET 7
  • Loading branch information
egvijayanand authored Oct 4, 2022
2 parents 6beaff1 + e52880d commit 8368663
Show file tree
Hide file tree
Showing 20 changed files with 244 additions and 250 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
</SnippetTypes>
</Header>
<Snippet>
<Code Language="XAML"><![CDATA[<b:BlazorWebView HostPage="wwwroot/index.html">
<b:BlazorWebView.RootComponents>
<b:RootComponent ComponentType="{x:Type $end$}" Selector="#app" />
</b:BlazorWebView.RootComponents>
</b:BlazorWebView>]]></Code>
<Code Language="XAML"><![CDATA[<BlazorWebView HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
<RootComponent ComponentType="{x:Type $end$}" Selector="#app" />
</BlazorWebView.RootComponents>
</BlazorWebView>]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<CodeSnippet Format="1.0.0">
<Header>
<Title>Grid Layout</Title>
<Shortcut>grid</Shortcut>
<Shortcut>grid1</Shortcut>
<Description>Code snippet for GridLayout</Description>
<Author>Vijay Anand E G</Author>
<SnippetTypes>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Pointer Gesture Recognizer</Title>
<Shortcut>pointer</Shortcut>
<Description>Code snippet for PointerGestureRecognizer</Description>
<Author>Vijay Anand E G</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="XAML"><![CDATA[<PointerGestureRecognizer />$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
<IncludeInVSIX>true</IncludeInVSIX>
<VSIXSubPath>ItemTemplates\MAUI</VSIXSubPath>
</Content>
<None Include="Assets\VijayAnand.MauiTemplates.1.7.3.nupkg" />
<None Include="Assets\VijayAnand.MauiTemplates.2.0.0.nupkg" />
<Content Include="MauiSnippets\CSharp\asyncRelayCommand.snippet">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
Expand All @@ -282,6 +282,10 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="MauiSnippets\Xaml\pointerGestureRecognizer.snippet">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
<Generator>VsixManifestGenerator</Generator>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[$RootKey$\TemplateEngine\Templates\VijayAnand.MauiTemplates\1.7.2]
[$RootKey$\TemplateEngine\Templates\VijayAnand.MauiTemplates\2.0.0]
"InstalledPath"="$PackageFolder$\ProjectTemplates"
Binary file modified src/Extensions/MauiTemplates/MauiTemplates/readme.docx
Binary file not shown.
Binary file modified src/Extensions/MauiTemplates/MauiTemplates/readme.pdf
Binary file not shown.
371 changes: 195 additions & 176 deletions src/Extensions/MauiTemplates/MauiTemplates/readme.rtf

Large diffs are not rendered by default.

62 changes: 8 additions & 54 deletions src/Extensions/MauiTemplates/MauiTemplates/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,64 +1,18 @@
What's new in ver. 1.7.6.3:
What's new in ver. 2.0.0.0:
---------------------------
CommunityToolkit.Mvvm NuGet package is out of preview and now stable, hence package version (8.0.0) updated.
Templates have been updated to support .NET MAUI on .NET 7 (RC1 - Preview release).

1. A new item template for Content Page, in both XAML and C#, with ViewModel following the MVVM design pattern.
1. A parameter named framework has been introduced that takes either net6.0 or net7.0 as its options (with net7.0 being the default value).

The ViewModels are generated with the base class titled BaseViewModel (implementation left to the user).
dotnet new mauiapp --framework net6.0

Recommended to add CommunityToolkit.Mvvm, an officially supported NuGet package, to make it easy to work with MVVM design pattern.
dotnet new mauiapp -f net7.0

These two articles can help you to get started with this brand-new NuGet package:
While creating the project within Visual Studio 2022, this would be a dropdown menu in the project creation option.

https://egvijayanand.in/2022/04/22/mvvm-made-easy/
2. For projects targeting .NET 7, option to add and configure Maui Maps NuGet package.

https://egvijayanand.in/2022/05/09/mvvm-made-easy-with-microsoft-mvvm-toolkit-part-2/

2. Added the following new Item Templates for creating a Custom View definition made available in the MAUI section in the Add New Item dialog.

Custom View and Handler (Regular) (.NET MAUI)
Custom View and Handler (Cond.) (.NET MAUI)
Custom View and Renderer (Regular) (.NET MAUI)
Custom View and Renderer (Cond.) (.NET MAUI)

Regular type template generates the Handler / Renderer source files in the Platforms folder whereas Cond. type template houses them in a single folder.

For conditional type format, ensure Conditional Compilation is configured in the project file for the build to succeed. An additional option is provisioned during project creation (or manually thereafter).

3. Added the option to configure Conditional Compilation so that platform source files can be defined anywhere in the project provided they follow a naming convention as mentioned below.

This will allow maintaining related source files in the same place, especially MAUI Handlers.

*.Standard.cs - Files targeting the BCL
*.Android.cs - Files specific to Android
*.iOS.cs - Files shared with both iOS and MacCatalyst
*.MacCatalyst.cs - Files specific to MacCatalyst
*.Tizen.cs - Files specific to Tizen
*.Windows.cs - Files specific to Windows

Parameter name: -cc | --conditional-compilation

Templates have been updated to .NET MAUI GA, stable release version. Also compatible with recent SR1 release too.

Breaking change: To make things easier, All-in-One and Class Library templates parameters for various package inclusion have been updated to Boolean parameter type.

Also check out the newly included project template for creating a Shared Class Library that produces assemblies targeting Xamarin.Forms and .NET MAUI from the same project.

With C# Markup, Global usings and Compiler directives, both Xamarin.Forms and .NET MAUI can be targeted from single project.

dotnet new sharedclasslib --name MyApp.UI

In which:

*.forms.cs source files will be specific to Xamarin.Forms
*.maui.cs source files will be specific to .NET MAUI
*.shared.cs / *.logic.cs will be common to both Xamarin.Forms and .NET MAUI

Run the command dotnet new sharedclasslib --help for further details.

https://egvijayanand.in/2022/05/25/introducing-shared-class-library-multi-target-xamarin-forms-and-dotnet-maui-from-a-single-project/

As a sample, refer to VijayAnand.Toolkit.Markup NuGet package source made available here https://github.com/egvijayanand/dotnet-maui-toolkit
Note: If project target .NET 6, selecting the Maps option will NOT have any impact.

Other features that you may give it a try:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ internal sealed partial class Vsix
{
public const string Id = "MauiTemplates.20dca96a-7311-401f-84ed-980478fb319b";
public const string Name = ".NET MAUI Project and Item Templates";
public const string Description = @".NET MAUI Project, Item Templates, and Code Snippets for Visual Studio 2022 (.NET MAUI GA and Service Releases).";
public const string Description = @".NET MAUI Project, Item Templates, and Code Snippets for Visual Studio 2022 (.NET MAUI GA and its Service Releases and .NET 7 RC1 - Preview Release).";
public const string Language = "en-US";
public const string Version = "1.7.6.3";
public const string Version = "2.0.0.0";
public const string Author = "Vijay Anand E G";
public const string Tags = "MAUI, iOS, Android, macOS, WinUI, Windows, Desktop, Mobile, Blazor, WinUI, .NET MAUI, Mac Catalyst, Templates, VS2022, Visual Studio, WinUI3, GA, Code Snippets, Unified, All-in-One, Hybrid, Tizen, Stable";
public const string Tags = "MAUI, iOS, Android, macOS, WinUI, Windows, Desktop, Mobile, Blazor, WinUI, .NET MAUI, Mac Catalyst, Templates, VS2022, Visual Studio, WinUI3, GA, Code Snippets, Unified, All-in-One, Hybrid, Tizen, Stable, .NET 7";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="MauiTemplates.20dca96a-7311-401f-84ed-980478fb319b"
Version="1.7.6.3"
Version="2.0.0.0"
Language="en-US"
Publisher="Vijay Anand E G"/>
<DisplayName>.NET MAUI Project and Item Templates</DisplayName>
<Description xml:space="preserve">.NET MAUI Project, Item Templates, and Code Snippets for Visual Studio 2022 (.NET MAUI GA and Service Releases).</Description>
<Description xml:space="preserve">.NET MAUI Project, Item Templates, and Code Snippets for Visual Studio 2022 (.NET MAUI GA and its Service Releases and .NET 7 RC1 - Preview Release).</Description>
<MoreInfo>https://egvijayanand.in/2022/04/20/all-in-one-dotnet-maui-app-project-template-what-is-new/</MoreInfo>
<License>license.txt</License>
<GettingStartedGuide>readme.rtf</GettingStartedGuide>
<ReleaseNotes>release-notes.txt</ReleaseNotes>
<Icon>Resources\Icon.png</Icon>
<PreviewImage>Resources\Icon.png</PreviewImage>
<Tags>MAUI, iOS, Android, macOS, WinUI, Windows, Desktop, Mobile, Blazor, WinUI, .NET MAUI, Mac Catalyst, Templates, VS2022, Visual Studio, WinUI3, GA, Code Snippets, Unified, All-in-One, Hybrid, Tizen, Stable</Tags>
<Tags>MAUI, iOS, Android, macOS, WinUI, Windows, Desktop, Mobile, Blazor, WinUI, .NET MAUI, Mac Catalyst, Templates, VS2022, Visual Studio, WinUI3, GA, Code Snippets, Unified, All-in-One, Hybrid, Tizen, Stable, .NET 7</Tags>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community"
Expand Down
2 changes: 1 addition & 1 deletion src/ItemTemplates/MauiPageCS/MauiPageCS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class $safeitemname$ : ContentPage
{
public $safeitemname$()
{
Content = new StackLayout
Content = new Grid
{
Children =
{
Expand Down
4 changes: 2 additions & 2 deletions src/ItemTemplates/MauiPageXaml/MauiPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:$rootnamespace$">
<ContentPage.Content>
<StackLayout>
<Grid>
<Label Text="Welcome to .NET MAUI!!!"
HorizontalOptions="Center"
TextColor="Purple"
VerticalOptions="Center"/>
</StackLayout>
</Grid>
</ContentPage.Content>
</ContentPage>
2 changes: 1 addition & 1 deletion src/ItemTemplates/MauiViewCS/MauiViewCS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class $safeitemname$ : ContentView
{
public $safeitemname$()
{
Content = new StackLayout
Content = new Grid
{
Children =
{
Expand Down
4 changes: 2 additions & 2 deletions src/ItemTemplates/MauiViewXaml/MauiView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:$rootnamespace$">
<ContentView.Content>
<StackLayout>
<Grid>
<Label Text="Welcome to .NET MAUI!!!"
HorizontalOptions="Center"
TextColor="Purple"
VerticalOptions="Center"/>
</StackLayout>
</Grid>
</ContentView.Content>
</ContentView>

0 comments on commit 8368663

Please sign in to comment.