Skip to content

Commit

Permalink
Merge pull request #36 from egvijayanand/working
Browse files Browse the repository at this point in the history
Support for XML-based solution file (`slnx`) and `PolySharp` NuGet package
  • Loading branch information
egvijayanand authored Aug 22, 2024
2 parents b592ad0 + 114222c commit 412a72a
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 4 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,36 @@ Explicit option:

* `-inm` | `--include-maps` - Default value is `false`
* `-iei` | `--include-essentials-interfaces` - Default value is `false`
* `-ips` | `--include-polysharp` - Default value is `false`
* `-slnx` | `--use-slnx` - Default value is `false`

*Note: The NuGet package version being added out-of-the-box are v5.x for the Xamarin packages, v2.x for the Xamarin Toolkit packages, v1.x for the Xamarin.Essentials package, and v8.x for the MVVM Toolkit package. The latest stable version.*

Starting with [v1.5.0](https://www.nuget.org/packages/VijayAnand.FormsTemplates/1.5.0), library project template take the below optional parameter support NuGet's Central Package Management (CPM) feature.

* `-cpm` | `--central-pkg-mgmt` - Default value is `false`

Starting with [v1.6.0](https://www.nuget.org/packages/VijayAnand.FormsTemplates/1.6.0), added the ability to reference the Xamarin.Essentials.Interfaces NuGet package.

* `-iei` | `--include-essentials-interfaces` - Default value is `false`

Starting with [v1.7.0](https://www.nuget.org/packages/VijayAnand.FormsTemplates/1.7.0), introduced the innovative Generic Item Templates for XAML and C#. Covered in detail [here](#generic-item-templates).

Starting with [v1.8.0](https://www.nuget.org/packages/VijayAnand.FormsTemplates/1.8.0), added the ability to use the NuGet Central Package Management (CPM) feature within Visual Studio IDE.

Starting with [v1.9.0](https://www.nuget.org/packages/VijayAnand.FormsTemplates/1.9.0), added the ability to reference the Xamarin.Forms.Maps NuGet package.

* `-inm` | `--include-maps` - Default value is `false`

Starting with [v1.10.0](https://www.nuget.org/packages/VijayAnand.FormsTemplates/1.10.0), introduced the option to reference the [PolySharp](https://www.nuget.org/packages/PolySharp) NuGet package and support for the XML-based solution file format (`slnx`).

* `-ips` | `--include-polysharp` - Default value is `false`
* `-slnx` | `--use-slnx` - Default value is `false`

*This would be an explicit option since the SLNX feature is currently in the preview stage and is only supported on VS2022.*

*Note: These options may also be combined.*

|Item|Template Name|
|:---:|:---:|
|[Xamarin.Forms Item (XAML)](#generic-item-templates)|forms-item|
Expand Down
Binary file modified images/xamarin-forms-class-library-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"Preview": {
"longName": "preview",
"shortName": "pre"
},
"include-polysharp": {
"shortName": "ips"
},
"use-slnx": {
"shortName": "slnx"
}
},
"usageExamples": [
Expand Down
16 changes: 16 additions & 0 deletions src/FormsTemplatesCLI/FormsClassLib/.template.config/ide.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
"$schema": "http://json.schemastore.org/vs-2017.3.host",
"icon": "ide/icon.png",
"symbolInfo": [
{
"id": "use-slnx",
"name": {
"text": "Use XML-based solution file (sln_x)."
},
"isVisible": true,
"defaultValue": "false"
},
{
"id": "central-pkg-mgmt",
"name": {
Expand Down Expand Up @@ -50,6 +58,14 @@
"isVisible": true,
"defaultValue": "false"
},
{
"id": "include-polysharp",
"name": {
"text": "Add _PolySharp NuGet package reference"
},
"isVisible": true,
"defaultValue": "false"
},
{
"id": "include-shared-toolkit",
"name": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
"replaces": "LIB_TFM",
"defaultValue": "netstandard2.0"
},
"use-slnx": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Option to use XML-based solution file (slnx).",
"displayName": "Option to use XML-based solution file (sln_x)"
},
"central-pkg-mgmt": {
"type": "parameter",
"datatype": "bool",
Expand Down Expand Up @@ -87,6 +94,13 @@
"description": "If true, includes reference to the CommunityToolkit.Mvvm (aka Microsoft MVVM Toolkit) NuGet package.",
"displayName": "Add CommunityToolkit.Mvvm (aka Microsoft MV_VM Toolkit) NuGet package reference"
},
"include-polysharp": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "If true, includes reference to the PolySharp NuGet package.",
"displayName": "Add _PolySharp NuGet package reference"
},
"include-shared-toolkit": {
"type": "parameter",
"datatype": "bool",
Expand Down Expand Up @@ -121,6 +135,13 @@
"defaultValue": "false",
"description": "Option to skip creating a solution file."
},
"xmlEncodedName": {
"type": "derived",
"datatype": "string",
"replaces": "SAFE-NAME",
"valueSource": "name",
"valueTransform": "xmlEncode"
},
"AddToolkit": {
"type": "computed",
"value": "(include-toolkit || all-supported-packages)"
Expand All @@ -145,6 +166,10 @@
"type": "computed",
"value": "(include-mvvm-toolkit || all-supported-packages)"
},
"AddPolySharp": {
"type": "computed",
"value": "(include-polysharp)"
},
"AddSharedToolkit": {
"type": "computed",
"value": "(include-shared-toolkit || all-supported-packages)"
Expand All @@ -153,6 +178,18 @@
"type": "computed",
"value": "(central-pkg-mgmt)"
},
"SolnFile": {
"type": "computed",
"value": "(!no-solution-file)"
},
"UseSlnx": {
"type": "computed",
"value": "(use-slnx)"
},
"NoPolySharp": {
"type": "computed",
"value": "(!include-polysharp)"
},
"HostIdentifier": {
"type": "bind",
"binding": "HostIdentifier"
Expand All @@ -167,9 +204,25 @@
{
"modifiers": [
{
"condition": "(no-solution-file)",
"condition": "(!SolnFile)",
"exclude": [
"FormsClassLib.1.sln",
"FormsClassLib.1.xml"
]
},
{
"condition": "(UseSlnx)",
"exclude": [
"FormsClassLib.1.sln"
],
"rename": {
"FormsClassLib.1.xml": "FormsClassLib.1.slnx"
}
},
{
"condition": "(!UseSlnx)",
"exclude": [
"FormsClassLib.1.xml"
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/FormsTemplatesCLI/FormsClassLib/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
#if NoPolySharp

// For making use of C# 9.0 features such as Records.

namespace System.Runtime.CompilerServices
{
internal class IsExternalInit { }
}
#endif
6 changes: 6 additions & 0 deletions src/FormsTemplatesCLI/FormsClassLib/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<!--#if (AddMvvmToolkit)-->
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<!--#endif-->
<!--#if (AddPolySharp)-->
<PackageVersion Include="PolySharp" Version="1.14.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<!--#endif-->
<!--#if (AddSharedToolkit)-->
<!--#if (Preview)-->
<PackageVersion Include="VijayAnand.Toolkit.Markup" Version="4.0.0-preview.3" />
Expand Down
9 changes: 9 additions & 0 deletions src/FormsTemplatesCLI/FormsClassLib/FormsClassLib.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<!--#if (AddMvvmToolkit)-->
<PackageReference Include="CommunityToolkit.Mvvm" />
<!--#endif-->
<!--#if (AddPolySharp)-->
<PackageReference Include="PolySharp" />
<!--#endif-->
<!--#if (AddSharedToolkit)-->
<PackageReference Include="VijayAnand.Toolkit.Markup" />
<!--#endif-->
Expand All @@ -63,6 +66,12 @@
<!--#if (AddMvvmToolkit)-->
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.*" />
<!--#endif-->
<!--#if (AddPolySharp)-->
<PackageReference Include="PolySharp" Version="1.*">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<!--#endif-->
<!--#if (AddSharedToolkit)-->
<!--#if (Preview)-->
<PackageReference Include="VijayAnand.Toolkit.Markup" Version="4.*-*" />
Expand Down
12 changes: 12 additions & 0 deletions src/FormsTemplatesCLI/FormsClassLib/FormsClassLib.1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Solution>
<!--#if (CentralPkgMgmt)-->
<Folder Name="/Solution Items/">
<File Path="Directory.Packages.props" />
</Folder>
<!--#endif-->
<Project Path="SAFE-NAME.csproj" />
<Properties Name="Visual Studio">
<!-- Support is provisionally available on Visual Studio 17.10 and later versions. -->
<Property Name="OpenWith" Value="17" />
</Properties>
</Solution>
2 changes: 1 addition & 1 deletion src/FormsTemplatesCLI/FormsClassLib/HomePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using Xamarin.CommunityToolkit.ObjectModel;
using Xamarin.CommunityToolkit.UI.Views;
#endif
#if AddMarkup
#if (AddMarkup || AddSharedToolkit)

using Xamarin.CommunityToolkit.Markup;
#endif
Expand Down
49 changes: 49 additions & 0 deletions src/FormsTemplatesCLI/FormsClassLib/Imports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
global using Xamarin.Forms;
global using Xamarin.Forms.Xaml;
#if AddMaps
global using Xamarin.Forms.Maps;
#endif
#if (AddEssentials || AddEssentialsInterfaces)
global using Xamarin.Essentials;
#endif
#if AddEssentialsInterfaces
global using Xamarin.Essentials.Implementation;
global using Xamarin.Essentials.Interfaces;
#endif
#if AddToolkit
global using Xamarin.CommunityToolkit.Behaviors;
global using Xamarin.CommunityToolkit.Converters;
global using Xamarin.CommunityToolkit.Effects;
global using Xamarin.CommunityToolkit.ObjectModel;
global using Xamarin.CommunityToolkit.UI.Views;
#endif
#if (AddMarkup || AddSharedToolkit)
global using Xamarin.CommunityToolkit.Markup;
#endif
#if AddMvvmToolkit
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
global using CommunityToolkit.Mvvm.Messaging;
#endif
#if AddSharedToolkit
global using VijayAnand.Toolkit.Markup;
#endif
#if AddSharedToolkit
// Static
global using static Xamarin.CommunityToolkit.Markup.GridRowsColumns;
global using static VijayAnand.Toolkit.Markup.ResourceHelper;
global using static VijayAnand.Toolkit.Markup.VisualStateHelper;
#elif AddMarkup
// Static
global using static Xamarin.CommunityToolkit.Markup.GridRowsColumns;
#endif
*/
20 changes: 18 additions & 2 deletions src/FormsTemplatesCLI/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
Join me on Developer Thoughts (https://egvijayanand.in/), an exclusive blog for articles on Xamarin.Forms, .NET MAUI and Blazor.

What's new in ver. 1.9.0:
-------------------------
What's new in ver. 1.10.0:
--------------------------
1. Introduced an option to support the XML-based solution file (slnx) format.

This would be an explicit option since the SLNX feature is currently in the preview stage and is only supported on VS2022.

-slnx | --use-slnx - Default value is false

dotnet new formsclasslib -o FormsLib -slnx

2. Introduced the option to include a reference to the PolySharp NuGet package.

-ips | --include-polysharp - Default value is false

dotnet new formsclasslib -o FormsLib -ips

v1.9.0:

1. Introduced an option to reference Xamarin.Forms.Maps NuGet package.

2. While using the generic item template, support for adding Xamarin Community Toolkit namespace while defining base types with that particular xmlns scope (xct).
Expand Down

0 comments on commit 412a72a

Please sign in to comment.