Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[improvement] Removed all usage of reflection, enabled trimming on UWP, improved memory usage when compiling .NET Native #184

Merged
merged 27 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
24a2ea7
Removed Android to fix release mode builds
Arlodotexe Jun 30, 2022
24a2c4c
Removed Android to fix release mode builds
Arlodotexe Jun 30, 2022
ad4f33a
Merge branch 'fix/sporadic-ci-release-mode-failures' of ssh://github.…
Arlodotexe Jun 30, 2022
04fca50
WIP enabling trimming
Arlodotexe Jun 30, 2022
80867f1
Switched from Newtonsoft to System.Text.Json
Arlodotexe Jun 30, 2022
3c7e9e9
Added more types for app settings serialization
Arlodotexe Jun 30, 2022
790d8be
Enable 64 bit compiler in release mode
Arlodotexe Jun 30, 2022
528dad9
Merge branch 'master' into fix/sporadic-ci-release-mode-failures
Arlodotexe Jul 8, 2022
200856a
Switched to System.Text.Json + source generators
Arlodotexe Jul 11, 2022
c2d79d6
Merge branch 'fix/sporadic-ci-release-mode-failures' of ssh://github.…
Arlodotexe Jul 11, 2022
451c334
Fixed compilation errors from refactor
Arlodotexe Jul 11, 2022
415aa7a
Exclude all metadata by default
Arlodotexe Jul 11, 2022
ed114e6
Use x64 for PreferredToolArchitecture
Arlodotexe Jul 11, 2022
d2dfb07
Removed "Prefer32Bit" property
Arlodotexe Jul 11, 2022
48ca424
Revert Microsoft.NETCore.UniversalWindowsPlatform to match MSBuild.Sd…
Arlodotexe Jul 11, 2022
1eaf1bb
Updated to .NET 7 preview for Microsoft.CodeAnalysis.NetAnalyzers
Arlodotexe Jul 12, 2022
53b6119
Remove explicit "Excluded" for *Application* runtime directive
Arlodotexe Jul 12, 2022
5dab73c
Remove ShortcutGenericAnalysis
Arlodotexe Jul 12, 2022
c2132c9
Remove potential infinite loop
Arlodotexe Jul 12, 2022
5de98d2
Set the optimizer as single threaded.
Jul 12, 2022
94a3b85
Set the optimizer as single threaded for Release all platforms
Jul 12, 2022
016784e
Refactored and cleaned up UWP csproj
Arlodotexe Jul 13, 2022
e5d0e88
Enabled ShortcutGenericAnalysis in release mode
Arlodotexe Jul 13, 2022
5818a2e
Enable generating PDB out of process and bump .NET Native to 6.2.14
Arlodotexe Jul 13, 2022
200705c
Revert "Enable generating PDB out of process and bump .NET Native to …
Arlodotexe Jul 14, 2022
ffcacf0
Revert "Revert "Enable generating PDB out of process and bump .NET Na…
Arlodotexe Jul 21, 2022
85350fa
Merge branch 'master' into fix/sporadic-ci-release-mode-failures
Arlodotexe Jul 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="6.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/Cores/Files/StrixMusic.Cores.LocalFiles/LocalFilesCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using OwlCore.Extensions;
using StrixMusic.Cores.Files;
using StrixMusic.Cores.Files.Models;
using StrixMusic.Cores.LocalFiles.Services;
using StrixMusic.Cores.LocalFiles.Settings;
using StrixMusic.Sdk.AppModels;
using StrixMusic.Sdk.CoreModels;
using StrixMusic.Sdk.FileMetadata;
Expand Down Expand Up @@ -86,10 +86,10 @@ private void DetachEvents()
/// <summary>
/// The metadata that identifies this core before instantiation.
/// </summary>
public static CoreMetadata Metadata { get; } = new CoreMetadata(id: nameof(LocalFilesCore),
displayName: "Local Files",
logoUri: new Uri("ms-appx:///Assets/Cores/LocalFiles/Logo.svg"),
sdkVer: typeof(ICore).Assembly.GetName().Version);
public static CoreMetadata Metadata { get; } = new CoreMetadata(Id: nameof(LocalFilesCore),
DisplayName: "Local Files",
LogoUri: new Uri("ms-appx:///Assets/Cores/LocalFiles/Logo.svg"),
SdkVer: typeof(ICore).Assembly.GetName().Version);

/// <summary>
/// The settings for this core instance.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OwlCore.AbstractUI.Models;
using StrixMusic.Cores.LocalFiles.Services;
using StrixMusic.Cores.LocalFiles.Settings;

namespace StrixMusic.Cores.LocalFiles
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.IO;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using CommunityToolkit.Diagnostics;
using OwlCore.Services;

namespace StrixMusic.Cores.LocalFiles.Settings
{
/// <summary>
/// An <see cref="IAsyncSerializer{TSerialized}"/> and implementation for serializing and deserializing streams using System.Text.Json.
/// </summary>
public class FilesCoreSettingsSerializer : IAsyncSerializer<Stream>
{
/// <summary>
/// A singleton instance for <see cref="FilesCoreSettingsSerializer"/>.
/// </summary>
public static FilesCoreSettingsSerializer Singleton { get; } = new();

/// <inheritdoc />
public async Task<Stream> SerializeAsync<T>(T data, CancellationToken? cancellationToken = null)
{
var stream = new MemoryStream();
await JsonSerializer.SerializeAsync(stream, data, typeof(T), context: FilesCoreSettingsSerializerContext.Default, cancellationToken: cancellationToken ?? CancellationToken.None);
return stream;
}

/// <inheritdoc />
public async Task<Stream> SerializeAsync(Type inputType, object data, CancellationToken? cancellationToken = null)
{
var stream = new MemoryStream();
await JsonSerializer.SerializeAsync(stream, data, inputType, context: FilesCoreSettingsSerializerContext.Default, cancellationToken: cancellationToken ?? CancellationToken.None);
return stream;
}

/// <inheritdoc />
public async Task<TResult> DeserializeAsync<TResult>(Stream serialized, CancellationToken? cancellationToken = null)
{
var result = await JsonSerializer.DeserializeAsync(serialized, typeof(TResult), FilesCoreSettingsSerializerContext.Default);
Guard.IsNotNull(result);
return (TResult)result;
}

/// <inheritdoc />
public async Task<object> DeserializeAsync(Type returnType, Stream serialized, CancellationToken? cancellationToken = null)
{
var result = await JsonSerializer.DeserializeAsync(serialized, returnType, FilesCoreSettingsSerializerContext.Default);
Guard.IsNotNull(result);
return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Text.Json.Serialization;

namespace StrixMusic.Cores.LocalFiles.Settings
{
/// <summary>
/// Supplies type information for settings values in <see cref="LocalFilesCoreSettings"/>.
/// </summary>
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(bool))]
[JsonSerializable(typeof(string))]
internal partial class FilesCoreSettingsSerializerContext : JsonSerializerContext
{
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using OwlCore.AbstractStorage;
using System.Threading.Tasks;
using System.Threading;
using OwlCore.AbstractStorage;
using OwlCore.Services;
using StrixMusic.Sdk.Services;
using System.Text.Json;

namespace StrixMusic.Cores.LocalFiles.Services
namespace StrixMusic.Cores.LocalFiles.Settings
{
/// <summary>
/// A container for <see cref="LocalFilesCore"/> settings.
Expand All @@ -13,7 +16,7 @@ public sealed class LocalFilesCoreSettings : SettingsBase
/// Creates a new instance of <see cref="LocalFilesCoreSettings"/>.
/// </summary>
public LocalFilesCoreSettings(IFolderData folder)
: base(folder, NewtonsoftStreamSerializer.Singleton)
: base(folder, FilesCoreSettingsSerializer.Singleton)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ItemGroup>
<PackageReference Include="OwlCore" Version="0.0.71" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Cores/Files/StrixMusic.Cores.OneDrive/OneDriveCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public OneDriveCore(string instanceId, OneDriveCoreSettings settings, IFolderDat
/// <summary>
/// The metadata that identifies this core before instantiation.
/// </summary>
public static CoreMetadata Metadata { get; } = new CoreMetadata(id: nameof(OneDriveCore),
displayName: "OneDrive",
logoUri: new Uri("ms-appx:///Assets/Cores/OneDrive/Logo.svg"),
sdkVer: typeof(ICore).Assembly.GetName().Version);
public static CoreMetadata Metadata { get; } = new CoreMetadata(Id: nameof(OneDriveCore),
DisplayName: "OneDrive",
LogoUri: new Uri("ms-appx:///Assets/Cores/OneDrive/Logo.svg"),
SdkVer: typeof(ICore).Assembly.GetName().Version);
/// <inheritdoc/>
public override string InstanceDescriptor { get; set; } = string.Empty;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.IO;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using CommunityToolkit.Diagnostics;
using OwlCore.Services;

namespace StrixMusic.Cores.OneDrive.Services
{
/// <summary>
/// An <see cref="IAsyncSerializer{TSerialized}"/> and implementation for serializing and deserializing streams using System.Text.Json.
/// </summary>
public class FilesCoreSettingsSerializer : IAsyncSerializer<Stream>
{
/// <summary>
/// A singleton instance for <see cref="FilesCoreSettingsSerializer"/>.
/// </summary>
public static FilesCoreSettingsSerializer Singleton { get; } = new();

/// <inheritdoc />
public async Task<Stream> SerializeAsync<T>(T data, CancellationToken? cancellationToken = null)
{
var stream = new MemoryStream();
await JsonSerializer.SerializeAsync(stream, data, typeof(T), context: FilesCoreSettingsSerializerContext.Default, cancellationToken: cancellationToken ?? CancellationToken.None);
return stream;
}

/// <inheritdoc />
public async Task<Stream> SerializeAsync(Type inputType, object data, CancellationToken? cancellationToken = null)
{
var stream = new MemoryStream();
await JsonSerializer.SerializeAsync(stream, data, inputType, context: FilesCoreSettingsSerializerContext.Default, cancellationToken: cancellationToken ?? CancellationToken.None);
return stream;
}

/// <inheritdoc />
public async Task<TResult> DeserializeAsync<TResult>(Stream serialized, CancellationToken? cancellationToken = null)
{
var result = await JsonSerializer.DeserializeAsync(serialized, typeof(TResult), FilesCoreSettingsSerializerContext.Default);
Guard.IsNotNull(result);
return (TResult)result;
}

/// <inheritdoc />
public async Task<object> DeserializeAsync(Type returnType, Stream serialized, CancellationToken? cancellationToken = null)
{
var result = await JsonSerializer.DeserializeAsync(serialized, returnType, FilesCoreSettingsSerializerContext.Default);
Guard.IsNotNull(result);
return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Text.Json.Serialization;

namespace StrixMusic.Cores.OneDrive.Services
{
/// <summary>
/// Supplies type information for settings values in <see cref="LocalFilesCoreSettings"/>.
/// </summary>
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(bool))]
[JsonSerializable(typeof(string))]
internal partial class FilesCoreSettingsSerializerContext : JsonSerializerContext
{
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using OwlCore.AbstractStorage;
using System.Threading.Tasks;
using System.Threading;
using OwlCore.AbstractStorage;
using OwlCore.Services;
using StrixMusic.Sdk.Services;
using System.Text.Json;

namespace StrixMusic.Cores.OneDrive.Services
{
Expand All @@ -13,7 +15,7 @@ public sealed class OneDriveCoreSettings : SettingsBase
/// Creates a new instance of <see cref="OneDriveCoreSettings"/>.
/// </summary>
public OneDriveCoreSettings(IFolderData folder)
: base(folder, NewtonsoftStreamSerializer.Singleton)
: base(folder, FilesCoreSettingsSerializer.Singleton)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageReference Include="Microsoft.Graph" Version="4.14.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.40.0" />
<PackageReference Include="OwlCore" Version="0.0.71" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public async Task InitAsync(CancellationToken cancellationToken = default)

public event EventHandler<string>? InstanceDescriptorChanged;

public CoreMetadata Registration { get; } = new CoreMetadata(id: nameof(MockCore),
displayName: "Mock core",
logoUri: new Uri("https://strixmusic.com/"),
sdkVer: typeof(ICore).Assembly.GetName().Version ?? throw new ArgumentNullException());
public CoreMetadata Registration { get; } = new CoreMetadata(Id: nameof(MockCore),
DisplayName: "Mock core",
LogoUri: new Uri("https://strixmusic.com/"),
SdkVer: typeof(ICore).Assembly.GetName().Version ?? throw new ArgumentNullException());

public string InstanceId { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="OwlCore" Version="0.0.71" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="OwlCore" Version="0.0.71" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/Libs/OwlCore.WinUI/OwlCore.WinUI.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;monoandroid11.0;uap10.0.19041</TargetFrameworks>
<!--<TargetFrameworks>netstandard2.0;uap10.0.19041</TargetFrameworks>-->
<TargetFrameworks>netstandard2.0;uap10.0.19041</TargetFrameworks>
<!-- Ensures the .xr.xml files are generated in a proper layout folder -->
<GenerateLibraryLayout>true</GenerateLibraryLayout>
<Nullable>enable</Nullable>
Expand All @@ -22,6 +23,7 @@
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls" Version="7.1.2" />
<PackageReference Include="OwlCore" Version="0.0.71" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />
<PackageReference Include="Uno.UI" Version="4.4.5" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'uap10.0.19041'">
Expand Down
19 changes: 0 additions & 19 deletions src/Platforms/StrixMusic.Droid/Assets/AboutAssets.txt

This file was deleted.

Binary file not shown.
41 changes: 0 additions & 41 deletions src/Platforms/StrixMusic.Droid/Main.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Platforms/StrixMusic.Droid/MainActivity.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/Platforms/StrixMusic.Droid/Properties/AndroidManifest.xml

This file was deleted.

Loading