Skip to content

Commit

Permalink
Merge pull request #73 from egvijayanand/working
Browse files Browse the repository at this point in the history
Custom View definition with Handlers / Renderers
  • Loading branch information
egvijayanand authored Jun 23, 2022
2 parents 86eba57 + 37600fc commit 1336679
Show file tree
Hide file tree
Showing 20 changed files with 569 additions and 482 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## .NET MAUI Project and Item Templates
This repository is to host the .NET MAUI Project Templates, Item Templates and Code Snippets.

Join me on [**Developer Thoughts**](https://egvijayanand.in/), an exclusive blog for .NET MAUI and Blazor, for articles on working with these templates and much more.
Join me on [**Developer Thoughts**](https://egvijayanand.in/ "Developer Thoughts"), an exclusive blog for .NET MAUI and Blazor, for articles on working with these templates and much more.

We all know that .NET MAUI is an evolution of Xamarin.Forms.

Expand All @@ -17,13 +17,13 @@ Templates have been updated to support the latest release and is available to in

To provide an integrated experience, a VS extension has been developed to host these templates.

Extension is made available in the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=egvijayanand.maui-templates) and even more easier, can be installed from within Visual Studio itself (Extensions -> Manage Extensions / Alt + X + M).
Extension is made available in the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=egvijayanand.maui-templates ".NET MAUI Templates Pack") and even more easier, can be installed from within Visual Studio itself (Extensions -> Manage Extensions / Alt + X + M).

![Manage Extensions - Visual Studio](images/vs-manage-extensions.png)

This has Project Templates for:

* .NET MAUI App - An All-in-One .NET MAUI App Project Template - For more details, check out this [article](https://egvijayanand.in/all-in-one-dotnet-maui-app-project-template/)
* .NET MAUI App - An All-in-One .NET MAUI App Project Template - For more details, check out this [article](https://egvijayanand.in/all-in-one-dotnet-maui-app-project-template/ "All-in-One .NET MAUI App Project Template")
* .NET MAUI App (C#)
* .NET MAUI Class Library
* Shared Class Library (Xamarin.Forms and .NET MAUI)
Expand All @@ -39,12 +39,14 @@ And has Item Templates for:
* Resource Dictionary (.NET MAUI)
* Resource Dictionary (XAML only)(.NET MAUI)
* Shell Page (.NET MAUI)
* .NET MAUI Custom View and Handler (Regular)
* Custom View and Handler (Regular) (.NET MAUI)
- Handler definitions generated in the Platforms folder
* .NET MAUI Custom View and Handler (Cond.)
* Custom View and Handler (Cond.) (.NET MAUI)
- Handler definitions generated in the same folder in conditional compilation format
* .NET MAUI Custom View and Renderer (Regular)
* Custom View and Renderer (Regular) (.NET MAUI)
- Renderer definitions generated in the Platforms folder
* Custom View and Renderer (Cond.) (.NET MAUI)
- Renderer definitions generated in the same folder in conditional compilation format
\
 
* For Cond. type template to work properly, ensure Conditional Compilation is enabled (mentioned in detail [**here**](https://github.com/egvijayanand/dotnet-maui-templates#conditional-compilation "Conditional Compilation"))
Expand Down Expand Up @@ -152,8 +154,8 @@ For existing projects, add the below block of code in the project file (.csproj)
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'maccatalyst'">
<Compile Remove="**\*.macOS.cs" />
<None Include="**\*.macOS.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\*.MacCatalyst.cs" />
<None Include="**\*.MacCatalyst.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\MacCatalyst\**\*.cs" />
<None Include="**\MacCatalyst\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
Expand Down
Binary file modified images/add-new-item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -255,6 +255,11 @@
<IncludeInVSIX>true</IncludeInVSIX>
<VSIXSubPath>ItemTemplates\MAUI</VSIXSubPath>
</Content>
<Content Include="ItemTemplates\MauiRenderer.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
<VSIXSubPath>ItemTemplates\MAUI</VSIXSubPath>
</Content>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
<Generator>VsixManifestGenerator</Generator>
Expand Down
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.
977 changes: 525 additions & 452 deletions src/Extensions/MauiTemplates/MauiTemplates/readme.rtf

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions src/Extensions/MauiTemplates/MauiTemplates/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
What's new in ver. 1.7.4.1:
What's new in ver. 1.7.5.0:
---------------------------
1. Added the following new Item Templates for creating a Custom View definition made available in the MAUI section in the Add New Item dialog.

.NET MAUI Custom View and Handler (Regular)
.NET MAUI Custom View and Handler (Cond.)
.NET MAUI Custom View and Renderer (Regular)
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 source files in the Platforms folder whereas Cond. type template houses them in a single folder.
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 provided during project creation (or thereafter manually).
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).

2. 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.

Expand All @@ -23,11 +24,11 @@ This will allow maintaining related source files in the same place, especially M

Parameter name: -cc | --conditional-compilation

Templates have been updated to .NET MAUI GA, stable release version.
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.
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.

Expand All @@ -41,7 +42,9 @@ In which:

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

Refer to VijayAnand.Toolkit.Markup NuGet package source made available here https://github.com/egvijayanand/dotnet-maui-toolkit for a sample.
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

Other features that you may give it a try:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed partial class Vsix
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 SR1).";
public const string Language = "en-US";
public const string Version = "1.7.4.1";
public const string Version = "1.7.5.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";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="MauiTemplates.20dca96a-7311-401f-84ed-980478fb319b"
Version="1.7.4.1"
Version="1.7.5.0"
Language="en-US"
Publisher="Vijay Anand E G"/>
<DisplayName>.NET MAUI Project and Item Templates</DisplayName>
Expand Down Expand Up @@ -33,7 +33,7 @@
</Installation>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor"
Version="[17.2,)"
Version="[17.3,)"
DisplayName="Visual Studio core editor"/>
<Prerequisite Id="Microsoft.VisualStudio.ComponentGroup.Maui.All"
Version="[17.3.32505.122,18.0)"
Expand Down Expand Up @@ -103,6 +103,10 @@
Path="ItemTemplates"
TargetVersion="[17.3, 18.0)"
d:TargetPath="ItemTemplates\MauiHandlerReg.zip" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate"
d:Source="File" Path="ItemTemplates"
TargetVersion="[17.3, 18.0)"
d:TargetPath="ItemTemplates\MauiRenderer.zip" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate"
d:Source="File" Path="ItemTemplates"
TargetVersion="[17.3, 18.0)"
Expand Down
2 changes: 1 addition & 1 deletion src/ItemTemplates/MauiHandler/MauiHandler.vstemplate
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>CustomView.cs</DefaultName>
<Name>.NET MAUI Custom View and Handler (Cond.)</Name>
<Name>Custom View and Handler (Cond.) (.NET MAUI)</Name>
<Description>.NET MAUI Custom View and its Handler definition (in conditional compilation format).</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>MAUI</ProjectSubType>
Expand Down
2 changes: 1 addition & 1 deletion src/ItemTemplates/MauiHandlerReg/MauiHandlerReg.vstemplate
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>CustomView.cs</DefaultName>
<Name>.NET MAUI Custom View and Handler (Regular)</Name>
<Name>Custom View and Handler (Regular) (.NET MAUI)</Name>
<Description>.NET MAUI Custom View and its Handler definition in the Platforms folder.</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>MAUI</ProjectSubType>
Expand Down
6 changes: 3 additions & 3 deletions src/ItemTemplates/MauiRenderer/MauiRenderer.vstemplate
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>CustomView.cs</DefaultName>
<Name>.NET MAUI Custom View and Renderer (Cond.)</Name>
<Name>Custom View and Renderer (Cond.) (.NET MAUI)</Name>
<Description>.NET MAUI Custom View and its Renderer definitions (in conditional compilation format).</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>MAUI</ProjectSubType>
<SortOrder>120</SortOrder>
<SortOrder>140</SortOrder>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
Expand All @@ -17,7 +17,7 @@
<Folder Name="Renderers" TargetFolderName="Renderers">
<ProjectItem TargetFileName="$fileinputname$Renderer.Android.cs" ReplaceParameters="true">CustomViewRenderer.Android.cs</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$Renderer.iOS.cs" ReplaceParameters="true">CustomViewRenderer.iOS.cs</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$Renderer.MacCatalyst.cs" ReplaceParameters="true">CustomViewRenderer.MacCatalyst.cs</ProjectItem>
<!-- <ProjectItem TargetFileName="$fileinputname$Renderer.MacCatalyst.cs" ReplaceParameters="true">CustomViewRenderer.MacCatalyst.cs</ProjectItem> -->
<!-- <ProjectItem TargetFileName="$fileinputname$Renderer.Tizen.cs" ReplaceParameters="true">CustomViewRenderer.Tizen.cs</ProjectItem> -->
<ProjectItem TargetFileName="$fileinputname$Renderer.Windows.cs" ReplaceParameters="true">CustomViewRenderer.Windows.cs</ProjectItem>
</Folder>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace $rootnamespace$
{
public class $safeitemname$ : ViewRenderer<$fileinputname$, TPlatformView>
public partial class $safeitemname$ : ViewRenderer<$fileinputname$, TPlatformView>
{
public $safeitemname$(Context context) : base(context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace $rootnamespace$
{
public class $safeitemname$ : ViewRenderer<$fileinputname$, TPlatformView>
public partial class $safeitemname$ : ViewRenderer<$fileinputname$, TPlatformView>
{
public $safeitemname$()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace $rootnamespace$
{
public class $safeitemname$ : ViewRenderer<$fileinputname$, TPlatformView>
public partial class $safeitemname$ : ViewRenderer<$fileinputname$, TPlatformView>
{
public $safeitemname$()
{
Expand Down
4 changes: 2 additions & 2 deletions src/ItemTemplates/MauiRendererReg/MauiRendererReg.vstemplate
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>CustomView.cs</DefaultName>
<Name>.NET MAUI Custom View and Renderer (Regular)</Name>
<Name>Custom View and Renderer (Regular) (.NET MAUI)</Name>
<Description>.NET MAUI Custom View and its Renderer definition in the Platforms folder.</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>MAUI</ProjectSubType>
<SortOrder>110</SortOrder>
<SortOrder>130</SortOrder>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
Expand Down

0 comments on commit 1336679

Please sign in to comment.