Skip to content

Commit

Permalink
Merge pull request #42 from Axemasta/feature/net-9
Browse files Browse the repository at this point in the history
Target .NET 9
  • Loading branch information
Axemasta authored Nov 21, 2024
2 parents 1c85e70 + 9dba395 commit a090231
Show file tree
Hide file tree
Showing 88 changed files with 519 additions and 287 deletions.
12 changes: 6 additions & 6 deletions directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
</PropertyGroup>

<PropertyGroup>
<MauiVersion>8.0.70</MauiVersion>
<MauiVersion>9.0.10</MauiVersion>

<StandardTargetFramework>net8.0</StandardTargetFramework>
<IosTargetFramework>net8.0-ios</IosTargetFramework>
<AndroidTargetFramework>net8.0-android</AndroidTargetFramework>
<MacTargetFramework>net8.0-maccatalyst</MacTargetFramework>
<WindowsTargetFramework>net8.0-windows10.0.19041.0</WindowsTargetFramework>
<StandardTargetFramework>net9.0</StandardTargetFramework>
<IosTargetFramework>net9.0-ios</IosTargetFramework>
<AndroidTargetFramework>net9.0-android</AndroidTargetFramework>
<MacTargetFramework>net9.0-maccatalyst</MacTargetFramework>
<WindowsTargetFramework>net9.0-windows10.0.19041.0</WindowsTargetFramework>

<MauiPlatformTargetFrameworks>$(StandardTargetFramework);$(AndroidTargetFramework);$(IosTargetFramework);$(MacTargetFramework);</MauiPlatformTargetFrameworks>
<MauiPlatformTargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(StandardTargetFramework);$(AndroidTargetFramework);$(IosTargetFramework);$(MacTargetFramework);$(WindowsTargetFramework);</MauiPlatformTargetFrameworks>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.204"
"version": "9.0.100"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseMaui>true</UseMaui>
<NoWarn>$(NoWarn);IDE0005</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions samples/Mocale.Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\.editorconfig = ..\.editorconfig
..\directory.build.props = ..\directory.build.props
..\global.json = ..\global.json
..\version.json = ..\version.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mocale.Providers.Azure.Blob", "..\src\Mocale.Providers.Azure.Blob\Mocale.Providers.Azure.Blob.csproj", "{1BF264ED-14A2-4847-9578-9312BF9ECFA9}"
Expand Down
5 changes: 4 additions & 1 deletion samples/Mocale.Samples/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

MainPage = new AppShell();
protected override Window CreateWindow(IActivationState activationState)
{
return new Window(new AppShell());
}
}
11 changes: 6 additions & 5 deletions samples/Mocale.Samples/Mocale.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<RootNamespace>Mocale.Samples</RootNamespace>
<SingleProject>true</SingleProject>
<ImplicitUsings>true</ImplicitUsings>

<NoWarn>$(NoWarn);IDE0005</NoWarn>
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
<MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>

<!-- Display name -->
<ApplicationTitle>Mocale.Samples</ApplicationTitle>
Expand All @@ -21,8 +22,8 @@
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">12.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
Expand Down Expand Up @@ -62,8 +63,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
49 changes: 26 additions & 23 deletions samples/Mocale.Samples/ObjectModel/ObservableRangeCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,38 @@
using System.Collections.Specialized;
using System.ComponentModel;

//Resharper disable all
#pragma warning disable

namespace Mocale.Samples.ObjectModel;
/// <summary>
/// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <summary>
/// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
/// </summary>
/// <typeparam name="T"></typeparam>
public class ObservableRangeCollection<T> : ObservableCollection<T>
{

/// <summary>
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class.
/// </summary>
/// <summary>
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class.
/// </summary>
public ObservableRangeCollection()
: base()
{
}

/// <summary>
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class that contains elements copied from the specified collection.
/// </summary>
/// <param name="collection">collection: The collection from which the elements are copied.</param>
/// <exception cref="System.ArgumentNullException">The collection parameter cannot be null.</exception>
/// <summary>
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class that contains elements copied from the specified collection.
/// </summary>
/// <param name="collection">collection: The collection from which the elements are copied.</param>
/// <exception cref="System.ArgumentNullException">The collection parameter cannot be null.</exception>
public ObservableRangeCollection(IEnumerable<T> collection)
: base(collection)
{
}

/// <summary>
/// Adds the elements of the specified collection to the end of the ObservableCollection(Of T).
/// </summary>
/// <summary>
/// Adds the elements of the specified collection to the end of the ObservableCollection(Of T).
/// </summary>
public void AddRange(IEnumerable<T> collection, NotifyCollectionChangedAction notificationMode = NotifyCollectionChangedAction.Add)
{
if (notificationMode != NotifyCollectionChangedAction.Add && notificationMode != NotifyCollectionChangedAction.Reset)
Expand Down Expand Up @@ -62,9 +65,9 @@ public void AddRange(IEnumerable<T> collection, NotifyCollectionChangedAction no
startingIndex: startIndex);
}

/// <summary>
/// <summary>
/// Removes the first occurence of each item in the specified collection from ObservableCollection(Of T). NOTE: with notificationMode = Remove, removed items starting index is not set because items are not guaranteed to be consecutive.
/// </summary>
/// </summary>
public void RemoveRange(IEnumerable<T> collection, NotifyCollectionChangedAction notificationMode = NotifyCollectionChangedAction.Reset)
{
if (notificationMode != NotifyCollectionChangedAction.Remove && notificationMode != NotifyCollectionChangedAction.Reset)
Expand Down Expand Up @@ -107,14 +110,14 @@ public void RemoveRange(IEnumerable<T> collection, NotifyCollectionChangedAction
changedItems: changedItems);
}

/// <summary>
/// Clears the current collection and replaces it with the specified item.
/// </summary>
/// <summary>
/// Clears the current collection and replaces it with the specified item.
/// </summary>
public void Replace(T item) => ReplaceRange(new T[] { item });

/// <summary>
/// Clears the current collection and replaces it with the specified collection.
/// </summary>
/// <summary>
/// Clears the current collection and replaces it with the specified collection.
/// </summary>
public void ReplaceRange(IEnumerable<T> collection)
{
if (collection == null)
Expand Down
8 changes: 4 additions & 4 deletions samples/Mocale.Samples/Pages/BindingPage.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
Title="{mocale:Localize Key={x:Static keys:TranslationKeys.BindingPageTitle}}"
x:Class="Mocale.Samples.Pages.BindingPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:converters="clr-namespace:Mocale.Samples.Converters"
xmlns:keys="clr-namespace:Mocale.Translations"
xmlns:mocale="http://axemasta.com/schemas/2022/mocale"
Title="{mocale:Localize Key={x:Static keys:TranslationKeys.BindingPageTitle}}">
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

<ContentPage.Resources>
<ResourceDictionary>
Expand All @@ -27,7 +27,7 @@
<Label Text="{mocale:Localize Key={x:Static keys:TranslationKeys.BindingPageCityDemoTitle}}" />
<Label Text="{mocale:Localize Key={x:Static keys:TranslationKeys.BindingPageCityDemoHeading}}" />

<Picker x:Name="CityPicker" Title="{mocale:Localize Key={x:Static keys:TranslationKeys.BindingPageCityDemoPickerPlaceholder}}">
<Picker Title="{mocale:Localize Key={x:Static keys:TranslationKeys.BindingPageCityDemoPickerPlaceholder}}" x:Name="CityPicker">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>London</x:String>
Expand All @@ -38,7 +38,7 @@
</Picker.ItemsSource>
</Picker>

<Label Text="{Binding Source={x:Reference CityPicker}, Path=SelectedItem, Converter={StaticResource CityDescriptionConverter}}" />
<Label Text="{Binding Source={x:Reference CityPicker}, Path=SelectedItem, Converter={StaticResource CityDescriptionConverter}, x:DataType=Picker}" />

</VerticalStackLayout>
</Border>
Expand Down
8 changes: 4 additions & 4 deletions samples/Mocale.Samples/Pages/ParameterPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace Mocale.Samples.Pages;

public partial class ParameterPage : BasePage<ParameterViewModel>
{
public ParameterPage(ParameterViewModel viewModel)
public ParameterPage(ParameterViewModel viewModel)
: base(viewModel)
{
InitializeComponent();
}
{
InitializeComponent();
}
}
7 changes: 1 addition & 6 deletions samples/Mocale.Samples/Platforms/Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
namespace Mocale.Samples;

[Application]
public class MainApplication : MauiApplication
public class MainApplication(IntPtr handle, JniHandleOwnership ownership) : MauiApplication(handle, ownership)
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp()
{
return MauiProgram.CreateMauiApp();
Expand Down
5 changes: 3 additions & 2 deletions samples/Mocale.Samples/ViewModels/ParameterViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
namespace Mocale.Samples.ViewModels;

public sealed partial class ParameterViewModel : BaseViewModel
{
[ObservableProperty]
private string name;

private static readonly Random random = new();
private static readonly Random Random = new();

private readonly string[] names =
[
Expand All @@ -29,7 +30,7 @@ public ParameterViewModel()

private string ChooseRandomName()
{
var index = random.Next(0, names.Length);
var index = Random.Next(0, names.Length);

var name = names[index];

Expand Down
25 changes: 24 additions & 1 deletion src/Mocale.Cache.SQLite/Abstractions/ICacheRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,36 @@

namespace Mocale.Cache.SQLite.Abstractions;

public interface ICacheRepository
/// <summary>
/// Cache Repository
/// </summary>
internal interface ICacheRepository
{
/// <summary>
/// Add Or Update Item
/// </summary>
/// <param name="cultureInfo">The culture to add / update</param>
/// <param name="lastUpdated">The last time this culture was updated</param>
/// <returns>Success</returns>
bool AddOrUpdateItem(CultureInfo cultureInfo, DateTime lastUpdated);

/// <summary>
/// Get update item
/// </summary>
/// <param name="cultureInfo">The culture to check for</param>
/// <returns>Update record if it exists</returns>
UpdateHistoryItem? GetItem(CultureInfo cultureInfo);

/// <summary>
/// Delete all records
/// </summary>
/// <returns>Success</returns>
bool DeleteAll();

/// <summary>
/// Delete the given culture
/// </summary>
/// <param name="cultureInfo">The culture to delete</param>
/// <returns>Success</returns>
bool DeleteItem(CultureInfo cultureInfo);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
namespace Mocale.Cache.SQLite.Abstractions;

/// <summary>
/// SQLite Database Connection Provider
/// </summary>
public interface IDatabaseConnectionProvider
{
/// <summary>
/// Get connection to the sqlite database
/// </summary>
/// <returns></returns>
SQLiteConnection GetDatabaseConnection();
}
7 changes: 7 additions & 0 deletions src/Mocale.Cache.SQLite/Abstractions/IDatabasePathProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
namespace Mocale.Cache.SQLite.Abstractions;

/// <summary>
/// Database Path Provider
/// </summary>
public interface IDatabasePathProvider
{
/// <summary>
/// Get SQLite database path on the device
/// </summary>
/// <returns></returns>
string GetDatabasePath();
}
2 changes: 1 addition & 1 deletion src/Mocale.Cache.SQLite/Entities/TranslationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Mocale.Cache.SQLite.Entities;
#nullable disable

[Table("Translations")]
public class TranslationItem
internal class TranslationItem
{
[PrimaryKey]
[AutoIncrement]
Expand Down
2 changes: 1 addition & 1 deletion src/Mocale.Cache.SQLite/Entities/UpdateHistoryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Mocale.Cache.SQLite.Entities;
#nullable disable

[Table("UpdateHistory")]
public class UpdateHistoryItem
internal class UpdateHistoryItem
{
[PrimaryKey]
[AutoIncrement]
Expand Down
26 changes: 8 additions & 18 deletions src/Mocale.Cache.SQLite/Managers/LocalisationCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,20 @@
using Mocale.Abstractions;
namespace Mocale.Cache.SQLite.Managers;

public class LocalisationCacheManager : ILocalisationCacheManager
internal class LocalisationCacheManager(
ICacheUpdateManager cacheUpdateManager,
ILogger<LocalisationCacheManager> logger,
ITranslationsRepository translationsRepository)
: ILocalisationCacheManager
{
#region Fields

private readonly ICacheUpdateManager cacheUpdateManager;
private readonly ILogger logger;
private readonly ITranslationsRepository translationsRepository;
private readonly ICacheUpdateManager cacheUpdateManager = Guard.Against.Null(cacheUpdateManager, nameof(cacheUpdateManager));
private readonly ILogger logger = Guard.Against.Null(logger, nameof(logger));
private readonly ITranslationsRepository translationsRepository = Guard.Against.Null(translationsRepository, nameof(translationsRepository));

#endregion Fields

#region Constructors

public LocalisationCacheManager(
ICacheUpdateManager cacheUpdateManager,
ILogger<LocalisationCacheManager> logger,
ITranslationsRepository translationsRepository)
{
this.cacheUpdateManager = Guard.Against.Null(cacheUpdateManager, nameof(cacheUpdateManager));
this.logger = Guard.Against.Null(logger, nameof(logger));
this.translationsRepository = Guard.Against.Null(translationsRepository, nameof(translationsRepository));
}

#endregion Constructors

#region Interface Implementations

public Dictionary<string, string>? GetCachedLocalizations(CultureInfo cultureInfo)
Expand Down
2 changes: 1 addition & 1 deletion src/Mocale.Cache.SQLite/Managers/SqlCacheUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Mocale.Cache.SQLite.Managers;

public class SqlCacheUpdateManager : ICacheUpdateManager
internal class SqlCacheUpdateManager : ICacheUpdateManager
{
private readonly ICacheRepository cacheRepository;
private readonly IDateTime dateTime;
Expand Down
Loading

0 comments on commit a090231

Please sign in to comment.