diff --git a/directory.build.props b/directory.build.props
index 3a44731..1d6e493 100644
--- a/directory.build.props
+++ b/directory.build.props
@@ -5,13 +5,13 @@
- 8.0.70
+ 9.0.10
- net8.0
- net8.0-ios
- net8.0-android
- net8.0-maccatalyst
- net8.0-windows10.0.19041.0
+ net9.0
+ net9.0-ios
+ net9.0-android
+ net9.0-maccatalyst
+ net9.0-windows10.0.19041.0
$(StandardTargetFramework);$(AndroidTargetFramework);$(IosTargetFramework);$(MacTargetFramework);
$(StandardTargetFramework);$(AndroidTargetFramework);$(IosTargetFramework);$(MacTargetFramework);$(WindowsTargetFramework);
diff --git a/global.json b/global.json
index b3e73d2..b5989fa 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,5 @@
{
"sdk": {
- "version": "8.0.204"
+ "version": "9.0.100"
}
}
diff --git a/samples/Mocale.GeneratorSample/Mocale.GeneratorSample.csproj b/samples/Mocale.GeneratorSample/Mocale.GeneratorSample.csproj
index 7e42e39..514683e 100644
--- a/samples/Mocale.GeneratorSample/Mocale.GeneratorSample.csproj
+++ b/samples/Mocale.GeneratorSample/Mocale.GeneratorSample.csproj
@@ -6,6 +6,7 @@
enable
enable
true
+ $(NoWarn);IDE0005
diff --git a/samples/Mocale.Samples.sln b/samples/Mocale.Samples.sln
index 51715de..3effd72 100644
--- a/samples/Mocale.Samples.sln
+++ b/samples/Mocale.Samples.sln
@@ -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}"
diff --git a/samples/Mocale.Samples/App.xaml.cs b/samples/Mocale.Samples/App.xaml.cs
index c47e84d..98e6bcd 100644
--- a/samples/Mocale.Samples/App.xaml.cs
+++ b/samples/Mocale.Samples/App.xaml.cs
@@ -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());
}
}
diff --git a/samples/Mocale.Samples/Mocale.Samples.csproj b/samples/Mocale.Samples/Mocale.Samples.csproj
index 3f8f795..0409c56 100644
--- a/samples/Mocale.Samples/Mocale.Samples.csproj
+++ b/samples/Mocale.Samples/Mocale.Samples.csproj
@@ -7,8 +7,9 @@
Mocale.Samples
true
true
-
+ $(NoWarn);IDE0005
true
+ true
Mocale.Samples
@@ -21,8 +22,8 @@
1.0
1
- 11.0
- 13.1
+ 12.2
+ 15.0
21.0
10.0.17763.0
10.0.17763.0
@@ -62,8 +63,8 @@
-
-
+
+
diff --git a/samples/Mocale.Samples/ObjectModel/ObservableRangeCollection.cs b/samples/Mocale.Samples/ObjectModel/ObservableRangeCollection.cs
index dd5059b..5b06608 100644
--- a/samples/Mocale.Samples/ObjectModel/ObservableRangeCollection.cs
+++ b/samples/Mocale.Samples/ObjectModel/ObservableRangeCollection.cs
@@ -2,35 +2,38 @@
using System.Collections.Specialized;
using System.ComponentModel;
+//Resharper disable all
+#pragma warning disable
+
namespace Mocale.Samples.ObjectModel;
-///
-/// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
-///
-///
+///
+/// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
+///
+///
public class ObservableRangeCollection : ObservableCollection
{
- ///
- /// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class.
- ///
+ ///
+ /// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class.
+ ///
public ObservableRangeCollection()
: base()
{
}
- ///
- /// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class that contains elements copied from the specified collection.
- ///
- /// collection: The collection from which the elements are copied.
- /// The collection parameter cannot be null.
+ ///
+ /// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class that contains elements copied from the specified collection.
+ ///
+ /// collection: The collection from which the elements are copied.
+ /// The collection parameter cannot be null.
public ObservableRangeCollection(IEnumerable collection)
: base(collection)
{
}
- ///
- /// Adds the elements of the specified collection to the end of the ObservableCollection(Of T).
- ///
+ ///
+ /// Adds the elements of the specified collection to the end of the ObservableCollection(Of T).
+ ///
public void AddRange(IEnumerable collection, NotifyCollectionChangedAction notificationMode = NotifyCollectionChangedAction.Add)
{
if (notificationMode != NotifyCollectionChangedAction.Add && notificationMode != NotifyCollectionChangedAction.Reset)
@@ -62,9 +65,9 @@ public void AddRange(IEnumerable collection, NotifyCollectionChangedAction no
startingIndex: startIndex);
}
- ///
+ ///
/// 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.
- ///
+ ///
public void RemoveRange(IEnumerable collection, NotifyCollectionChangedAction notificationMode = NotifyCollectionChangedAction.Reset)
{
if (notificationMode != NotifyCollectionChangedAction.Remove && notificationMode != NotifyCollectionChangedAction.Reset)
@@ -107,14 +110,14 @@ public void RemoveRange(IEnumerable collection, NotifyCollectionChangedAction
changedItems: changedItems);
}
- ///
- /// Clears the current collection and replaces it with the specified item.
- ///
+ ///
+ /// Clears the current collection and replaces it with the specified item.
+ ///
public void Replace(T item) => ReplaceRange(new T[] { item });
- ///
- /// Clears the current collection and replaces it with the specified collection.
- ///
+ ///
+ /// Clears the current collection and replaces it with the specified collection.
+ ///
public void ReplaceRange(IEnumerable collection)
{
if (collection == null)
diff --git a/samples/Mocale.Samples/Pages/BindingPage.xaml b/samples/Mocale.Samples/Pages/BindingPage.xaml
index b411370..b8465f8 100644
--- a/samples/Mocale.Samples/Pages/BindingPage.xaml
+++ b/samples/Mocale.Samples/Pages/BindingPage.xaml
@@ -1,12 +1,12 @@
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
@@ -27,7 +27,7 @@
-
+
London
@@ -38,7 +38,7 @@
-
+
diff --git a/samples/Mocale.Samples/Pages/ParameterPage.xaml.cs b/samples/Mocale.Samples/Pages/ParameterPage.xaml.cs
index ef19211..13839b3 100644
--- a/samples/Mocale.Samples/Pages/ParameterPage.xaml.cs
+++ b/samples/Mocale.Samples/Pages/ParameterPage.xaml.cs
@@ -4,9 +4,9 @@ namespace Mocale.Samples.Pages;
public partial class ParameterPage : BasePage
{
- public ParameterPage(ParameterViewModel viewModel)
+ public ParameterPage(ParameterViewModel viewModel)
: base(viewModel)
- {
- InitializeComponent();
- }
+ {
+ InitializeComponent();
+ }
}
diff --git a/samples/Mocale.Samples/Platforms/Android/MainApplication.cs b/samples/Mocale.Samples/Platforms/Android/MainApplication.cs
index fc9bcff..1c8e07a 100644
--- a/samples/Mocale.Samples/Platforms/Android/MainApplication.cs
+++ b/samples/Mocale.Samples/Platforms/Android/MainApplication.cs
@@ -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();
diff --git a/samples/Mocale.Samples/ViewModels/ParameterViewModel.cs b/samples/Mocale.Samples/ViewModels/ParameterViewModel.cs
index 7e04e5c..ad3ec83 100644
--- a/samples/Mocale.Samples/ViewModels/ParameterViewModel.cs
+++ b/samples/Mocale.Samples/ViewModels/ParameterViewModel.cs
@@ -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 =
[
@@ -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];
diff --git a/src/Mocale.Cache.SQLite/Abstractions/ICacheRepository.cs b/src/Mocale.Cache.SQLite/Abstractions/ICacheRepository.cs
index 1ff83bd..01e2839 100644
--- a/src/Mocale.Cache.SQLite/Abstractions/ICacheRepository.cs
+++ b/src/Mocale.Cache.SQLite/Abstractions/ICacheRepository.cs
@@ -2,13 +2,36 @@
namespace Mocale.Cache.SQLite.Abstractions;
-public interface ICacheRepository
+///
+/// Cache Repository
+///
+internal interface ICacheRepository
{
+ ///
+ /// Add Or Update Item
+ ///
+ /// The culture to add / update
+ /// The last time this culture was updated
+ /// Success
bool AddOrUpdateItem(CultureInfo cultureInfo, DateTime lastUpdated);
+ ///
+ /// Get update item
+ ///
+ /// The culture to check for
+ /// Update record if it exists
UpdateHistoryItem? GetItem(CultureInfo cultureInfo);
+ ///
+ /// Delete all records
+ ///
+ /// Success
bool DeleteAll();
+ ///
+ /// Delete the given culture
+ ///
+ /// The culture to delete
+ /// Success
bool DeleteItem(CultureInfo cultureInfo);
}
diff --git a/src/Mocale.Cache.SQLite/Abstractions/IDatabaseConnectionProvider.cs b/src/Mocale.Cache.SQLite/Abstractions/IDatabaseConnectionProvider.cs
index cb4080b..b271aaf 100644
--- a/src/Mocale.Cache.SQLite/Abstractions/IDatabaseConnectionProvider.cs
+++ b/src/Mocale.Cache.SQLite/Abstractions/IDatabaseConnectionProvider.cs
@@ -1,6 +1,13 @@
namespace Mocale.Cache.SQLite.Abstractions;
+///
+/// SQLite Database Connection Provider
+///
public interface IDatabaseConnectionProvider
{
+ ///
+ /// Get connection to the sqlite database
+ ///
+ ///
SQLiteConnection GetDatabaseConnection();
}
diff --git a/src/Mocale.Cache.SQLite/Abstractions/IDatabasePathProvider.cs b/src/Mocale.Cache.SQLite/Abstractions/IDatabasePathProvider.cs
index 650ebd0..cf7a15b 100644
--- a/src/Mocale.Cache.SQLite/Abstractions/IDatabasePathProvider.cs
+++ b/src/Mocale.Cache.SQLite/Abstractions/IDatabasePathProvider.cs
@@ -1,6 +1,13 @@
namespace Mocale.Cache.SQLite.Abstractions;
+///
+/// Database Path Provider
+///
public interface IDatabasePathProvider
{
+ ///
+ /// Get SQLite database path on the device
+ ///
+ ///
string GetDatabasePath();
}
diff --git a/src/Mocale.Cache.SQLite/Entities/TranslationItem.cs b/src/Mocale.Cache.SQLite/Entities/TranslationItem.cs
index 4febf5e..141c2b9 100644
--- a/src/Mocale.Cache.SQLite/Entities/TranslationItem.cs
+++ b/src/Mocale.Cache.SQLite/Entities/TranslationItem.cs
@@ -3,7 +3,7 @@ namespace Mocale.Cache.SQLite.Entities;
#nullable disable
[Table("Translations")]
-public class TranslationItem
+internal class TranslationItem
{
[PrimaryKey]
[AutoIncrement]
diff --git a/src/Mocale.Cache.SQLite/Entities/UpdateHistoryItem.cs b/src/Mocale.Cache.SQLite/Entities/UpdateHistoryItem.cs
index 3fc8046..9039f24 100644
--- a/src/Mocale.Cache.SQLite/Entities/UpdateHistoryItem.cs
+++ b/src/Mocale.Cache.SQLite/Entities/UpdateHistoryItem.cs
@@ -3,7 +3,7 @@ namespace Mocale.Cache.SQLite.Entities;
#nullable disable
[Table("UpdateHistory")]
-public class UpdateHistoryItem
+internal class UpdateHistoryItem
{
[PrimaryKey]
[AutoIncrement]
diff --git a/src/Mocale.Cache.SQLite/Managers/LocalisationCacheManager.cs b/src/Mocale.Cache.SQLite/Managers/LocalisationCacheManager.cs
index af1c6b3..fa102e6 100644
--- a/src/Mocale.Cache.SQLite/Managers/LocalisationCacheManager.cs
+++ b/src/Mocale.Cache.SQLite/Managers/LocalisationCacheManager.cs
@@ -3,30 +3,20 @@
using Mocale.Abstractions;
namespace Mocale.Cache.SQLite.Managers;
-public class LocalisationCacheManager : ILocalisationCacheManager
+internal class LocalisationCacheManager(
+ ICacheUpdateManager cacheUpdateManager,
+ ILogger 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 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? GetCachedLocalizations(CultureInfo cultureInfo)
diff --git a/src/Mocale.Cache.SQLite/Managers/SqlCacheUpdateManager.cs b/src/Mocale.Cache.SQLite/Managers/SqlCacheUpdateManager.cs
index 593b134..afdeb37 100644
--- a/src/Mocale.Cache.SQLite/Managers/SqlCacheUpdateManager.cs
+++ b/src/Mocale.Cache.SQLite/Managers/SqlCacheUpdateManager.cs
@@ -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;
diff --git a/src/Mocale.Cache.SQLite/Mocale.Cache.SQLite.csproj b/src/Mocale.Cache.SQLite/Mocale.Cache.SQLite.csproj
index 55ade91..021aa22 100644
--- a/src/Mocale.Cache.SQLite/Mocale.Cache.SQLite.csproj
+++ b/src/Mocale.Cache.SQLite/Mocale.Cache.SQLite.csproj
@@ -12,13 +12,7 @@
Mocale.Cache.SQLite
Caching implementation for Mocale. This cache provider utilizes a SQLite database to store translations and other details important for Mocales library functions.
true
-
- 14.2
- 14.0
- 21.0
- 10.0.17763.0
- 10.0.17763.0
- 6.5
+ true
@@ -26,7 +20,7 @@
-
-
+
+
diff --git a/src/Mocale.Cache.SQLite/MocaleBuilderExtension.cs b/src/Mocale.Cache.SQLite/MocaleBuilderExtension.cs
index 73a14ae..b842df5 100644
--- a/src/Mocale.Cache.SQLite/MocaleBuilderExtension.cs
+++ b/src/Mocale.Cache.SQLite/MocaleBuilderExtension.cs
@@ -5,8 +5,17 @@
using Mocale.Managers;
namespace Mocale.Cache.SQLite;
+///
+/// Mocale Builder Extension
+///
public static class MocaleBuilderExtension
{
+ ///
+ /// Use SQLite to cache localizations acquired by external providers
+ ///
+ ///
+ ///
+ ///
public static MocaleBuilder UseSqliteCache(this MocaleBuilder builder, Action configureSql)
{
var config = new SqliteConfig
diff --git a/src/Mocale.Cache.SQLite/Models/SqliteConfig.cs b/src/Mocale.Cache.SQLite/Models/SqliteConfig.cs
index aa04a09..50a9037 100644
--- a/src/Mocale.Cache.SQLite/Models/SqliteConfig.cs
+++ b/src/Mocale.Cache.SQLite/Models/SqliteConfig.cs
@@ -1,10 +1,14 @@
namespace Mocale.Cache.SQLite.Models;
+///
public class SqliteConfig : ISqliteConfig
{
+ ///
public string DatabaseName { get; private set; } = Constants.DatabaseFileName;
+ ///
public string DatabaseDirectory { get; internal set; } = string.Empty;
+ ///
public TimeSpan UpdateInterval { get; set; } = TimeSpan.FromDays(1);
}
diff --git a/src/Mocale.Cache.SQLite/Providers/DatabaseConnectionProvider.cs b/src/Mocale.Cache.SQLite/Providers/DatabaseConnectionProvider.cs
index 6403584..1a4be2e 100644
--- a/src/Mocale.Cache.SQLite/Providers/DatabaseConnectionProvider.cs
+++ b/src/Mocale.Cache.SQLite/Providers/DatabaseConnectionProvider.cs
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
namespace Mocale.Cache.SQLite.Providers;
-public class DatabaseConnectionProvider : IDatabaseConnectionProvider
+internal class DatabaseConnectionProvider : IDatabaseConnectionProvider
{
#region Fields
diff --git a/src/Mocale.Cache.SQLite/Providers/DatabasePathProvider.cs b/src/Mocale.Cache.SQLite/Providers/DatabasePathProvider.cs
index 1ef39d8..e20580f 100644
--- a/src/Mocale.Cache.SQLite/Providers/DatabasePathProvider.cs
+++ b/src/Mocale.Cache.SQLite/Providers/DatabasePathProvider.cs
@@ -1,14 +1,10 @@
using Mocale.Abstractions;
namespace Mocale.Cache.SQLite.Providers;
-public class DatabasePathProvider : IDatabasePathProvider
+internal class DatabasePathProvider(IConfigurationManager configurationManager)
+ : IDatabasePathProvider
{
- private readonly IConfigurationManager configurationManager;
-
- public DatabasePathProvider(IConfigurationManager configurationManager)
- {
- this.configurationManager = Guard.Against.Null(configurationManager, nameof(configurationManager));
- }
+ private readonly IConfigurationManager configurationManager = Guard.Against.Null(configurationManager, nameof(configurationManager));
public string GetDatabasePath()
{
diff --git a/src/Mocale.Cache.SQLite/Repositories/CacheRepository.cs b/src/Mocale.Cache.SQLite/Repositories/CacheRepository.cs
index 5dd6e63..5d0b04d 100644
--- a/src/Mocale.Cache.SQLite/Repositories/CacheRepository.cs
+++ b/src/Mocale.Cache.SQLite/Repositories/CacheRepository.cs
@@ -3,7 +3,7 @@
namespace Mocale.Cache.SQLite.Repositories;
-public class CacheRepository : RepositoryBase, ICacheRepository
+internal class CacheRepository : RepositoryBase, ICacheRepository
{
#region Constructors
diff --git a/src/Mocale.Cache.SQLite/Repositories/RepositoryBase.cs b/src/Mocale.Cache.SQLite/Repositories/RepositoryBase.cs
index 562779f..2e09517 100644
--- a/src/Mocale.Cache.SQLite/Repositories/RepositoryBase.cs
+++ b/src/Mocale.Cache.SQLite/Repositories/RepositoryBase.cs
@@ -1,9 +1,12 @@
using Microsoft.Extensions.Logging;
namespace Mocale.Cache.SQLite.Repositories;
-public abstract class RepositoryBase
+internal abstract class RepositoryBase
{
+#pragma warning disable IDE1006
+ // ReSharper disable once InconsistentNaming
protected ILogger logger { get; }
+#pragma warning restore IDE1006
protected SQLiteConnection Connection { get; }
diff --git a/src/Mocale.Cache.SQLite/Repositories/TranslationsRepository.cs b/src/Mocale.Cache.SQLite/Repositories/TranslationsRepository.cs
index 72643d8..e9062fc 100644
--- a/src/Mocale.Cache.SQLite/Repositories/TranslationsRepository.cs
+++ b/src/Mocale.Cache.SQLite/Repositories/TranslationsRepository.cs
@@ -2,7 +2,7 @@
using Microsoft.Extensions.Logging;
namespace Mocale.Cache.SQLite.Repositories;
-public class TranslationsRepository : RepositoryBase, ITranslationsRepository
+internal class TranslationsRepository : RepositoryBase, ITranslationsRepository
{
#region Constructors
@@ -50,7 +50,7 @@ private static List CreateEntities(CultureInfo cultureInfo, Dic
.Where(t => t.CultureName == cultureInfo.Name)
.ToList();
- if (entities is null || !entities.Any())
+ if (entities is null || entities.Count < 1)
{
logger.LogTrace("No cached translations found for culture: {CultureName}", cultureInfo.Name);
return null;
@@ -80,7 +80,7 @@ public bool AddTranslations(CultureInfo cultureInfo, Dictionary
var newValues = translations.Where(t => currentEntities.All(c => c.Key != t.Key))
.ToList();
- if (newValues.Any())
+ if (newValues.Count > 0)
{
var newTranslations = translations.Where(t => currentEntities.All(c => c.Key != t.Key))
.ToDictionary(d => d.Key, d => d.Value);
@@ -95,7 +95,7 @@ public bool AddTranslations(CultureInfo cultureInfo, Dictionary
var deletedValues = currentEntities.Where(t => translations.All(c => c.Key != t.Key))
.ToList();
- if (deletedValues.Any())
+ if (deletedValues.Count > 0)
{
var rows = 0;
@@ -110,7 +110,7 @@ public bool AddTranslations(CultureInfo cultureInfo, Dictionary
var updatedValues = currentEntities.Where(t => translations.Any(c => c.Key == t.Key && c.Value != t.Value))
.ToList();
- if (updatedValues.Any())
+ if (updatedValues.Count > 0)
{
foreach (var translation in updatedValues)
{
@@ -143,7 +143,7 @@ public bool DeleteTranslations(CultureInfo cultureInfo)
.Where(t => t.CultureName == cultureInfo.Name)
.ToList();
- if (entities is null || !entities.Any())
+ if (entities is null || entities.Count < 1)
{
logger.LogWarning("No translations to delete for culture: {CultureName}", cultureInfo.Name);
return false;
diff --git a/src/Mocale.Providers.AWS.S3/Abstractions/IBucketConfig.cs b/src/Mocale.Providers.AWS.S3/Abstractions/IBucketConfig.cs
index 7d4b883..128468c 100644
--- a/src/Mocale.Providers.AWS.S3/Abstractions/IBucketConfig.cs
+++ b/src/Mocale.Providers.AWS.S3/Abstractions/IBucketConfig.cs
@@ -1,7 +1,8 @@
-using Mocale.Abstractions;
-
namespace Mocale.Providers.AWS.S3.Abstractions;
+///
+/// S3 Bucket Config
+///
public interface IBucketConfig : IExternalProviderConfiguration
{
///
diff --git a/src/Mocale.Providers.AWS.S3/Mocale.Providers.AWS.S3.csproj b/src/Mocale.Providers.AWS.S3/Mocale.Providers.AWS.S3.csproj
index 3e3a628..a1571a9 100644
--- a/src/Mocale.Providers.AWS.S3/Mocale.Providers.AWS.S3.csproj
+++ b/src/Mocale.Providers.AWS.S3/Mocale.Providers.AWS.S3.csproj
@@ -12,13 +12,7 @@
Mocale.Providers.Azure.Blob
AWS S3 object storage external provider for Mocale. This packages provides the ability to query S3 object storage for localization files to be used in your maui application.
false
-
- 14.2
- 14.0
- 21.0
- 10.0.17763.0
- 10.0.17763.0
- 6.5
+ true
diff --git a/src/Mocale.Providers.AWS.S3/MocaleBuilderExtension.cs b/src/Mocale.Providers.AWS.S3/MocaleBuilderExtension.cs
index b5b57b9..eb560d4 100644
--- a/src/Mocale.Providers.AWS.S3/MocaleBuilderExtension.cs
+++ b/src/Mocale.Providers.AWS.S3/MocaleBuilderExtension.cs
@@ -1,9 +1,18 @@
-using Mocale.Abstractions;
using Mocale.Managers;
namespace Mocale.Providers.AWS.S3;
+///
+/// Mocale Builder Extension
+///
public static class MocaleBuilderExtension
{
+ ///
+ /// [External Provider]
+ /// Use AWS S3 Bucket to retrieve localizations
+ ///
+ ///
+ ///
+ ///
public static MocaleBuilder UseS3Bucket(this MocaleBuilder builder, Action configureBucket)
{
var config = new BucketConfig();
diff --git a/src/Mocale.Providers.AWS.S3/Models/BucketConfig.cs b/src/Mocale.Providers.AWS.S3/Models/BucketConfig.cs
index 5445ae1..6856078 100644
--- a/src/Mocale.Providers.AWS.S3/Models/BucketConfig.cs
+++ b/src/Mocale.Providers.AWS.S3/Models/BucketConfig.cs
@@ -1,7 +1,9 @@
namespace Mocale.Providers.AWS.S3.Models;
+///
public class BucketConfig : IBucketConfig
{
+ ///
public Uri? BucketUri { get; set; }
///
diff --git a/src/Mocale.Providers.AWS.S3/Properties/GlobalUsings.cs b/src/Mocale.Providers.AWS.S3/Properties/GlobalUsings.cs
index c25840b..b0460aa 100644
--- a/src/Mocale.Providers.AWS.S3/Properties/GlobalUsings.cs
+++ b/src/Mocale.Providers.AWS.S3/Properties/GlobalUsings.cs
@@ -2,3 +2,4 @@
global using Mocale.Providers.AWS.S3.Models;
global using Mocale.Abstractions;
global using Mocale.Models;
+global using System.Globalization;
diff --git a/src/Mocale.Providers.AWS.S3/S3BucketProvider.cs b/src/Mocale.Providers.AWS.S3/S3BucketProvider.cs
index 2ea6f53..6a71d15 100644
--- a/src/Mocale.Providers.AWS.S3/S3BucketProvider.cs
+++ b/src/Mocale.Providers.AWS.S3/S3BucketProvider.cs
@@ -1,6 +1,3 @@
-using System.Globalization;
-using Mocale.Abstractions;
-using Mocale.Models;
namespace Mocale.Providers.AWS.S3;
internal sealed class S3BucketProvider : IExternalLocalizationProvider
@@ -44,7 +41,7 @@ public async Task GetValuesForCultureAsync(CultureI
return new ExternalLocalizationResult()
{
Success = false,
- Localizations = new Dictionary(),
+ Localizations = [],
};
}
}
diff --git a/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobResourceLocator.cs b/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobResourceLocator.cs
index b6c2496..df1f90c 100644
--- a/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobResourceLocator.cs
+++ b/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobResourceLocator.cs
@@ -1,4 +1,3 @@
-using System.Globalization;
namespace Mocale.Providers.Azure.Blob.Abstractions;
///
diff --git a/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobStorageConfig.cs b/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobStorageConfig.cs
index f5e51e3..e596792 100644
--- a/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobStorageConfig.cs
+++ b/src/Mocale.Providers.Azure.Blob/Abstractions/IBlobStorageConfig.cs
@@ -1,5 +1,8 @@
namespace Mocale.Providers.Azure.Blob.Abstractions;
+///
+/// Configuration for aure blob storage external provider
+///
public interface IBlobStorageConfig : IExternalProviderConfiguration
{
///
diff --git a/src/Mocale.Providers.Azure.Blob/BlobLocalizationProvider.cs b/src/Mocale.Providers.Azure.Blob/BlobLocalizationProvider.cs
index f9dc111..321732f 100644
--- a/src/Mocale.Providers.Azure.Blob/BlobLocalizationProvider.cs
+++ b/src/Mocale.Providers.Azure.Blob/BlobLocalizationProvider.cs
@@ -1,10 +1,5 @@
-using System.Globalization;
-using System.Text.Json;
-using Ardalis.GuardClauses;
-using Azure.Storage.Blobs;
-using Azure.Storage.Blobs.Models;
-using Microsoft.Extensions.Logging;
using Mocale.Extensions;
+
namespace Mocale.Providers.Azure.Blob;
internal sealed class BlobLocalizationProvider : IExternalLocalizationProvider
@@ -17,7 +12,7 @@ internal sealed class BlobLocalizationProvider : IExternalLocalizationProvider
private readonly ILocalizationParser localizationParser;
private readonly ILogger logger;
- private static readonly BlobOpenReadOptions BlobOptions = new BlobOpenReadOptions(false);
+ private static readonly BlobOpenReadOptions BlobOptions = new(false);
#endregion Fields
diff --git a/src/Mocale.Providers.Azure.Blob/Managers/BlobResourceLocator.cs b/src/Mocale.Providers.Azure.Blob/Managers/BlobResourceLocator.cs
index 50e5264..0d2c99a 100644
--- a/src/Mocale.Providers.Azure.Blob/Managers/BlobResourceLocator.cs
+++ b/src/Mocale.Providers.Azure.Blob/Managers/BlobResourceLocator.cs
@@ -1,9 +1,3 @@
-using System.Globalization;
-using Ardalis.GuardClauses;
-using Azure.Storage.Blobs;
-using Azure.Storage.Blobs.Models;
-using Microsoft.Extensions.Logging;
-using Page = Azure.Page;
namespace Mocale.Providers.Azure.Blob.Managers;
internal class BlobResourceLocator : IBlobResourceLocator
@@ -72,7 +66,7 @@ public async Task TryLocateResource(CultureInfo cultureInfo)
var pages = client.GetBlobsAsync().AsPages();
- await foreach (Page page in pages)
+ await foreach (var page in pages)
{
if (FindMatchingBlobResource(page.Values, expectedFileSlug, out var info) && info is not null)
{
diff --git a/src/Mocale.Providers.Azure.Blob/Mocale.Providers.Azure.Blob.csproj b/src/Mocale.Providers.Azure.Blob/Mocale.Providers.Azure.Blob.csproj
index 3b79f27..cdbfe86 100644
--- a/src/Mocale.Providers.Azure.Blob/Mocale.Providers.Azure.Blob.csproj
+++ b/src/Mocale.Providers.Azure.Blob/Mocale.Providers.Azure.Blob.csproj
@@ -13,13 +13,7 @@
Mocale.Providers.Azure.Blob
Azure blob storage external provider for Mocale. This package provides the ability to query azure blob storage for localization files to be used in your maui application.
true
-
- 14.2
- 14.0
- 21.0
- 10.0.17763.0
- 10.0.17763.0
- 6.5
+ true
@@ -27,8 +21,8 @@
-
-
+
+
diff --git a/src/Mocale.Providers.Azure.Blob/MocaleBuilderExtension.cs b/src/Mocale.Providers.Azure.Blob/MocaleBuilderExtension.cs
index c0e6189..1e39b12 100644
--- a/src/Mocale.Providers.Azure.Blob/MocaleBuilderExtension.cs
+++ b/src/Mocale.Providers.Azure.Blob/MocaleBuilderExtension.cs
@@ -2,6 +2,9 @@
using Mocale.Providers.Azure.Blob.Managers;
namespace Mocale.Providers.Azure.Blob;
+///
+/// Mocale Builder Extension
+///
public static class MocaleBuilderExtension
{
///
diff --git a/src/Mocale.Providers.Azure.Blob/Models/BlobResourceInfo.cs b/src/Mocale.Providers.Azure.Blob/Models/BlobResourceInfo.cs
index 2656232..227b203 100644
--- a/src/Mocale.Providers.Azure.Blob/Models/BlobResourceInfo.cs
+++ b/src/Mocale.Providers.Azure.Blob/Models/BlobResourceInfo.cs
@@ -1,8 +1,17 @@
namespace Mocale.Providers.Azure.Blob.Models;
+///
+/// Blob Resource Information
+///
public class BlobResourceInfo
{
+ ///
+ /// Whether the theorized blob resource actually exists
+ ///
public bool Exists { get; init; }
+ ///
+ /// The name of the theorized blob resource
+ ///
public string? ResourceName { get; init; }
}
diff --git a/src/Mocale.Providers.Azure.Blob/Properties/GlobalUsings.cs b/src/Mocale.Providers.Azure.Blob/Properties/GlobalUsings.cs
index fed2189..86615a3 100644
--- a/src/Mocale.Providers.Azure.Blob/Properties/GlobalUsings.cs
+++ b/src/Mocale.Providers.Azure.Blob/Properties/GlobalUsings.cs
@@ -2,3 +2,8 @@
global using Mocale.Models;
global using Mocale.Providers.Azure.Blob.Abstractions;
global using Mocale.Providers.Azure.Blob.Models;
+global using Microsoft.Extensions.Logging;
+global using System.Globalization;
+global using Ardalis.GuardClauses;
+global using Azure.Storage.Blobs;
+global using Azure.Storage.Blobs.Models;
diff --git a/src/Mocale.Providers.GitHub.Raw/Abstractions/IGithubRawConfig.cs b/src/Mocale.Providers.GitHub.Raw/Abstractions/IGithubRawConfig.cs
index 63a4947..9e9d465 100644
--- a/src/Mocale.Providers.GitHub.Raw/Abstractions/IGithubRawConfig.cs
+++ b/src/Mocale.Providers.GitHub.Raw/Abstractions/IGithubRawConfig.cs
@@ -1,12 +1,27 @@
namespace Mocale.Providers.GitHub.Raw.Abstractions;
+///
+/// External provider configuration for github raw source
+///
public interface IGithubRawConfig : IExternalProviderConfiguration
{
+ ///
+ /// The github username
+ ///
string Username { get; }
+ ///
+ /// The repository to target
+ ///
string Repository { get; }
+ ///
+ /// The branch the localizations exist on
+ ///
string Branch { get; }
+ ///
+ /// The directory in the repository that contains the locale files
+ ///
string LocaleDirectory { get; }
}
diff --git a/src/Mocale.Providers.GitHub.Raw/Mocale.Providers.GitHub.Raw.csproj b/src/Mocale.Providers.GitHub.Raw/Mocale.Providers.GitHub.Raw.csproj
index 7bb8d60..1759e61 100644
--- a/src/Mocale.Providers.GitHub.Raw/Mocale.Providers.GitHub.Raw.csproj
+++ b/src/Mocale.Providers.GitHub.Raw/Mocale.Providers.GitHub.Raw.csproj
@@ -13,13 +13,7 @@
Mocale.Providers.GitHub.Raw
GitHub raw external provider for Mocale. This package will attempt to use the configured GitHub repository to download localizations to be used in your maui application.
true
-
- 14.2
- 14.0
- 21.0
- 10.0.17763.0
- 10.0.17763.0
- 6.5
+ true
@@ -27,7 +21,7 @@
-
+
diff --git a/src/Mocale.Providers.GitHub.Raw/MocaleBuilderExtension.cs b/src/Mocale.Providers.GitHub.Raw/MocaleBuilderExtension.cs
index cf41f52..b4ade1a 100644
--- a/src/Mocale.Providers.GitHub.Raw/MocaleBuilderExtension.cs
+++ b/src/Mocale.Providers.GitHub.Raw/MocaleBuilderExtension.cs
@@ -1,5 +1,8 @@
namespace Mocale.Providers.GitHub.Raw;
+///
+/// Mocale Builder Extension
+///
public static class MocaleBuilderExtension
{
///
diff --git a/src/Mocale.Providers.GitHub.Raw/Models/GithubRawConfig.cs b/src/Mocale.Providers.GitHub.Raw/Models/GithubRawConfig.cs
index 8f01684..c0051ba 100644
--- a/src/Mocale.Providers.GitHub.Raw/Models/GithubRawConfig.cs
+++ b/src/Mocale.Providers.GitHub.Raw/Models/GithubRawConfig.cs
@@ -1,14 +1,20 @@
namespace Mocale.Providers.GitHub.Raw.Models;
+///
public class GithubRawConfig : IGithubRawConfig
{
+ ///
public string Username { get; set; } = string.Empty;
+ ///
public string Repository { get; set; } = string.Empty;
+ ///
public string Branch { get; set; } = "main";
+ ///
public string LocaleDirectory { get; set; } = string.Empty;
+ ///
public IResourceFileDetails ResourceFileDetails { get; set; } = new JsonResourceFileDetails();
}
diff --git a/src/Mocale.SourceGenerators/Mocale.SourceGenerators.csproj b/src/Mocale.SourceGenerators/Mocale.SourceGenerators.csproj
index 5a77bb3..61af348 100644
--- a/src/Mocale.SourceGenerators/Mocale.SourceGenerators.csproj
+++ b/src/Mocale.SourceGenerators/Mocale.SourceGenerators.csproj
@@ -27,8 +27,8 @@
-
-
+
+
diff --git a/src/Mocale/Abstractions/IAppResourcesConfig.cs b/src/Mocale/Abstractions/IAppResourcesConfig.cs
index 83c48d9..df6d40a 100644
--- a/src/Mocale/Abstractions/IAppResourcesConfig.cs
+++ b/src/Mocale/Abstractions/IAppResourcesConfig.cs
@@ -1,6 +1,12 @@
namespace Mocale.Abstractions;
+///
+/// Configuration For App Resources
+///
public interface IAppResourcesConfig
{
+ ///
+ /// The type for the app resources
+ ///
Type? AppResourcesType { get; }
}
diff --git a/src/Mocale/Abstractions/IAppServiceProvider.cs b/src/Mocale/Abstractions/IAppServiceProvider.cs
deleted file mode 100644
index 05497c0..0000000
--- a/src/Mocale/Abstractions/IAppServiceProvider.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Mocale.Abstractions;
-
-public interface IAppServiceProvider
-{
- IServiceProvider ServiceProvider { get; }
-}
diff --git a/src/Mocale/Abstractions/IConfigurationManager.cs b/src/Mocale/Abstractions/IConfigurationManager.cs
index 616b705..f4042ab 100644
--- a/src/Mocale/Abstractions/IConfigurationManager.cs
+++ b/src/Mocale/Abstractions/IConfigurationManager.cs
@@ -1,11 +1,26 @@
namespace Mocale.Abstractions;
+///
+/// Configuration Manager
+///
+/// The config for this manager
public interface IConfigurationManager
{
+ ///
+ /// The configuration for the given area
+ ///
TConfig Configuration { get; set; }
}
+///
+/// Configuration Update Manager
+///
+///
public interface IConfigurationUpdateManager
{
+ ///
+ /// Update Configuration
+ ///
+ ///
void UpdateConfiguration(Action configuration);
}
diff --git a/src/Mocale/Abstractions/ICurrentCultureManager.cs b/src/Mocale/Abstractions/ICurrentCultureManager.cs
index 558b3c6..d1e9a6b 100644
--- a/src/Mocale/Abstractions/ICurrentCultureManager.cs
+++ b/src/Mocale/Abstractions/ICurrentCultureManager.cs
@@ -2,10 +2,21 @@
namespace Mocale.Abstractions;
+///
+/// Current Culture Manager
+///
public interface ICurrentCultureManager
{
+ ///
+ /// Get Active Culture
+ ///
+ ///
CultureInfo GetActiveCulture();
+ ///
+ /// Set Active Culture
+ ///
+ ///
void SetActiveCulture(CultureInfo cultureInfo);
}
diff --git a/src/Mocale/Abstractions/IExternalLocalizationResult.cs b/src/Mocale/Abstractions/IExternalLocalizationResult.cs
index 23e1442..3c2f634 100644
--- a/src/Mocale/Abstractions/IExternalLocalizationResult.cs
+++ b/src/Mocale/Abstractions/IExternalLocalizationResult.cs
@@ -1,8 +1,17 @@
namespace Mocale.Abstractions;
+///
+/// External Localization Result
+///
public interface IExternalLocalizationResult
{
+ ///
+ /// Whether the attempt succeeded
+ ///
bool Success { get; }
+ ///
+ /// Localizations from the external provider
+ ///
Dictionary? Localizations { get; }
}
diff --git a/src/Mocale/Abstractions/IExternalProviderConfiguration.cs b/src/Mocale/Abstractions/IExternalProviderConfiguration.cs
index 6fbe0ec..64e2f21 100644
--- a/src/Mocale/Abstractions/IExternalProviderConfiguration.cs
+++ b/src/Mocale/Abstractions/IExternalProviderConfiguration.cs
@@ -1,10 +1,13 @@
-using System.Globalization;
-
namespace Mocale.Abstractions;
+///
+/// External Provider Configuration
+///
public interface IExternalProviderConfiguration
-
{
+ ///
+ /// Details about the resource files returned by the external provider
+ ///
IResourceFileDetails ResourceFileDetails { get; }
}
diff --git a/src/Mocale/Abstractions/ILocalizationManager.cs b/src/Mocale/Abstractions/ILocalizationManager.cs
index 774429a..906f52e 100644
--- a/src/Mocale/Abstractions/ILocalizationManager.cs
+++ b/src/Mocale/Abstractions/ILocalizationManager.cs
@@ -1,11 +1,26 @@
using System.Globalization;
namespace Mocale.Abstractions;
+///
+/// Localization Manager
+///
public interface ILocalizationManager
{
+ ///
+ /// The current culture
+ ///
CultureInfo CurrentCulture { get; }
+ ///
+ /// Mocale Bootstrapper, this is called internall by mocale during maui app startup
+ ///
+ /// Success
Task Initialize();
+ ///
+ /// Set culture
+ ///
+ /// The culture to attempt to display
+ /// Success
Task SetCultureAsync(CultureInfo culture);
}
diff --git a/src/Mocale/Abstractions/IParameterTranslatorManager.cs b/src/Mocale/Abstractions/IParameterTranslatorManager.cs
index e318b7c..746f706 100644
--- a/src/Mocale/Abstractions/IParameterTranslatorManager.cs
+++ b/src/Mocale/Abstractions/IParameterTranslatorManager.cs
@@ -1,7 +1,14 @@
namespace Mocale.Abstractions;
+///
+/// Parameterized Translation Manager
+///
public interface IParameterTranslatorManager : ITranslatorManager
{
+ ///
+ /// Set the parameters to be used as part of translation
+ ///
+ ///
void SetParameters(object[] parameters);
}
diff --git a/src/Mocale/Abstractions/IResourceFileDetails.cs b/src/Mocale/Abstractions/IResourceFileDetails.cs
index 553b9c8..e486d73 100644
--- a/src/Mocale/Abstractions/IResourceFileDetails.cs
+++ b/src/Mocale/Abstractions/IResourceFileDetails.cs
@@ -1,4 +1,8 @@
namespace Mocale.Abstractions;
+
+///
+/// Resource File Details
+///
public interface IResourceFileDetails
{
///
@@ -7,7 +11,7 @@ public interface IResourceFileDetails
LocaleResourceType ResourceType { get; }
///
- /// The version prefix of the files, this will be prepanded after the url & before the file name
+ /// The version prefix of the files, this will be prepended after the url & before the file name
///
string? VersionPrefix { get; }
}
diff --git a/src/Mocale/Abstractions/ITranslationUpdater.cs b/src/Mocale/Abstractions/ITranslationUpdater.cs
index 1277c46..b066740 100644
--- a/src/Mocale/Abstractions/ITranslationUpdater.cs
+++ b/src/Mocale/Abstractions/ITranslationUpdater.cs
@@ -1,6 +1,14 @@
namespace Mocale.Abstractions;
+///
+/// Translation Updater
+///
public interface ITranslationUpdater
{
+ ///
+ /// Update Translations From Source
+ ///
+ ///
+ ///
void UpdateTranslations(Localization localization, TranslationSource source);
}
diff --git a/src/Mocale/Abstractions/ITranslatorManager.cs b/src/Mocale/Abstractions/ITranslatorManager.cs
index 45f8995..4f7b208 100644
--- a/src/Mocale/Abstractions/ITranslatorManager.cs
+++ b/src/Mocale/Abstractions/ITranslatorManager.cs
@@ -1,11 +1,28 @@
using System.Globalization;
namespace Mocale.Abstractions;
+///
+/// Translator Manager
+///
public interface ITranslatorManager
{
+ ///
+ /// Current Culture
+ ///
CultureInfo? CurrentCulture { get; }
+ ///
+ /// Translate
+ ///
+ /// Key to translate
+ /// Translation result
string? Translate(string key);
+ ///
+ /// Translate
+ ///
+ /// Key to translate
+ /// Parameters to translate
+ /// Translation result
string? Translate(string key, object[] parameters);
}
diff --git a/src/Mocale/AppBuilderExtensions.cs b/src/Mocale/AppBuilderExtensions.cs
index 7e7e847..e5e86d0 100644
--- a/src/Mocale/AppBuilderExtensions.cs
+++ b/src/Mocale/AppBuilderExtensions.cs
@@ -1,6 +1,4 @@
-using System.Globalization;
using Mocale.Exceptions;
-using Mocale.Helper;
using Mocale.Managers;
using Mocale.Providers;
using Mocale.Wrappers;
@@ -11,6 +9,13 @@ namespace Mocale;
///
public static class AppBuilderExtensions
{
+ ///
+ /// Use mocale in your app to provide translations.
+ ///
+ /// Maui app builder
+ /// Mocale builder
+ /// Maui app builder
+ /// If configuration is invalid, see details for troubleshooting
public static MauiAppBuilder UseMocale(
this MauiAppBuilder mauiAppBuilder,
Action? builder = default)
diff --git a/src/Mocale/Enums/LocaleResourceType.cs b/src/Mocale/Enums/LocaleResourceType.cs
index d018e05..9f26157 100644
--- a/src/Mocale/Enums/LocaleResourceType.cs
+++ b/src/Mocale/Enums/LocaleResourceType.cs
@@ -1,8 +1,17 @@
namespace Mocale.Enums;
+///
+/// Locale Resource Type
+///
public enum LocaleResourceType
-
{
+ ///
+ /// Resx File
+ ///
Resx = 0,
+
+ ///
+ /// Json File
+ ///
Json = 1,
}
diff --git a/src/Mocale/Exceptions/InitializationException.cs b/src/Mocale/Exceptions/InitializationException.cs
index bc9e7a1..0d7e8fe 100644
--- a/src/Mocale/Exceptions/InitializationException.cs
+++ b/src/Mocale/Exceptions/InitializationException.cs
@@ -1,9 +1,3 @@
namespace Mocale.Exceptions;
-internal class InitializationException : MocaleException
-{
- public InitializationException(string message)
- : base(message)
- {
- }
-}
+internal class InitializationException(string message) : MocaleException(message);
diff --git a/src/Mocale/Extensions/BindableObjectExtension.cs b/src/Mocale/Extensions/BindableObjectExtension.cs
index e0c1775..244e627 100644
--- a/src/Mocale/Extensions/BindableObjectExtension.cs
+++ b/src/Mocale/Extensions/BindableObjectExtension.cs
@@ -1,6 +1,17 @@
namespace Mocale.Extensions;
+
+///
+/// Bindable Object Extension
+///
public static class BindableObjectExtension
{
+ ///
+ /// Set Translation
+ ///
+ /// The bindable object to apply a translation
+ /// The bindable property to target for translation
+ /// The translation key
+ /// An optional converter
public static void SetTranslation(this BindableObject bindableObject, BindableProperty property, string translationKey, IValueConverter? converter = null)
{
var binding = new Binding
diff --git a/src/Mocale/Extensions/DictionaryExtension.cs b/src/Mocale/Extensions/DictionaryExtension.cs
index c0d4503..2433e67 100644
--- a/src/Mocale/Extensions/DictionaryExtension.cs
+++ b/src/Mocale/Extensions/DictionaryExtension.cs
@@ -7,7 +7,7 @@ public static void AddOrUpdateValues(this Dictionary currentValu
var newValues = updatedValues.Where(uv => !currentValues.ContainsKey(uv.Key))
.ToList();
- if (newValues.Any())
+ if (newValues.Count > 0)
{
foreach (var newValue in newValues)
{
@@ -20,7 +20,7 @@ public static void AddOrUpdateValues(this Dictionary currentValu
!currentValues[uv.Key].Equals(uv.Value, StringComparison.Ordinal))
.ToList();
- if (modifiedValues.Any())
+ if (modifiedValues.Count > 0)
{
foreach (var modifiedValue in modifiedValues)
{
diff --git a/src/Mocale/Extensions/LocalizeExtension.cs b/src/Mocale/Extensions/LocalizeExtension.cs
index 249c5b5..1a86290 100644
--- a/src/Mocale/Extensions/LocalizeExtension.cs
+++ b/src/Mocale/Extensions/LocalizeExtension.cs
@@ -3,28 +3,53 @@
using Mocale.Managers;
namespace Mocale.Extensions;
+///
+/// Localize Extension
+///
+/// Translator Manager
+[AcceptEmptyServiceProvider]
[ContentProperty(nameof(Key))]
public class LocalizeExtension(ITranslatorManager translatorManager) : IMarkupExtension
{
private readonly ITranslatorManager translatorManager = Guard.Against.Null(translatorManager, nameof(translatorManager));
+ ///
+ /// The translation key
+ ///
public string? Key { get; set; }
+ ///
+ /// Translation parameters
+ ///
public string? Parameters { get; set; }
+ ///
+ /// Binding
+ ///
public BindingBase? Binding { get; set; }
+ ///
+ /// Parameter delimiter (for string)
+ ///
public char SplitDelimiter { get; set; } = '|';
+ ///
+ /// Converter
+ ///
public IValueConverter? Converter { get; set; }
+ ///
+ /// Localize Extension
+ ///
public LocalizeExtension()
: this(MocaleLocator.TranslatorManager)
{
}
+ ///
public BindingBase ProvideValue(IServiceProvider serviceProvider)
{
+ //TODO: Pass in itranslator
if (!string.IsNullOrEmpty(Parameters))
{
var parameters = Parameters.Contains(SplitDelimiter)
@@ -44,7 +69,7 @@ public BindingBase ProvideValue(IServiceProvider serviceProvider)
}
else if (Binding is Binding originalBinding)
{
- var parameter = translatorManager.Translate(Key);
+ var parameter = translatorManager.Translate(Key ?? string.Empty);
var converter = new LocalizeBindingConverter();
@@ -77,7 +102,7 @@ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
return ProvideValue(serviceProvider);
}
- public class LocalizeBindingConverter : IValueConverter
+ private class LocalizeBindingConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
diff --git a/src/Mocale/Managers/ConfigurationManager.cs b/src/Mocale/Managers/ConfigurationManager.cs
index b1c0bd3..e292162 100644
--- a/src/Mocale/Managers/ConfigurationManager.cs
+++ b/src/Mocale/Managers/ConfigurationManager.cs
@@ -6,15 +6,13 @@ namespace Mocale.Managers;
/// Simple Singleton Style Class For Storing Configuration Objects
///
///
-public class ConfigurationManager : IConfigurationManager, IConfigurationUpdateManager
+public class ConfigurationManager(TConfig config)
+ : IConfigurationManager, IConfigurationUpdateManager
{
- public TConfig Configuration { get; set; }
-
- public ConfigurationManager(TConfig config)
- {
- Configuration = Guard.Against.Null(config, nameof(config));
- }
+ ///
+ public TConfig Configuration { get; set; } = Guard.Against.Null(config, nameof(config));
+ ///
public void UpdateConfiguration(Action configuration)
{
configuration(Configuration);
diff --git a/src/Mocale/Managers/CurrentCultureManager.cs b/src/Mocale/Managers/CurrentCultureManager.cs
index 5d25d3a..f6c08dc 100644
--- a/src/Mocale/Managers/CurrentCultureManager.cs
+++ b/src/Mocale/Managers/CurrentCultureManager.cs
@@ -3,7 +3,7 @@
namespace Mocale.Managers;
-public class CurrentCultureManager : ICurrentCultureManager
+internal class CurrentCultureManager : ICurrentCultureManager
{
#region Fields
diff --git a/src/Mocale/Managers/LocalizationManager.cs b/src/Mocale/Managers/LocalizationManager.cs
index 4dce1db..c5bd8d3 100644
--- a/src/Mocale/Managers/LocalizationManager.cs
+++ b/src/Mocale/Managers/LocalizationManager.cs
@@ -2,7 +2,7 @@
using Ardalis.GuardClauses;
namespace Mocale.Managers;
-public class LocalizationManager : ILocalizationManager
+internal class LocalizationManager : ILocalizationManager
{
private readonly ICurrentCultureManager currentCultureManager;
private readonly ILogger logger;
diff --git a/src/Mocale/Managers/TranslationResolver.cs b/src/Mocale/Managers/TranslationResolver.cs
index 543ebf0..2512cc3 100644
--- a/src/Mocale/Managers/TranslationResolver.cs
+++ b/src/Mocale/Managers/TranslationResolver.cs
@@ -2,36 +2,24 @@
using Ardalis.GuardClauses;
namespace Mocale.Managers;
-public class TranslationResolver : ITranslationResolver
+internal class TranslationResolver(
+ ICacheUpdateManager cacheUpdateManager,
+ IExternalLocalizationProvider externalLocalizationProvider,
+ IInternalLocalizationProvider internalLocalizationProvider,
+ ILocalisationCacheManager localisationCacheManager,
+ ILogger logger)
+ : ITranslationResolver
{
#region Fields
- private readonly ICacheUpdateManager cacheUpdateManager;
- private readonly IExternalLocalizationProvider externalLocalizationProvider;
- private readonly IInternalLocalizationProvider internalLocalizationProvider;
- private readonly ILocalisationCacheManager localisationCacheManager;
- private readonly ILogger logger;
+ private readonly ICacheUpdateManager cacheUpdateManager = Guard.Against.Null(cacheUpdateManager, nameof(cacheUpdateManager));
+ private readonly IExternalLocalizationProvider externalLocalizationProvider = Guard.Against.Null(externalLocalizationProvider, nameof(externalLocalizationProvider));
+ private readonly IInternalLocalizationProvider internalLocalizationProvider = Guard.Against.Null(internalLocalizationProvider, nameof(internalLocalizationProvider));
+ private readonly ILocalisationCacheManager localisationCacheManager = Guard.Against.Null(localisationCacheManager, nameof(localisationCacheManager));
+ private readonly ILogger logger = Guard.Against.Null(logger, nameof(logger));
#endregion Fields
- #region Constructors
-
- public TranslationResolver(
- ICacheUpdateManager cacheUpdateManager,
- IExternalLocalizationProvider externalLocalizationProvider,
- IInternalLocalizationProvider internalLocalizationProvider,
- ILocalisationCacheManager localisationCacheManager,
- ILogger logger)
- {
- this.cacheUpdateManager = Guard.Against.Null(cacheUpdateManager, nameof(cacheUpdateManager));
- this.externalLocalizationProvider = Guard.Against.Null(externalLocalizationProvider, nameof(externalLocalizationProvider));
- this.internalLocalizationProvider = Guard.Against.Null(internalLocalizationProvider, nameof(internalLocalizationProvider));
- this.localisationCacheManager = Guard.Against.Null(localisationCacheManager, nameof(localisationCacheManager));
- this.logger = Guard.Against.Null(logger, nameof(logger));
- }
-
- #endregion Constructors
-
#region Methods
private async Task LoadTranslationsInternal(CultureInfo cultureInfo)
@@ -158,7 +146,7 @@ public TranslationLoadResult LoadLocalTranslations(CultureInfo cultureInfo)
}
}
- if (addedKeys.Any())
+ if (addedKeys.Count > 0)
{
logger.LogInformation("The following keys were present in the local translations but not in the cache: {AddedKeys}", addedKeys);
}
diff --git a/src/Mocale/Managers/TranslatorManager.cs b/src/Mocale/Managers/TranslatorManager.cs
index c7aae1a..ed37ab9 100644
--- a/src/Mocale/Managers/TranslatorManager.cs
+++ b/src/Mocale/Managers/TranslatorManager.cs
@@ -3,7 +3,7 @@
using Ardalis.GuardClauses;
namespace Mocale.Managers;
-public class TranslatorManager : ITranslatorManager, ITranslationUpdater, INotifyPropertyChanged
+internal class TranslatorManager : ITranslatorManager, ITranslationUpdater, INotifyPropertyChanged
{
#region Fields
@@ -73,9 +73,14 @@ public TranslatorManager(
{
var translation = Translate(key);
+ if (string.IsNullOrEmpty(translation))
+ {
+ return translation;
+ }
+
try
{
- return string.Format(translation, parameters);
+ return string.Format(CurrentCulture, translation, parameters);
}
catch (Exception ex)
{
diff --git a/src/Mocale/Mocale.csproj b/src/Mocale/Mocale.csproj
index 27fda4e..48011c4 100644
--- a/src/Mocale/Mocale.csproj
+++ b/src/Mocale/Mocale.csproj
@@ -12,13 +12,7 @@
Mocale
Localization framework for .NET Maui with support for over the air localization updates from external data sources.
true
-
- 14.2
- 14.0
- 21.0
- 10.0.17763.0
- 10.0.17763.0
- 6.5
+ true
@@ -30,7 +24,7 @@
-
+
diff --git a/src/Mocale/MocaleBuilder.cs b/src/Mocale/MocaleBuilder.cs
index 3303b43..5a8c976 100644
--- a/src/Mocale/MocaleBuilder.cs
+++ b/src/Mocale/MocaleBuilder.cs
@@ -1,12 +1,24 @@
using Mocale.Managers;
namespace Mocale;
+///
+/// Mocale Builder
+///
public class MocaleBuilder
{
+ ///
+ /// Internal Localization Provider
+ ///
public IInternalLocalizationProvider? LocalizationProvider { get; set; }
+ ///
+ /// Maui App Builder
+ ///
public required MauiAppBuilder AppBuilder { get; set; }
+ ///
+ /// Configuration Manager
+ ///
public required ConfigurationManager ConfigurationManager { get; set; }
internal string? LocalProviderName { get; set; }
@@ -19,6 +31,12 @@ public class MocaleBuilder
internal bool CacheProviderRegistered { get; set; }
+ ///
+ /// Use Mocale With Given Configuration
+ ///
+ /// Action to configure mocale
+ /// Mocale builder
+ ///
public MocaleBuilder WithConfiguration(Action configureMocale)
{
var config = ConfigurationManager.Configuration as MocaleConfiguration
diff --git a/src/Mocale/MocaleBuilderExtensions.cs b/src/Mocale/MocaleBuilderExtensions.cs
index 37636c0..50a7e62 100644
--- a/src/Mocale/MocaleBuilderExtensions.cs
+++ b/src/Mocale/MocaleBuilderExtensions.cs
@@ -5,6 +5,9 @@
using Mocale.Providers;
namespace Mocale;
+///
+/// Mocale Builder Extensions
+///
public static class MocaleBuilderExtensions
{
///
diff --git a/src/Mocale/Models/AppResourcesConfig.cs b/src/Mocale/Models/AppResourcesConfig.cs
index 477d399..8fb5bac 100644
--- a/src/Mocale/Models/AppResourcesConfig.cs
+++ b/src/Mocale/Models/AppResourcesConfig.cs
@@ -1,9 +1,8 @@
namespace Mocale.Models;
-///
-/// Configuration for App Resources localizations
-///
+///
public class AppResourcesConfig : IAppResourcesConfig
{
+ ///
public Type? AppResourcesType { get; set; }
}
diff --git a/src/Mocale/Models/EmbeddedResourcesConfig.cs b/src/Mocale/Models/EmbeddedResourcesConfig.cs
index 49e8c37..df12177 100644
--- a/src/Mocale/Models/EmbeddedResourcesConfig.cs
+++ b/src/Mocale/Models/EmbeddedResourcesConfig.cs
@@ -1,11 +1,15 @@
using System.Reflection;
namespace Mocale.Models;
+///
public class EmbeddedResourcesConfig : IEmbeddedResourcesConfig
{
+ ///
public string ResourcesPath { get; set; } = "Locales";
+ ///
public Assembly? ResourcesAssembly { get; set; }
+ ///
public bool UseResourceFolder { get; set; } = true;
}
diff --git a/src/Mocale/Models/ExternalLocalizationResult.cs b/src/Mocale/Models/ExternalLocalizationResult.cs
index 7ab1405..33792fe 100644
--- a/src/Mocale/Models/ExternalLocalizationResult.cs
+++ b/src/Mocale/Models/ExternalLocalizationResult.cs
@@ -4,5 +4,5 @@ internal class ExternalLocalizationResult : IExternalLocalizationResult
{
public required bool Success { get; set; }
- public Dictionary Localizations { get; set; } = new Dictionary();
+ public Dictionary Localizations { get; set; } = [];
}
diff --git a/src/Mocale/Models/JsonResourceFileDetails.cs b/src/Mocale/Models/JsonResourceFileDetails.cs
index d3c5a13..5925209 100644
--- a/src/Mocale/Models/JsonResourceFileDetails.cs
+++ b/src/Mocale/Models/JsonResourceFileDetails.cs
@@ -1,5 +1,6 @@
namespace Mocale.Models;
+///
public class JsonResourceFileDetails : IResourceFileDetails
{
///
diff --git a/src/Mocale/Models/Localization.cs b/src/Mocale/Models/Localization.cs
index 5a87109..7ed778e 100644
--- a/src/Mocale/Models/Localization.cs
+++ b/src/Mocale/Models/Localization.cs
@@ -1,13 +1,24 @@
using System.Globalization;
namespace Mocale.Models;
+///
+/// Localization
+///
public class Localization
{
+ ///
+ /// Corresponding culture
+ ///
public required CultureInfo CultureInfo { get; set; }
- public Dictionary Translations { get; set; } = new Dictionary();
+ ///
+ /// Translations
+ ///
+ public Dictionary Translations { get; set; } = [];
- // This is to get around nullable
+ ///
+ /// Blank localization
+ ///
public static Localization Invariant => new()
{
CultureInfo = new CultureInfo(""),
diff --git a/src/Mocale/Models/MocaleConfiguration.cs b/src/Mocale/Models/MocaleConfiguration.cs
index ee1263f..5ee5b98 100644
--- a/src/Mocale/Models/MocaleConfiguration.cs
+++ b/src/Mocale/Models/MocaleConfiguration.cs
@@ -1,6 +1,7 @@
using System.Globalization;
namespace Mocale.Models;
+///
public class MocaleConfiguration : IMocaleConfiguration
{
///
diff --git a/src/Mocale/Models/ResxResourceFileDetails.cs b/src/Mocale/Models/ResxResourceFileDetails.cs
index 9325af8..42c2500 100644
--- a/src/Mocale/Models/ResxResourceFileDetails.cs
+++ b/src/Mocale/Models/ResxResourceFileDetails.cs
@@ -2,6 +2,7 @@
namespace Mocale.Models;
+///
public class ResxResourceFileDetails : IResourceFileDetails
{
///
diff --git a/src/Mocale/Models/TranslationLoadResult.cs b/src/Mocale/Models/TranslationLoadResult.cs
index c304408..6aa0812 100644
--- a/src/Mocale/Models/TranslationLoadResult.cs
+++ b/src/Mocale/Models/TranslationLoadResult.cs
@@ -1,10 +1,22 @@
namespace Mocale.Models;
+///
+/// Translation Load Result
+///
public class TranslationLoadResult
{
+ ///
+ /// Whether translations were loaded
+ ///
public bool Loaded { get; set; }
+ ///
+ /// Source of the translations
+ ///
public TranslationSource Source { get; set; }
+ ///
+ ///
+ ///
public required Localization Localization { get; set; }
}
diff --git a/src/Mocale/Parsers/JsonLocalizationParser.cs b/src/Mocale/Parsers/JsonLocalizationParser.cs
index 3b2a938..48b343a 100644
--- a/src/Mocale/Parsers/JsonLocalizationParser.cs
+++ b/src/Mocale/Parsers/JsonLocalizationParser.cs
@@ -3,14 +3,9 @@
namespace Mocale.Parsers;
-internal class JsonLocalizationParser : ILocalizationParser
+internal class JsonLocalizationParser(ILogger logger) : ILocalizationParser
{
- private readonly ILogger logger;
-
- public JsonLocalizationParser(ILogger logger)
- {
- this.logger = Guard.Against.Null(logger, nameof(logger));
- }
+ private readonly ILogger logger = Guard.Against.Null(logger, nameof(logger));
public Dictionary? ParseLocalizationStream(Stream resourceStream)
{
diff --git a/src/Mocale/Parsers/ResxLocalizationParser.cs b/src/Mocale/Parsers/ResxLocalizationParser.cs
index c6ec651..f491170 100644
--- a/src/Mocale/Parsers/ResxLocalizationParser.cs
+++ b/src/Mocale/Parsers/ResxLocalizationParser.cs
@@ -3,14 +3,9 @@
namespace Mocale.Parsers;
-internal class ResxLocalizationParser : ILocalizationParser
+internal class ResxLocalizationParser(ILogger logger) : ILocalizationParser
{
- private readonly ILogger logger;
-
- public ResxLocalizationParser(ILogger logger)
- {
- this.logger = Guard.Against.Null(logger, nameof(logger));
- }
+ private readonly ILogger logger = Guard.Against.Null(logger, nameof(logger));
public Dictionary? ParseLocalizationStream(Stream resourceStream)
{
diff --git a/src/Mocale/Providers/EmbeddedResourceProvider.cs b/src/Mocale/Providers/EmbeddedResourceProvider.cs
index 18e8a30..dd12e6e 100644
--- a/src/Mocale/Providers/EmbeddedResourceProvider.cs
+++ b/src/Mocale/Providers/EmbeddedResourceProvider.cs
@@ -3,18 +3,13 @@
using System.Text.Json;
namespace Mocale.Providers;
-internal class EmbeddedResourceProvider : IInternalLocalizationProvider
+internal class EmbeddedResourceProvider(
+ IConfigurationManager jsonConfigurationManager,
+ ILogger logger)
+ : IInternalLocalizationProvider
{
- private readonly IEmbeddedResourcesConfig localConfig;
- private readonly ILogger logger;
-
- public EmbeddedResourceProvider(
- IConfigurationManager jsonConfigurationManager,
- ILogger logger)
- {
- localConfig = jsonConfigurationManager.Configuration;
- this.logger = logger;
- }
+ private readonly IEmbeddedResourcesConfig localConfig = jsonConfigurationManager.Configuration;
+ private readonly ILogger logger = logger;
public Dictionary? GetValuesForCulture(CultureInfo cultureInfo)
{
@@ -37,7 +32,7 @@ public EmbeddedResourceProvider(
var localesFolderResources = resources.Where(r => r.StartsWith(folderPrefix, StringComparison.InvariantCultureIgnoreCase))
.ToList();
- if (!localesFolderResources.Any())
+ if (localesFolderResources.Count < 1)
{
logger.LogWarning("No assembly resources found with prefix: {FolderPrefix}", folderPrefix);
return null;
@@ -80,8 +75,7 @@ private static bool FileMatchesCulture(string resourceName, CultureInfo culture)
try
{
- return JsonSerializer.Deserialize>(fileStream)
- ?? new Dictionary();
+ return JsonSerializer.Deserialize>(fileStream) ?? [];
}
catch (Exception ex)
{
diff --git a/src/directory.build.props b/src/directory.build.props
index 146c664..a188a65 100644
--- a/src/directory.build.props
+++ b/src/directory.build.props
@@ -36,8 +36,8 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/tests/Mocale.UnitTests/.editorconfig b/tests/Mocale.UnitTests/.editorconfig
new file mode 100644
index 0000000..3f79c1b
--- /dev/null
+++ b/tests/Mocale.UnitTests/.editorconfig
@@ -0,0 +1,12 @@
+###############################
+# Core EditorConfig Options #
+###############################
+
+# Csharp files
+[*.{cs,vb}]
+dotnet_diagnostic.CA1309.severity = none
+dotnet_diagnostic.CA1861.severity = none
+
+# Resharper
+[resharper_]
+resharper_structured_message_template_problem_highlighting = none
\ No newline at end of file
diff --git a/tests/Mocale.UnitTests/Extensions/BindableObjectExtensionTests.cs b/tests/Mocale.UnitTests/Extensions/BindableObjectExtensionTests.cs
index 06f2cb7..18f27cf 100644
--- a/tests/Mocale.UnitTests/Extensions/BindableObjectExtensionTests.cs
+++ b/tests/Mocale.UnitTests/Extensions/BindableObjectExtensionTests.cs
@@ -76,7 +76,7 @@ public void SetTranslation_WhenTranslationKeyExists_ShouldSetTranslation()
}
};
- translatorManager.UpdateTranslations(localization, TranslationSource.Internal);;
+ translatorManager.UpdateTranslations(localization, TranslationSource.Internal);
var label = new Label();
diff --git a/tests/Mocale.UnitTests/Extensions/DictionaryExtensionTests.cs b/tests/Mocale.UnitTests/Extensions/DictionaryExtensionTests.cs
index dc88cf1..847a4a0 100644
--- a/tests/Mocale.UnitTests/Extensions/DictionaryExtensionTests.cs
+++ b/tests/Mocale.UnitTests/Extensions/DictionaryExtensionTests.cs
@@ -18,7 +18,7 @@ public void AddOrUpdateValues_WhenCurrentValueIsEmpty_ShouldAddNewValues()
current.AddOrUpdateValues(updated);
// Assert
- Assert.True(current.Count == 2);
+ Assert.Equal(2, current.Count);
current.Should().BeEquivalentTo(new Dictionary()
{
{ "Key One", "Value One" },
@@ -46,7 +46,7 @@ public void AddOrUpdateValues_WhenCurrentValueHasEntriesAndNewValuesAreAllDistin
current.AddOrUpdateValues(updated);
// Assert
- Assert.True(current.Count == 4);
+ Assert.Equal(4, current.Count);
current.Should().BeEquivalentTo(new Dictionary()
{
{ "Key One", "Value One" },
@@ -76,7 +76,7 @@ public void AddOrUpdateValues_WhenCurrentValueHasEntriesAndAllValuesAreSame_Shou
current.AddOrUpdateValues(updated);
// Assert
- Assert.True(current.Count == 2);
+ Assert.Equal(2, current.Count);
current.Should().BeEquivalentTo(new Dictionary()
{
{ "Key One", "Value One" },
@@ -103,7 +103,7 @@ public void AddOrUpdateValues_WhenCurrentValueHasEntriesAndNewValuesAreDifferent
current.AddOrUpdateValues(updated);
// Assert
- Assert.True(current.Count == 2);
+ Assert.Equal(2, current.Count);
current.Should().BeEquivalentTo(new Dictionary()
{
{ "Key One", "Value One" },
@@ -131,7 +131,7 @@ public void AddOrUpdateValues_WhenSomeNewValuesAndSomeUpdatedValues_ShouldAddAnd
current.AddOrUpdateValues(updated);
// Assert
- Assert.True(current.Count == 3);
+ Assert.Equal(3, current.Count);
current.Should().BeEquivalentTo(new Dictionary()
{
{ "Key One", "Value One" },
diff --git a/tests/Mocale.UnitTests/Extensions/StringExtensionTests.cs b/tests/Mocale.UnitTests/Extensions/StringExtensionTests.cs
index 2bbeb93..8b1e728 100644
--- a/tests/Mocale.UnitTests/Extensions/StringExtensionTests.cs
+++ b/tests/Mocale.UnitTests/Extensions/StringExtensionTests.cs
@@ -5,7 +5,6 @@ namespace Mocale.UnitTests.Extensions;
public class StringExtensionTests
{
[Theory]
- [InlineData(null)]
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
diff --git a/tests/Mocale.UnitTests/Managers/TranslatorManagerTests.cs b/tests/Mocale.UnitTests/Managers/TranslatorManagerTests.cs
index 5309f1d..c675754 100644
--- a/tests/Mocale.UnitTests/Managers/TranslatorManagerTests.cs
+++ b/tests/Mocale.UnitTests/Managers/TranslatorManagerTests.cs
@@ -7,20 +7,14 @@
namespace Mocale.UnitTests.Managers;
-public class TranslatorManagerTests : FixtureBase
+public class TranslatorManagerTests : FixtureBase
{
#region Setup
- private readonly Mock> logger;
- private readonly Mock> configManager;
+ private readonly Mock> logger = new();
+ private readonly Mock> configManager = new();
- public TranslatorManagerTests()
- {
- logger = new Mock>();
- configManager = new Mock>();
- }
-
- public override TranslatorManager CreateSystemUnderTest()
+ public override object CreateSystemUnderTest()
{
return new TranslatorManager(logger.Object, configManager.Object);
}
@@ -39,10 +33,12 @@ public void Translate_WhenExternalLocalizationsContainsKey_ShouldReturnLocalizat
Translations = new Dictionary { { "KeyOne", "I am the first key" } }
};
- Sut.UpdateTranslations(localization, TranslationSource.External);
+ var sut = GetSut();
+
+ sut.UpdateTranslations(localization, TranslationSource.External);
// Act
- var translation = Sut.Translate("KeyOne");
+ var translation = sut.Translate("KeyOne");
// Assert
Assert.Equal("I am the first key", translation);
@@ -60,10 +56,12 @@ public void Translate_WhenInternalLocalizationsContainsKey_ShouldReturnLocalizat
Translations = new Dictionary { { "KeyOne", "I am the first key" } }
};
- Sut.UpdateTranslations(localization, TranslationSource.Internal);
+ var sut = GetSut();
+
+ sut.UpdateTranslations(localization, TranslationSource.Internal);
// Act
- var translation = Sut.Translate("KeyOne");
+ var translation = sut.Translate("KeyOne");
// Assert
Assert.Equal("I am the first key", translation);
@@ -78,8 +76,10 @@ public void Translate_WhenNoLocalizationsForKeyAndShowMissingKeysIsDisabled_Shou
configManager.SetupGet(m => m.Configuration)
.Returns(new MocaleConfiguration { ShowMissingKeys = false });
+ var sut = GetSut();
+
// Act
- var translation = Sut.Translate("KeyOne");
+ var translation = sut.Translate("KeyOne");
// Assert
Assert.Equal(string.Empty, translation);
@@ -100,8 +100,10 @@ public void Translate_WhenNoLocalizationsForKeyAndShowMissingKeysIsEnabled_Shoul
configManager.SetupGet(m => m.Configuration)
.Returns(new MocaleConfiguration { ShowMissingKeys = true, NotFoundSymbol = missingSymbol });
+ var sut = GetSut();
+
// Act
- var translation = Sut.Translate("KeyOne");
+ var translation = sut.Translate("KeyOne");
// Assert
Assert.Equal(expectedTranslation, translation);
@@ -125,12 +127,14 @@ public void Translate_WhenCultureChanges_ShouldReturnNewLocalization()
Translations = new Dictionary { { "KeyOne", "je suis la première clé" } }
};
- Sut.UpdateTranslations(englishLocalization, TranslationSource.External);
+ var sut = GetSut();
+
+ sut.UpdateTranslations(englishLocalization, TranslationSource.External);
// Act
- Sut.UpdateTranslations(frenchLocalization, TranslationSource.External);
+ sut.UpdateTranslations(frenchLocalization, TranslationSource.External);
- var translation = Sut.Translate("KeyOne");
+ var translation = sut.Translate("KeyOne");
// Assert
Assert.Equal("je suis la première clé", translation);
@@ -155,12 +159,14 @@ public void Translate_WhenCultureChangesAndNewCultureDoesntContainKey_ShouldRetu
configManager.SetupGet(m => m.Configuration)
.Returns(new MocaleConfiguration { ShowMissingKeys = true, NotFoundSymbol = "_" });
- Sut.UpdateTranslations(englishLocalization, TranslationSource.External);
+ var sut = GetSut();
+
+ sut.UpdateTranslations(englishLocalization, TranslationSource.External);
// Act
- Sut.UpdateTranslations(frenchLocalization, TranslationSource.External);
+ sut.UpdateTranslations(frenchLocalization, TranslationSource.External);
- var translation = Sut.Translate("KeyOne");
+ var translation = sut.Translate("KeyOne");
// Assert
Assert.Equal("_KeyOne_", translation);
diff --git a/tests/Mocale.UnitTests/Mocale.UnitTests.csproj b/tests/Mocale.UnitTests/Mocale.UnitTests.csproj
index bb064c0..bc7c585 100644
--- a/tests/Mocale.UnitTests/Mocale.UnitTests.csproj
+++ b/tests/Mocale.UnitTests/Mocale.UnitTests.csproj
@@ -7,23 +7,24 @@
false
true
true
+ $(NoWarn);CA2254;IDE0005
-
+
-
+
-
-
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
@@ -33,7 +34,7 @@
-
+