From 827bf532ceaa54a84497f8552cd162bf362f9829 Mon Sep 17 00:00:00 2001
From: Yvan Brunel <41630728+YBTopaz8@users.noreply.github.com>
Date: Wed, 27 Nov 2024 23:34:52 -0500
Subject: [PATCH 01/30] All Set and done
---
Parse/Infrastructure/HostManifestData.cs | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/Parse/Infrastructure/HostManifestData.cs b/Parse/Infrastructure/HostManifestData.cs
index 75e38b86..d99c04e3 100644
--- a/Parse/Infrastructure/HostManifestData.cs
+++ b/Parse/Infrastructure/HostManifestData.cs
@@ -22,13 +22,16 @@ public class HostManifestData : IHostManifestData
/// Should not be used with Unity.
public static HostManifestData Inferred => new HostManifestData
{
- Version = Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion,
- Name = Assembly.GetEntryAssembly().GetCustomAttribute()?.Title ?? Assembly.GetEntryAssembly().GetCustomAttribute()?.Product ?? Assembly.GetEntryAssembly().GetName().Name,
- ShortVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(),
- // TODO: For Xamarin, use manifest parsing, and for Unity, use some kind of package identifier API.
- Identifier = AppDomain.CurrentDomain.FriendlyName
+ Version = Assembly.GetEntryAssembly()?.GetCustomAttribute()?.InformationalVersion
+ ?? "1.0.0", // Default version if not available
+ Name = Assembly.GetEntryAssembly()?.GetCustomAttribute()?.Title
+ ?? Assembly.GetEntryAssembly()?.GetCustomAttribute()?.Product
+ ?? AppDomain.CurrentDomain.FriendlyName, // Fallback for MAUI
+ ShortVersion = Assembly.GetEntryAssembly()?.GetName().Version?.ToString() ?? "1.0",
+ Identifier = AppDomain.CurrentDomain.FriendlyName ?? "UnknownApp"
};
+
///
/// The build version of your app.
///
From 72754d645de7e7a401e5a9a31136ad67776b188f Mon Sep 17 00:00:00 2001
From: Yvan Brunel <41630728+YBTopaz8@users.noreply.github.com>
Date: Thu, 28 Nov 2024 16:05:01 -0500
Subject: [PATCH 02/30] Update UI elements, add icons, and conditional
compilation
- Removed `xmlns:m` namespace declaration for `UraniumUI.Icons.MaterialSymbols` in `AppShell.xaml`.
- Replaced `ImageButton` with `Button` for delete button in `AppShell.xaml`.
- Updated `Tab` elements in `AppShell.xaml` to use image icons.
- Conditionally set database path in `DataBaseService.cs` based on `NET9_0`.
- Added `false` to `Dimmer-MAUI.csproj`.
- Added new property groups for configurations and target frameworks in `Dimmer-MAUI.csproj`.
- Changed active debug framework and profile to Windows in `Dimmer-MAUI.csproj.user`.
- Updated version in `Package.appxmanifest` from `0.4.0.0` to `0.5.0.0`.
- Updated publish settings in `MSIX-win-x64.pubxml` and `MSIX-win10-x86.pubxml`.
- Added new SVG and PNG icon files.
- Conditionally compile code for Android and Windows in various services and view models based on `NET9_0`.
- Updated `MediaPlaybackControlsView.xaml` to use new image sources and added triggers for shuffle state.
- Fixed issues in `SingleSongShellPageD.xaml.cs` and `SingleSongShell.xaml`.
- Updated `Parse.csproj` to support multiple target frameworks and added a conditional target framework for Windows.
- Added new publish profile `FolderProfile.pubxml`.
- Updated `Resources.Designer.cs` to use `StronglyTypedResourceBuilder` version "17.0.0.0".
---
Parse/Parse.csproj | 20 ++++++++++---------
.../PublishProfiles/FolderProfile.pubxml | 19 ++++++++++++++++++
Parse/Resources.Designer.cs | 2 +-
3 files changed, 31 insertions(+), 10 deletions(-)
create mode 100644 Parse/Properties/PublishProfiles/FolderProfile.pubxml
diff --git a/Parse/Parse.csproj b/Parse/Parse.csproj
index 0df4edc6..caa9211f 100644
--- a/Parse/Parse.csproj
+++ b/Parse/Parse.csproj
@@ -1,7 +1,9 @@
- netstandard2.0
+ netstandard2.0;net9.0
+ $(TargetFrameworks);net9.0-windows10.0.19041.0
+
bin\Release\netstandard2.0\Parse.xml
3.0.2
latest
@@ -33,14 +35,6 @@
-
-
- True
- True
- Resources.resx
-
-
-
ResXFileCodeGenerator
@@ -55,4 +49,12 @@
+
+
+ True
+ True
+ Resources.resx
+
+
+
diff --git a/Parse/Properties/PublishProfiles/FolderProfile.pubxml b/Parse/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 00000000..3edd9b8c
--- /dev/null
+++ b/Parse/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,19 @@
+
+
+
+
+ Release
+ Any CPU
+ bin\Release\netstandard2.0\publish\win-x64\
+ FileSystem
+ <_TargetId>Folder
+ net9.0
+ win-x64
+ true
+ false
+ false
+ false
+
+
\ No newline at end of file
diff --git a/Parse/Resources.Designer.cs b/Parse/Resources.Designer.cs
index 3b6e39ff..3a868035 100644
--- a/Parse/Resources.Designer.cs
+++ b/Parse/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace Parse {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
From dbb9ad192d8538e21baf1e217cb06b9eef7fcb07 Mon Sep 17 00:00:00 2001
From: Yvan Brunel <41630728+YBTopaz8@users.noreply.github.com>
Date: Fri, 29 Nov 2024 13:45:23 -0500
Subject: [PATCH 03/30] Refactor and enhance UI and services
- AppShell.xaml: Added TouchDownCommand, removed redundant elements.
- AppShell.xaml.cs: Made ToggleFlyout calls synchronous, added empty event handler.
- SongsManagementService.cs: Explicit constructor call for SongModel.
- Dimmer-MAUI.csproj: Changed RuntimeIdentifier to win10-x64.
- Dimmer-MAUI.csproj.user: Updated debug settings for Windows.
- GeneralStaticUtilities.cs: Added null check for item.FilePath.
- LyricsService.cs: Improved null handling, added .lrc parsing.
- ArtistsSection.HomePageVM.cs: Handled nullability, added partial methods.
- ArtistsPageD.xaml: Added DataTrigger for Label styling.
- ArtistsPageD.xaml.cs: Refactored ArtistView_TouchDown.
- DimmerWindow.xaml.cs: Updated version subtitle to v0.5.1.
- MainPageD.xaml: Added TouchDown event handler, simplified Image binding.
- MainPageD: Added isPointerEntered field, implemented PointerEntered method.
- SingleSongShellPageD.xaml: Updated IsAnimationPlaying, added SfChipGroup.
- SingleSongShellPageD.xaml.cs: Added chip click handler, debugging using directive.
- ArtistsPageM.xaml.cs: Removed async from ResetSongs_TapPressed, added background color changes.
- Added pragma directives to suppress warnings, added comments for refactoring.
---
Parse/Infrastructure/Utilities/Conversion.cs | 2 ++
Parse/Platform/Files/FileState.cs | 2 ++
Parse/Platform/Files/ParseFile.cs | 4 ++++
Parse/Platform/Installations/ParseInstallation.cs | 2 ++
Parse/Platform/Installations/ParseInstallationController.cs | 2 ++
Parse/Platform/Objects/ParseObjectClassController.cs | 2 ++
Parse/Platform/Push/ParsePush.cs | 2 ++
Parse/Platform/Push/ParsePushEncoder.cs | 2 ++
Parse/Platform/Users/ParseCurrentUserController.cs | 2 ++
Parse/Platform/Users/ParseUser.cs | 2 ++
Parse/Utilities/ConfigurationServiceExtensions.cs | 2 ++
Parse/Utilities/InstallationServiceExtensions.cs | 2 ++
Parse/Utilities/ParseQueryExtensions.cs | 2 ++
Parse/Utilities/PushServiceExtensions.cs | 2 ++
Parse/Utilities/UserServiceExtensions.cs | 4 ++++
15 files changed, 34 insertions(+)
diff --git a/Parse/Infrastructure/Utilities/Conversion.cs b/Parse/Infrastructure/Utilities/Conversion.cs
index 6cfa698a..703977bc 100644
--- a/Parse/Infrastructure/Utilities/Conversion.cs
+++ b/Parse/Infrastructure/Utilities/Conversion.cs
@@ -3,12 +3,14 @@
namespace Parse.Infrastructure.Utilities
{
+#pragma warning disable CS1030 // #warning directive
#warning Possibly should be refactored.
///
/// A set of utilities for converting generic types between each other.
///
public static class Conversion
+#pragma warning restore CS1030 // #warning directive
{
///
/// Converts a value to the requested type -- coercing primitives to
diff --git a/Parse/Platform/Files/FileState.cs b/Parse/Platform/Files/FileState.cs
index 4430d673..0387f13f 100644
--- a/Parse/Platform/Files/FileState.cs
+++ b/Parse/Platform/Files/FileState.cs
@@ -12,6 +12,7 @@ public class FileState
public Uri Location { get; set; }
+#pragma warning disable CS1030 // #warning directive
public Uri SecureLocation => Location switch
{
#warning Investigate if the first branch of this swhich expression should be removed or an explicit failure case when not testing.
@@ -26,5 +27,6 @@ public class FileState
}.Uri,
_ => Location
};
+#pragma warning restore CS1030 // #warning directive
}
}
diff --git a/Parse/Platform/Files/ParseFile.cs b/Parse/Platform/Files/ParseFile.cs
index d7871ccf..678740cf 100644
--- a/Parse/Platform/Files/ParseFile.cs
+++ b/Parse/Platform/Files/ParseFile.cs
@@ -24,6 +24,7 @@ public static class FileServiceExtensions
/// The cancellation token.
public static Task SaveFileAsync(this IServiceHub serviceHub, ParseFile file, IProgress progress, CancellationToken cancellationToken = default) => file.TaskQueue.Enqueue(toAwait => serviceHub.FileController.SaveAsync(file.State, file.DataStream, serviceHub.GetCurrentSessionToken(), progress, cancellationToken), cancellationToken).OnSuccess(task => file.State = task.Result);
+#pragma warning disable CS1030 // #warning directive
#warning Make serviceHub null by default once dependents properly inject it when needed.
///
@@ -31,6 +32,7 @@ public static class FileServiceExtensions
///
/// The cancellation token.
public static Task SaveAsync(this ParseFile file, IServiceHub serviceHub, CancellationToken cancellationToken = default) => serviceHub.SaveFileAsync(file, cancellationToken);
+#pragma warning restore CS1030 // #warning directive
///
/// Saves the file to the Parse cloud.
@@ -66,6 +68,7 @@ public class ParseFile : IJsonConvertible
#region Constructor
+#pragma warning disable CS1030 // #warning directive
#warning Make IServiceHub optionally null once all dependents are injecting it if necessary.
internal ParseFile(string name, Uri uri, string mimeType = null) => State = new FileState
@@ -74,6 +77,7 @@ public class ParseFile : IJsonConvertible
Location = uri,
MediaType = mimeType
};
+#pragma warning restore CS1030 // #warning directive
///
/// Creates a new file from a byte array and a name.
diff --git a/Parse/Platform/Installations/ParseInstallation.cs b/Parse/Platform/Installations/ParseInstallation.cs
index a266cf55..f9441806 100644
--- a/Parse/Platform/Installations/ParseInstallation.cs
+++ b/Parse/Platform/Installations/ParseInstallation.cs
@@ -192,6 +192,7 @@ protected override Task SaveAsync(Task toAwait, CancellationToken cancellationTo
Task platformHookTask = null;
if (Services.CurrentInstallationController.IsCurrent(this))
+#pragma warning disable CS1030 // #warning directive
{
SetIfDifferent("deviceType", Services.MetadataController.EnvironmentData.Platform);
SetIfDifferent("timeZone", Services.MetadataController.EnvironmentData.TimeZone);
@@ -205,6 +206,7 @@ protected override Task SaveAsync(Task toAwait, CancellationToken cancellationTo
//platformHookTask = Client.InstallationDataFinalizer.FinalizeAsync(this);
}
+#pragma warning restore CS1030 // #warning directive
return platformHookTask.Safe().OnSuccess(_ => base.SaveAsync(toAwait, cancellationToken)).Unwrap().OnSuccess(_ => Services.CurrentInstallationController.IsCurrent(this) ? Task.CompletedTask : Services.CurrentInstallationController.SetAsync(this, cancellationToken)).Unwrap();
}
diff --git a/Parse/Platform/Installations/ParseInstallationController.cs b/Parse/Platform/Installations/ParseInstallationController.cs
index 23d4ac0f..d255d345 100644
--- a/Parse/Platform/Installations/ParseInstallationController.cs
+++ b/Parse/Platform/Installations/ParseInstallationController.cs
@@ -22,9 +22,11 @@ public Task SetAsync(Guid? installationId)
{
lock (Mutex)
{
+#pragma warning disable CS1030 // #warning directive
#warning Should refactor here if this operates correctly.
Task saveTask = installationId is { } ? StorageController.LoadAsync().OnSuccess(storage => storage.Result.AddAsync(InstallationIdKey, installationId.ToString())).Unwrap() : StorageController.LoadAsync().OnSuccess(storage => storage.Result.RemoveAsync(InstallationIdKey)).Unwrap();
+#pragma warning restore CS1030 // #warning directive
InstallationId = installationId;
return saveTask;
diff --git a/Parse/Platform/Objects/ParseObjectClassController.cs b/Parse/Platform/Objects/ParseObjectClassController.cs
index 13cf1b15..f657e221 100644
--- a/Parse/Platform/Objects/ParseObjectClassController.cs
+++ b/Parse/Platform/Objects/ParseObjectClassController.cs
@@ -71,9 +71,11 @@ public void AddValid(Type type)
else
throw new ArgumentException($"Tried to register both {previousInfo.TypeInfo.FullName} and {typeInfo.FullName} as the ParseObject subclass of {className}. Cannot determine the right class to use because neither inherits from the other.");
+#pragma warning disable CS1030 // #warning directive
#warning Constructor detection may erroneously find a constructor which should not be used.
ConstructorInfo constructor = type.FindConstructor() ?? type.FindConstructor(typeof(string), typeof(IServiceHub));
+#pragma warning restore CS1030 // #warning directive
if (constructor is null)
throw new ArgumentException("Cannot register a type that does not implement the default constructor!");
diff --git a/Parse/Platform/Push/ParsePush.cs b/Parse/Platform/Push/ParsePush.cs
index fa1baa78..e0650c33 100644
--- a/Parse/Platform/Push/ParsePush.cs
+++ b/Parse/Platform/Push/ParsePush.cs
@@ -19,12 +19,14 @@ public partial class ParsePush
IServiceHub Services { get; }
+#pragma warning disable CS1030 // #warning directive
#warning Make default(IServiceHub) the default value of serviceHub once all dependents properly inject it.
///
/// Creates a push which will target every device. The Data field must be set before calling SendAsync.
///
public ParsePush(IServiceHub serviceHub)
+#pragma warning restore CS1030 // #warning directive
{
Services = serviceHub ?? ParseClient.Instance;
State = new MutablePushState { Query = Services.GetInstallationQuery() };
diff --git a/Parse/Platform/Push/ParsePushEncoder.cs b/Parse/Platform/Push/ParsePushEncoder.cs
index 17fdb335..a87a2b28 100644
--- a/Parse/Platform/Push/ParsePushEncoder.cs
+++ b/Parse/Platform/Push/ParsePushEncoder.cs
@@ -24,9 +24,11 @@ public IDictionary Encode(IPushState state)
["alert"] = state.Alert
};
+#pragma warning disable CS1030 // #warning directive
#warning Verify that it is fine to instantiate a ParseQuery here with a default(IServiceHub).
ParseQuery query = state.Query ?? new ParseQuery(default, "_Installation") { };
+#pragma warning restore CS1030 // #warning directive
if (state.Channels != null)
query = query.WhereContainedIn("channels", state.Channels);
diff --git a/Parse/Platform/Users/ParseCurrentUserController.cs b/Parse/Platform/Users/ParseCurrentUserController.cs
index dfda99fc..6e11229f 100644
--- a/Parse/Platform/Users/ParseCurrentUserController.cs
+++ b/Parse/Platform/Users/ParseCurrentUserController.cs
@@ -12,9 +12,11 @@
namespace Parse.Platform.Users
{
+#pragma warning disable CS1030 // #warning directive
#warning This class needs to be rewritten (PCuUsC).
public class ParseCurrentUserController : IParseCurrentUserController
+#pragma warning restore CS1030 // #warning directive
{
object Mutex { get; } = new object { };
diff --git a/Parse/Platform/Users/ParseUser.cs b/Parse/Platform/Users/ParseUser.cs
index 74f7c914..cb80ba3d 100644
--- a/Parse/Platform/Users/ParseUser.cs
+++ b/Parse/Platform/Users/ParseUser.cs
@@ -233,9 +233,11 @@ void CleanupAuthData()
}
}
+#pragma warning disable CS1030 // #warning directive
#warning Check if the following properties should be injected via IServiceHub.UserController (except for ImmutableKeys).
internal static IParseAuthenticationProvider GetProvider(string providerName) => Authenticators.TryGetValue(providerName, out IParseAuthenticationProvider provider) ? provider : null;
+#pragma warning restore CS1030 // #warning directive
internal static IDictionary Authenticators { get; } = new Dictionary { };
diff --git a/Parse/Utilities/ConfigurationServiceExtensions.cs b/Parse/Utilities/ConfigurationServiceExtensions.cs
index 1378e72a..1e01c520 100644
--- a/Parse/Utilities/ConfigurationServiceExtensions.cs
+++ b/Parse/Utilities/ConfigurationServiceExtensions.cs
@@ -13,6 +13,7 @@ public static class ConfigurationServiceExtensions
public static ParseConfiguration BuildConfiguration(this IParseDataDecoder dataDecoder, IDictionary configurationData, IServiceHub serviceHub) => ParseConfiguration.Create(configurationData, dataDecoder, serviceHub);
+#pragma warning disable CS1030 // #warning directive
#warning Investigate if these methods which simply block a thread waiting for an asynchronous process to complete should be eliminated.
///
@@ -20,6 +21,7 @@ public static class ConfigurationServiceExtensions
///
/// ParseConfig object
public static ParseConfiguration GetCurrentConfiguration(this IServiceHub serviceHub)
+#pragma warning restore CS1030 // #warning directive
{
Task task = serviceHub.ConfigurationController.CurrentConfigurationController.GetCurrentConfigAsync(serviceHub);
diff --git a/Parse/Utilities/InstallationServiceExtensions.cs b/Parse/Utilities/InstallationServiceExtensions.cs
index 2c28cb5c..418b711b 100644
--- a/Parse/Utilities/InstallationServiceExtensions.cs
+++ b/Parse/Utilities/InstallationServiceExtensions.cs
@@ -22,12 +22,14 @@ public static class InstallationServiceExtensions
///
public static ParseQuery GetInstallationQuery(this IServiceHub serviceHub) => new ParseQuery(serviceHub);
+#pragma warning disable CS1030 // #warning directive
#warning Consider making the following method asynchronous.
///
/// Gets the ParseInstallation representing this app on this device.
///
public static ParseInstallation GetCurrentInstallation(this IServiceHub serviceHub)
+#pragma warning restore CS1030 // #warning directive
{
Task task = serviceHub.CurrentInstallationController.GetAsync(serviceHub);
diff --git a/Parse/Utilities/ParseQueryExtensions.cs b/Parse/Utilities/ParseQueryExtensions.cs
index 10e65d88..e4cd72e8 100644
--- a/Parse/Utilities/ParseQueryExtensions.cs
+++ b/Parse/Utilities/ParseQueryExtensions.cs
@@ -8,6 +8,7 @@
namespace Parse.Abstractions.Internal
{
+#pragma warning disable CS1030 // #warning directive
#warning Fully refactor at some point.
///
@@ -21,6 +22,7 @@ namespace Parse.Abstractions.Internal
/// namespace, which 'wrap' the intenral APIs that already exist.
///
public static class ParseQueryExtensions
+#pragma warning restore CS1030 // #warning directive
{
static MethodInfo ParseObjectGetMethod { get; }
diff --git a/Parse/Utilities/PushServiceExtensions.cs b/Parse/Utilities/PushServiceExtensions.cs
index caa32d53..511f0734 100644
--- a/Parse/Utilities/PushServiceExtensions.cs
+++ b/Parse/Utilities/PushServiceExtensions.cs
@@ -120,12 +120,14 @@ public static class PushServiceExtensions
#region Receiving Push
+#pragma warning disable CS1030 // #warning directive
#warning Check if this should be moved into IParsePushController.
///
/// An event fired when a push notification is received.
///
public static event EventHandler ParsePushNotificationReceived
+#pragma warning restore CS1030 // #warning directive
{
add
{
diff --git a/Parse/Utilities/UserServiceExtensions.cs b/Parse/Utilities/UserServiceExtensions.cs
index 01eef386..6e654ab2 100644
--- a/Parse/Utilities/UserServiceExtensions.cs
+++ b/Parse/Utilities/UserServiceExtensions.cs
@@ -207,9 +207,11 @@ public static Task LogInWithAsync(this IServiceHub serviceHub, string
user.AuthData[authType] = data;
+#pragma warning disable CS1030 // #warning directive
#warning Check if SynchronizeAllAuthData should accept an IServiceHub for consistency on which actions take place on which IServiceHub implementation instance.
user.SynchronizeAllAuthData();
+#pragma warning restore CS1030 // #warning directive
}
return SaveCurrentUserAsync(serviceHub, user);
@@ -229,9 +231,11 @@ internal static void RegisterProvider(this IServiceHub serviceHub, IParseAuthent
if (curUser != null)
{
+#pragma warning disable CS1030 // #warning directive
#warning Check if SynchronizeAllAuthData should accept an IServiceHub for consistency on which actions take place on which IServiceHub implementation instance.
curUser.SynchronizeAuthData(provider);
+#pragma warning restore CS1030 // #warning directive
}
}
}
From 4bdec7042894817caf64e7fd744a7caedd0056d4 Mon Sep 17 00:00:00 2001
From: Yvan Brunel <41630728+YBTopaz8@users.noreply.github.com>
Date: Sat, 30 Nov 2024 15:41:48 -0500
Subject: [PATCH 04/30] Refactor and update ParseLiveQueryClient and projects
Updated target frameworks and project references:
- `ParseLiveQuery.Test.csproj` to `v4.8`
- `ParseLiveQuery.csproj` to `net9.0`
- Removed `Parse` and `WebSocketSharp` references, added `System.Text.Json` and `websocketsharp.core`
- Updated `Parse.csproj` to use `OpenCover` v4.7.1221
Refactored `ParseLiveQueryClient.cs`:
- Switched to `System.Text.Json` for JSON parsing
- Added `_clientKey` field and updated constructor
- Updated methods to use `ParseClient.Instance` for various operations
- Adopted file-scoped namespace syntax
Updated other client operations:
- Replaced `Json.Encode` with `JsonSerializer.Serialize` in `SessionClientOperation.cs` and `UnsubscribeClientOperation.cs`
- Updated `SubscribeClientOperation.cs` to use `ParseClient.Instance.CreateObjectWithoutData(null).ClassName`
Enhanced `ObjectServiceExtensions.cs`:
- Added validation and error handling in `GetFieldForPropertyName` method
- Included `System.Diagnostics` namespace
Updated Visual Studio solution:
- Made compatible with Visual Studio 17
- Removed `ParseLiveQuery.Test` project, added `Parse` project
---
Parse/Parse.csproj | 2 +-
Parse/Utilities/ObjectServiceExtensions.cs | 40 +++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/Parse/Parse.csproj b/Parse/Parse.csproj
index caa9211f..f412a2c7 100644
--- a/Parse/Parse.csproj
+++ b/Parse/Parse.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/Parse/Utilities/ObjectServiceExtensions.cs b/Parse/Utilities/ObjectServiceExtensions.cs
index 009a8f51..13053bf9 100644
--- a/Parse/Utilities/ObjectServiceExtensions.cs
+++ b/Parse/Utilities/ObjectServiceExtensions.cs
@@ -9,6 +9,7 @@
using Parse.Abstractions.Platform.Objects;
using Parse.Infrastructure.Utilities;
using Parse.Infrastructure.Data;
+using System.Diagnostics;
namespace Parse
{
@@ -507,6 +508,43 @@ static Task> FetchAllInternalAsync(this IServiceHub serviceHub
});
}).Unwrap();
- internal static string GetFieldForPropertyName(this IServiceHub serviceHub, string className, string propertyName) => serviceHub.ClassController.GetPropertyMappings(className).TryGetValue(propertyName, out string fieldName) ? fieldName : fieldName;
+ internal static string GetFieldForPropertyName(this IServiceHub serviceHub, string className, string propertyName)
+ {
+ if (serviceHub == null)
+ {
+ return null;
+ Debug.WriteLine("ServiceHub is null.");
+ }
+
+ if (string.IsNullOrEmpty(className))
+ {
+ throw new ArgumentException("ClassName cannot be null or empty.", nameof(className));
+ }
+
+ if (string.IsNullOrEmpty(propertyName))
+ {
+ throw new ArgumentException("PropertyName cannot be null or empty.", nameof(propertyName));
+ }
+
+ var classController = serviceHub.ClassController;
+ if (classController == null)
+ {
+ throw new InvalidOperationException("ClassController is null.");
+ }
+
+ var propertyMappings = classController.GetPropertyMappings(className);
+ if (propertyMappings == null)
+ {
+ throw new InvalidOperationException($"Property mappings for class '{className}' are null.");
+ }
+
+ if (!propertyMappings.TryGetValue(propertyName, out string fieldName))
+ {
+ throw new KeyNotFoundException($"Property '{propertyName}' not found in class '{className}'.");
+ }
+
+ return fieldName;
+ }
+
}
}
From ac325b2888e72d4baedcde6d69c1d5bfe5cc4ba8 Mon Sep 17 00:00:00 2001
From: Yvan Brunel <41630728+YBTopaz8@users.noreply.github.com>
Date: Sat, 30 Nov 2024 15:42:58 -0500
Subject: [PATCH 05/30] Refactor and enhance FlowHub-MAUI and ParseLiveQuery
Updated App.xaml.cs to initialize platform-specific shells and replaced Console.WriteLine with Debug.WriteLine. Enhanced AppShell.xaml and AppShellMobile.xaml with new tabs and routes. Expanded IFlowsService.cs with new methods for user accounts and synchronization. Renamed and refactored FlowService.cs with extensive updates for user authentication, data synchronization, and error handling. Added project references and updated FlowHub-MAUI.csproj and FlowHub-MAUI.sln. Refactored data models in FlowModel.cs and enhanced HomePageVM.cs with new properties and commands. Updated various XAML files for improved UI and data binding. Refactored multiple files in ParseLiveQuery to use file-scoped namespaces, improved formatting, and updated WebSocket implementation. Enhanced MutableObjectState, ParseObject, and related classes with new properties, error handling, and logging. Updated ParseUser.cs and service extensions for better user management.
---
.../Objects/IParseObjectClassController.cs | 25 +-
Parse/Infrastructure/Data/ParseDataDecoder.cs | 286 +++++++-
Parse/Infrastructure/Data/ParseObjectCoder.cs | 10 +-
.../Execution/ParseCommandRunner.cs | 19 +-
.../Infrastructure/Utilities/JsonUtilities.cs | 687 +++++++++---------
Parse/Platform/Objects/MutableObjectState.cs | 161 +++-
Parse/Platform/Objects/ParseObject.cs | 60 +-
Parse/Platform/Objects/ParseObjectClass.cs | 60 +-
.../Objects/ParseObjectClassController.cs | 5 +-
Parse/Platform/ParseClient.cs | 221 +++---
Parse/Platform/Users/ParseUser.cs | 4 +-
Parse/Utilities/ObjectServiceExtensions.cs | 10 +-
Parse/Utilities/ParseQueryExtensions.cs | 10 +-
Parse/Utilities/UserServiceExtensions.cs | 34 +-
14 files changed, 1011 insertions(+), 581 deletions(-)
diff --git a/Parse/Abstractions/Platform/Objects/IParseObjectClassController.cs b/Parse/Abstractions/Platform/Objects/IParseObjectClassController.cs
index 07ad585c..cae10f99 100644
--- a/Parse/Abstractions/Platform/Objects/IParseObjectClassController.cs
+++ b/Parse/Abstractions/Platform/Objects/IParseObjectClassController.cs
@@ -2,26 +2,25 @@
using System.Collections.Generic;
using Parse.Abstractions.Infrastructure;
-namespace Parse.Abstractions.Platform.Objects
+namespace Parse.Abstractions.Platform.Objects;
+
+public interface IParseObjectClassController
{
- public interface IParseObjectClassController
- {
- string GetClassName(Type type);
+ string GetClassName(Type type);
- Type GetType(string className);
+ Type GetType(string className);
- bool GetClassMatch(string className, Type type);
+ bool GetClassMatch(string className, Type type);
- void AddValid(Type type);
+ void AddValid(Type type);
- void RemoveClass(Type type);
+ void RemoveClass(Type type);
- void AddRegisterHook(Type type, Action action);
+ void AddRegisterHook(Type type, Action action);
- ParseObject Instantiate(string className, IServiceHub serviceHub);
+ ParseObject Instantiate(string className, IServiceHub serviceHub);
- IDictionary GetPropertyMappings(string className);
+ IDictionary GetPropertyMappings(string className);
- void AddIntrinsic();
- }
+ void AddIntrinsic();
}
diff --git a/Parse/Infrastructure/Data/ParseDataDecoder.cs b/Parse/Infrastructure/Data/ParseDataDecoder.cs
index fa38b49f..9a8f46eb 100644
--- a/Parse/Infrastructure/Data/ParseDataDecoder.cs
+++ b/Parse/Infrastructure/Data/ParseDataDecoder.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Parse.Abstractions.Infrastructure;
@@ -7,42 +8,271 @@
using Parse.Abstractions.Platform.Objects;
using Parse.Infrastructure.Control;
using Parse.Infrastructure.Utilities;
+using Parse.Platform.Objects;
-namespace Parse.Infrastructure.Data
+namespace Parse.Infrastructure.Data;
+
+public class ParseDataDecoder : IParseDataDecoder
{
- public class ParseDataDecoder : IParseDataDecoder
+ // Prevent default constructor.
+
+ IParseObjectClassController ClassController { get; }
+
+ public ParseDataDecoder(IParseObjectClassController classController) => ClassController = classController;
+ private static DateTime? DecodeDateTime(object value)
{
- // Prevent default constructor.
+ try
+ {
+ // Handle cases where the value is already a DateTime
+ if (value is DateTime dateTime)
+ {
+ return dateTime;
+ }
+
+ // Handle string representations of dates
+ if (value is string dateString)
+ {
+ if (DateTime.TryParse(dateString, out var parsedDate))
+ {
+ return parsedDate;
+ }
+ }
+
+ // Handle Unix timestamp (milliseconds since epoch)
+ if (value is long unixTimestamp)
+ {
+ return DateTimeOffset.FromUnixTimeMilliseconds(unixTimestamp).UtcDateTime;
+ }
+
+ // Handle Unix timestamp (seconds since epoch)
+ if (value is int unixTimestampSeconds)
+ {
+ return DateTimeOffset.FromUnixTimeSeconds(unixTimestampSeconds).UtcDateTime;
+ }
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine($"Failed to decode DateTime value: {value}, Error: {ex.Message}");
+ }
+
+ // Return null if decoding fails
+ return null;
+ }
+
+ static string[] Types { get; } = { "Date", "Bytes", "Pointer", "File", "GeoPoint", "Object", "Relation" };
+ public object Decode(object data, IServiceHub serviceHub)
+ {
+ if (data is IDictionary dictionary)
+ {
+ try
+ {
+ var state = new MutableObjectState
+ {
+ ClassName = dictionary.ContainsKey("className") ? dictionary["className"]?.ToString() : null,
+ ObjectId = dictionary.ContainsKey("objectId") ? dictionary["objectId"]?.ToString() : null,
+ CreatedAt = dictionary.ContainsKey("createdAt") ? DecodeDateTime(dictionary["createdAt"]) : null,
+ UpdatedAt = dictionary.ContainsKey("updatedAt") ? DecodeDateTime(dictionary["updatedAt"]) : null,
+ IsNew = dictionary.ContainsKey("isNew") && Convert.ToBoolean(dictionary["isNew"]),
+ EmailVerified = dictionary.ContainsKey("emailVerified") && Convert.ToBoolean(dictionary["emailVerified"]),
+ Username = dictionary.ContainsKey("username") ? dictionary["username"]?.ToString() : null,
+ Email = dictionary.ContainsKey("email") ? dictionary["email"]?.ToString() : null,
+ SessionToken = dictionary.ContainsKey("sessionToken") ? dictionary["sessionToken"]?.ToString() : null,
+ ServerData = dictionary
+ };
+
+ return state;
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine($"Failed to decode MutableObjectState: {ex.Message}");
+ throw; // Let the caller handle decoding errors
+ }
+ }
+ Debug.WriteLine("Data is not a compatible object for decoding. " + data.GetType());
+
+ if (data.GetType() == typeof(string))
+ {
+ Debug.WriteLine($"Data is not a compatible object for decoding. {data.GetType()} {data}");
+ }
+ else if (data.GetType() == typeof(Int64))
+ {
+ Debug.WriteLine($"Data is not a compatible object for decoding. {data.GetType()} Value: {data}");
+ }
+ else
+ {
+ Debug.WriteLine("Data is not a compatible object for decoding. Unknown Type");
+ }
+
+
+ return null;
+ //throw new InvalidCastException("Input data cannot be cast to IObjectState.");
+ }
+
+ //public object Decode(object data, IServiceHub serviceHub)
+ //{
+ // try
+ // {
+ // if (data == null)
+ // {
+ // return default;
+ // }
+
+ // if (data is IDictionary dictionary)
+ // {
+ // // Handle "__op" operations
+ // if (dictionary.ContainsKey("__op"))
+ // {
+ // return ParseFieldOperations.Decode(dictionary);
+ // }
+
+ // // Handle "__type" objects
+ // if (dictionary.TryGetValue("__type", out var type) && Types.Contains(type))
+ // {
+ // return DecodeByType(dictionary, type.ToString(), serviceHub);
+ // }
- IParseObjectClassController ClassController { get; }
+ // // Decode nested dictionary
+ // return dictionary.ToDictionary(pair => pair.Key, pair =>
+ // {
+ // try
+ // {
+ // return Decode(pair.Value, serviceHub);
+ // }
+ // catch
+ // {
+ // // Fallback to the original value if decoding fails
+ // return pair.Value;
+ // }
+ // });
+ // }
- public ParseDataDecoder(IParseObjectClassController classController) => ClassController = classController;
+ // // Handle lists
+ // if (data is IList