Skip to content

Commit

Permalink
Merge pull request #44 from SuessLabs/feature/ViewModelTemplate
Browse files Browse the repository at this point in the history
Add ViewModel Item Template
  • Loading branch information
DamianSuess authored Aug 26, 2024
2 parents 60b2ce5 + a90232a commit 8c7ff5b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Prism.Avalonia.Templates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>

<ItemGroup>
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**;templates\app-prism-8-*\;templates\app-prism-full\;templates\**\.vs\" />
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**;templates\app-prism-8-*\;templates\**\.vs\" />
<Compile Remove="**\*" />
<None Include="readme.md" Pack="true" PackagePath="\" />
<None Include="Prism.Avalonia.png" Pack="true" PackagePath="\" />
Expand Down
22 changes: 16 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ dotnet new install Templates.Prism.Avalonia

The templates are now be available in `dotnet new list`:

### Project Templates

```txt
Template Name Short Name Language Tags
------------------------------------ -------------------------- -------- -----------------------------------------------------
Prism.Avalonia .NET - Empty App prism.avalonia.app [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism.Avalonia .NET - Sample Dialog App prism.avalonia.app.dialog [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism.Avalonia .NET - Sample Full SideBar App prism.avalonia.app.full [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
```

### Item Templates

```txt
Template Name Short Name Language Tags
------------------------------------ -------------------------- -------- -----------------------------------------------------
Prism.Avalonia .NET MVVM App prism.avalonia.app [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism.Avalonia .NET MVVM App Sample prism.avalonia.app.sample [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism.Avalonia .NET MVVM Dialog App prism.avalonia.app.dialog [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism Avalonia Event prism.avalonia.event [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism Avalonia UserControl prism.avalonia.usercontrol [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism Avalonia Window prism.avalonia.window [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism Avalonia Event prism.avalonia.event [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism Avalonia UserControl prism.avalonia.usercontrol [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism Avalonia ViewModel prism.avalonia.viewmodel [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
Prism Avalonia Window prism.avalonia.window [C#] Desktop/Xaml/Axaml/Avalonia/Prism/Windows/Linux/macOS
```

## Contributing
Expand Down
26 changes: 26 additions & 0 deletions templates/csharp/viewmodel/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Damian Suess",
"classifications": [ "Desktop", "Xaml", "Axaml", "Avalonia", "Prism", "Windows", "Linux", "macOS" ],
"defaultName": "ViewModel",
"description": "A Prism ViewModel",
"groupidentity": "Prism.Avalonia.ViewModel",
"identity": "Prism.Avalonia.ViewModel",
"name": "Prism Avalonia ViewModel",
"primaryOutputs": [
{ "path": "ViewModel.cs" }
],
"shortName": "prism.avalonia.viewmodel",
"sourceName": "ViewModel",
"symbols": {
"namespace": {
"description": "Namespace for the generated code",
"replaces": "SampleApp.ViewModels",
"type": "parameter"
}
},
"tags": {
"language": "C#",
"type": "item"
}
}
8 changes: 8 additions & 0 deletions templates/csharp/viewmodel/NewViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Prism.Mvvm;

namespace PrismAvaloniaTemplate.ViewModels;

public class NewViewModel : BindableBase
{

}
18 changes: 9 additions & 9 deletions tests/build-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ Template options:
-A, --AvaloniaVersion <11.0.7|11.1.3> The target version of Avalonia NuGet packages.
Type: choice
11.1.3 Target 11.1.3 (default)
11.0.7 Target 11.0.7
Default: 11.1.3
-P, --PrismVersion <9.0.537.11130> The target version of Prism.Avalonia NuGet packages.
Type: choice
9.0.537.11130 Target 9.0.537.11130 (Latest stable).
8.1.97.11073 Target 8.1.97.11073.
Default: 8.1.97.11073
#>

Expand Down Expand Up @@ -91,7 +89,8 @@ function Test-Template {

# Instantiate each item template in the project
Exec { dotnet new prism.avalonia.event -o $outDir/$lang/$folderName -n NewEvent -lang $lang }
Exec { dotnet new prism.avalonia.usercontrol -o $outDir/$lang/$folderName -n NewUserControl }
Exec { dotnet new prism.avalonia.usercontrol -o $outDir/$lang/$folderName/Views -n NewUserControl }
Exec { dotnet new prism.avalonia.viewmodel -o $outDir/$lang/$folderName/ViewModels -n NewViewModel }
Exec { dotnet new prism.avalonia.window -o $outDir/$lang/$folderName -n NewWindow }

# Build
Expand Down Expand Up @@ -146,21 +145,22 @@ if (Test-Path $binLogDir -ErrorAction SilentlyContinue) {
$binlog = [IO.Path]::GetFullPath([IO.Path]::Combine($pwd, "output", "binlog", "test.binlog"))

# Build the project only once with all item templates using .net8.0 tfm for C#
Test-Template "prism.avalonia.app.full" "TestAvaloniaItems" "C#" "A" "$latestAvalonia" $binlog
Test-Template "prism.avalonia.app" "TestAvaloniaItems" "C#" "A" "$latestAvalonia" $binlog
##Test-Template "prism.avalonia.app.full" "TestAvaloniaItems" "C#" "A" "$latestAvalonia" $binlog

# Bare-bones app
Create-And-Build "prism.avalonia.app" "TestAvaloniaBase" "C#" "A" "$latestAvalonia" $binlog
# Create-And-Build "prism.avalonia.app" "TestAvaloniaBase6" "C#" "F" "net6.0" $binlog

# Base MVVM App Template Tests
# Create-And-Build "prism.avalonia.app.full" "TestAvaloniaMvvm" "C#" "A" "$latestAvalonia" $binlog
# Create-And-Build "prism.avalonia.app.full" "TestAvaloniaMvvm" "C#" "A" "$olderAvalonia" $binlog
# Create-And-Build "prism.avalonia.app.full" "TestAvaloniaMvvm" "C#" "F" "net6.0" $binlog

# Dialog App Template Tests
Create-And-Build "prism.avalonia.app.dialog" "TestAvaloniaDialog" "C#" "A" "$latestAvalonia" $binlog
#Create-And-Build "prism.avalonia.app.dialog" "TestAvaloniaDialog" "C#" "A" "$olderAvalonia" $binlog

# Full (most-features) MVVM App Template Tests
Create-And-Build "prism.avalonia.app.full" "TestAvaloniaMvvm" "C#" "A" "$latestAvalonia" $binlog
# Create-And-Build "prism.avalonia.app.full" "TestAvaloniaMvvm" "C#" "A" "$olderAvalonia" $binlog
# Create-And-Build "prism.avalonia.app.full" "TestAvaloniaMvvm" "C#" "F" "net6.0" $binlog

# desktop/android/ios/browser (not implemented)
# Create-And-Build "prism.avalonia.xplat" "PrismAvaloniaXplat" "C#" "f" "net8.0" $binlog
# Create-And-Build "prism.avalonia.xplat" "PrismAvaloniaXplat" "C#" "av" "$latestAvalonia" $binlog
Expand Down

0 comments on commit 8c7ff5b

Please sign in to comment.