Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues #240 and #165 #257

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions templates/csharp/xplat/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Avalonia Cross Platform Application",
"preferNameDirectory": true,
"shortName": "avalonia.xplat",
"sourceName": "AvaloniaTest",
"sourceName": "AvaloniaTest.1", //based on: https://github.com/dotnet/templating/issues/1920#issuecomment-901954876
"defaultName": "AvaloniaApplication",
"tags": {
"language": "C#",
Expand Down Expand Up @@ -74,8 +74,8 @@
{
"condition": "(RemoveViewLocator)",
"exclude": [
"AvaloniaTest/App.axaml",
"AvaloniaTest/ViewLocator.cs"
"AvaloniaTest.1/App.axaml",
"AvaloniaTest.1/ViewLocator.cs"
],
"rename": {
"App.RemoveViewLocator.axaml": "App.axaml"
Expand All @@ -84,25 +84,25 @@
{
"condition": "(!RemoveViewLocator)",
"exclude": [
"AvaloniaTest/App.RemoveViewLocator.axaml"
"AvaloniaTest.1/App.RemoveViewLocator.axaml"
]
}
]
}
],
"primaryOutputs": [
{ "path": "AvaloniaTest/AvaloniaTest.csproj" },
{ "path": "AvaloniaTest.Android/AvaloniaTest.Android.csproj" },
{ "path": "AvaloniaTest.Desktop/AvaloniaTest.Desktop.csproj" },
{ "path": "AvaloniaTest.iOS/AvaloniaTest.iOS.csproj" },
{ "path": "AvaloniaTest.Browser/AvaloniaTest.Browser.csproj" },
{ "path": "AvaloniaTest.1/AvaloniaTest.1.csproj" },
{ "path": "AvaloniaTest.1.Android/AvaloniaTest.1.Android.csproj" },
{ "path": "AvaloniaTest.1.Desktop/AvaloniaTest.1.Desktop.csproj" },
{ "path": "AvaloniaTest.1.iOS/AvaloniaTest.1.iOS.csproj" },
{ "path": "AvaloniaTest.1.Browser/AvaloniaTest.1.Browser.csproj" },
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"path": "AvaloniaTest/ViewModels/MainViewModel.cs"
"path": "AvaloniaTest.1/ViewModels/MainViewModel.cs"
},
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"path": "AvaloniaTest/Views/MainView.axaml"
"path": "AvaloniaTest.1/Views/MainView.axaml"
}
],
"postActions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>FrameworkParameter-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>com.CompanyName.AvaloniaTest</ApplicationId>
<ApplicationId>com.CompanyName.AvaloniaTest._1</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
Expand All @@ -23,6 +23,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Avalonia.Android;
using Avalonia.ReactiveUI;

namespace AvaloniaTest.Android;
namespace AvaloniaTest._1.Android;

[Activity(
Label = "AvaloniaTest.Android",
Label = "AvaloniaTest._1.Android",
Theme = "@style/MyTheme.NoActionBar",
Icon = "@drawable/icon",
MainLauncher = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="AvaloniaTest" android:icon="@drawable/Icon" />
<application android:label="AvaloniaTest.1" android:icon="@drawable/Icon" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Avalonia;
using Avalonia.Browser;
using Avalonia.ReactiveUI;
using AvaloniaTest;
using AvaloniaTest._1;

[assembly: SupportedOSPlatform("browser")]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"AvaloniaTest.Browser": {
"AvaloniaTest.1.Browser": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<title>AvaloniaTest.Browser</title>
<title>AvaloniaTest.1.Browser</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with FrameworkParameter-windows TFM, one for MacOS with FrameworkParameter-macos and one with FrameworkParameter TFM for Linux.-->
<TargetFramework>FrameworkParameter</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with FrameworkParameter-windows TFM, one for MacOS with FrameworkParameter-macos and one with FrameworkParameter TFM for Linux.-->
<TargetFramework>FrameworkParameter</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>

<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
using System;
using Avalonia;
using Avalonia.ReactiveUI;
namespace AvaloniaTest.Desktop;
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
}
using System;
using Avalonia;
using Avalonia.ReactiveUI;

namespace AvaloniaTest._1.Desktop;

sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="AvaloniaTest.Desktop"/>
<assemblyIdentity version="1.0.0.0" name="AvaloniaTest._1.Desktop"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Avalonia.Media;
using Avalonia.ReactiveUI;

namespace AvaloniaTest.iOS;
namespace AvaloniaTest._1.iOS;

// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>AvaloniaTest</string>
<string>AvaloniaTest.1</string>
<key>CFBundleIdentifier</key>
<string>companyName.AvaloniaTest</string>
<string>companyName.AvaloniaTest._1</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UIKit;

namespace AvaloniaTest.iOS;
namespace AvaloniaTest._1.iOS;

public class Application
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
<nil key="highlightedColor" />
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AvaloniaTest" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AvaloniaTest.1" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43" />
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest", "AvaloniaTest\AvaloniaTest.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1", "AvaloniaTest.1\AvaloniaTest.1.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.Desktop", "AvaloniaTest.Desktop\AvaloniaTest.Desktop.csproj", "{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.Desktop", "AvaloniaTest.1.Desktop\AvaloniaTest.1.Desktop.csproj", "{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.Browser", "AvaloniaTest.Browser\AvaloniaTest.Browser.csproj", "{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.Browser", "AvaloniaTest.1.Browser\AvaloniaTest.1.Browser.csproj", "{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.iOS", "AvaloniaTest.iOS\AvaloniaTest.iOS.csproj", "{EBD9022F-BC83-4846-9A11-6F7F3772DC64}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.iOS", "AvaloniaTest.1.iOS\AvaloniaTest.1.iOS.csproj", "{EBD9022F-BC83-4846-9A11-6F7F3772DC64}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.Android", "AvaloniaTest.Android\AvaloniaTest.Android.csproj", "{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.Android", "AvaloniaTest.1.Android\AvaloniaTest.1.Android.csproj", "{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DA99C4E-89E3-4049-9C22-0A7EC60D83D8}"
ProjectSection(SolutionItems) = preProject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaloniaTest.App"
x:Class="AvaloniaTest._1.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AvaloniaTest"
x:Class="AvaloniaTest.App"
xmlns:local="using:AvaloniaTest._1"
x:Class="AvaloniaTest._1.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using AvaloniaTest.ViewModels;
using AvaloniaTest.Views;
namespace AvaloniaTest;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainViewModel()
};
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
DataContext = new MainViewModel()
};
}
base.OnFrameworkInitializationCompleted();
}
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using AvaloniaTest._1.ViewModels;
using AvaloniaTest._1.Views;

namespace AvaloniaTest._1;

public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainViewModel()
};
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
DataContext = new MainViewModel()
};
}

base.OnFrameworkInitializationCompleted();
}
}
Loading