Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Merge #580

Merged
merged 24 commits into from
Apr 21, 2022
Merged

Merge #580

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4eda643
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
02d26ff
Update Quarrel.csproj
matthew4850 Apr 21, 2022
ebef526
Update Quarrel.csproj
matthew4850 Apr 21, 2022
854b8b3
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
dc2329f
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
0b4b2bf
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
1e6a41f
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
95ce9d9
Added DirtyService overrides
Avid29 Apr 21, 2022
27e255b
Merge branch 'rewrite/main' of https://github.com/UWPCommunity/Quarre…
Avid29 Apr 21, 2022
9c3bf0a
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
39444d4
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
8620625
Isolated ApplyDiretyOverrides to Debug config
Avid29 Apr 21, 2022
6a098fe
Merge branch 'rewrite/main' of https://github.com/UWPCommunity/Quarre…
Avid29 Apr 21, 2022
85a7ef7
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
7475a09
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
801cd50
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
792b34c
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
6939509
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
fc715b8
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
fdd6b72
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
71329ae
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
f2f4057
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
3a5d33e
Update azure-pipelines-package-alpha.yml for Azure Pipelines
matthew4850 Apr 21, 2022
42cbbb2
Update Quarrel.csproj
matthew4850 Apr 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
45 changes: 45 additions & 0 deletions Quarrel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.RichPresence", "src
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.Samples.RichPresence", "samples\Quarrel.Samples.RichPresence\Quarrel.Samples.RichPresence.csproj", "{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{E3BFEBEE-5570-4885-B4C7-2CB3E7B04C60}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.Testing.DirtyServices", "tests\Quarrel.Testing.DirtyServices\Quarrel.Testing.DirtyServices.csproj", "{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Alpha|Any CPU = Alpha|Any CPU
Expand Down Expand Up @@ -444,6 +448,46 @@ Global
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}.Release|ARM64.ActiveCfg = Debug|ARM64
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}.Release|x64.ActiveCfg = Debug|x64
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}.Release|x86.ActiveCfg = Debug|x86
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|Any CPU.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|Any CPU.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM64.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM64.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x64.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x64.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x86.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x86.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM64.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x64.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x64.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x86.ActiveCfg = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x86.Build.0 = Debug|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|Any CPU.ActiveCfg = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|Any CPU.Build.0 = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM.ActiveCfg = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM.Build.0 = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM64.ActiveCfg = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM64.Build.0 = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x64.ActiveCfg = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x64.Build.0 = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x86.ActiveCfg = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x86.Build.0 = Insider|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|Any CPU.Build.0 = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM.ActiveCfg = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM.Build.0 = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM64.ActiveCfg = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM64.Build.0 = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x64.ActiveCfg = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x64.Build.0 = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x86.ActiveCfg = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -456,6 +500,7 @@ Global
{7B631D3A-F353-4557-B848-A68140341F53} = {29E0E840-B85F-4209-933B-8369DB2EA187}
{BA8BE893-2B4D-4213-A4AF-53AA28BF2E46} = {7B631D3A-F353-4557-B848-A68140341F53}
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE} = {7B631D3A-F353-4557-B848-A68140341F53}
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2} = {E3BFEBEE-5570-4885-B4C7-2CB3E7B04C60}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2B4323A3-5C28-4929-AB1C-20CE992D6024}
Expand Down
41 changes: 17 additions & 24 deletions azure-pipelines-package-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pool:

variables:
solution: '**/Quarrel.App.sln'
buildPlatform: 'x86|x64|arm|arm64'
buildPlatform: 'x86|x64|arm'
buildConfiguration: 'Alpha'
installerDirectory: './QuarrelInstaller'
appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'
Expand Down Expand Up @@ -53,7 +53,7 @@ steps:
displayName: Place AppCenterToken
inputs:
targetType: 'inline'
script: 'Copy-Item $Env:APP_CENTER_TOKEN_PATH -Destination "$($Env:BUILD_SOURCESDIRECTORY)/src/Quarrel/Assets/Tokens/AppCenter/"'
script: 'Copy-Item $Env:APP_CENTER_TOKEN_PATH -Destination "$($Env:BUILD_SOURCESDIRECTORY)/Quarrel/src/Quarrel/Assets/Tokens/AppCenter/"'
env:
APP_CENTER_TOKEN_PATH: $(appCenterToken.secureFilePath)

Expand All @@ -80,29 +80,28 @@ steps:
/p:PackageCertificateKeyFile="$(signingCertificate.secureFilePath)"
/p:PackageCertificateThumbprint="$(SignedCertificateThumbprint-Alpha)"
/p:PackageCertificatePassword="$(SignCertificatePassword-Alpha)"
/p:AppInstallerUri="${siteUri}"
/p:AppInstallerUri="$(siteUri)"
/p:AppInstallerUpdateFrequency=1
/p:AppInstallerCheckForUpdateFrequency=OnApplicationRun'
/p:AppInstallerCheckForUpdateFrequency=OnApplicationRun
/p:GenerateAppInstallerFile=true'

- powershell: |
[Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")
$doc = [System.Xml.Linq.XDocument]::Load(
"$(appxPackageDir)/Quarrel.appinstaller")
$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}MainBundle"
$bundle = $doc.Root.Element($xName).Attribute("Uri").Value.Replace("${siteUri}", "");
Copy-Item $bundle -Destination ($(build.artifactStagingDirectory) + $bundle.Replace("/", "_"));
$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}MainBundle";
$bundle = $doc.Root.Element($xName).Attribute("Uri").Value.Replace("$(siteUri)", "");

Copy-Item "$(appxPackageDir)\$($bundle)" -Destination "$(build.artifactStagingDirectory)\$($bundle.Replace("/", "_"))";
$doc.Root.Element($xName).Attribute("Uri").Value =
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/Quarrel.appinstaller" +
$bundle.Replace("/", "_");
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/$($bundle.Replace("/", "_"))";

$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}Dependencies"

foreach ($element in $doc.Root.Elements($xName)){
$dep = $element.Attribute("Uri").Value.Replace("${siteUri}", "");
Copy-Item $dep -Destination ($(build.artifactStagingDirectory) + $dep.Replace("/", "_"));
$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}Dependencies";
foreach ($element in $doc.Root.Element($xName).Elements()){
$dep = $element.Attribute("Uri").Value.Replace("$(siteUri)", "");
Copy-Item "$(appxPackageDir)\$($dep)" -Destination "$(build.artifactStagingDirectory)\$($dep.Replace("/", "_"))";
$element.Attribute("Uri").Value =
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/Quarrel.appinstaller" +
$dep.Replace("/", "_");
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/$($dep.Replace("/", "_"))";
}
$doc.Save("$(appInstaller)")
displayName: 'Fix appinstaller'
Expand All @@ -121,14 +120,8 @@ steps:
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
assets: |
'$(build.artifactStagingDirectory)/*'

- task: CopyFiles@2
displayName: Copy artifacts to QuarrelInstaller repo
inputs:
SourceFolder: '$(build.artifactStagingDirectory)'
Contents: '**'
TargetFolder: '$(installerDirectory)'
$(build.artifactStagingDirectory)\*.msixbundle
$(build.artifactStagingDirectory)\*.appx

- script: |
git config --global user.email $(GitHub-Email)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Quarrel © 2022

namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// A class containing extensions for the <see cref="ServiceCollection"/> class.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Replaces the service a singleton service in the <see cref="ServiceCollection"/>.
/// </summary>
public static void OverrideSingleton<TService, TOldImpl, TNewImpl>(this ServiceCollection services)
where TService : class
where TOldImpl : class, TService
where TNewImpl : class, TService
{
var oldDesc = ServiceDescriptor.Singleton<TService, TOldImpl>();
services.Remove(oldDesc);
services.AddSingleton<TService, TNewImpl>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ public GitHubService(IAnalyticsService analyticsService)

return result;
}

/// <inheritdoc/>
public async Task<BindableDeveloper> GetDeveloper(Contributor contributor)
public async Task<BindableDeveloper?> GetDeveloper(Contributor contributor)
{
var user = await _gitHubApiService.GetUserAsync(contributor.Name);
return new BindableDeveloper(user, contributor);
try
{
var user = await _gitHubApiService.GetUserAsync(contributor.Name);
return new BindableDeveloper(user, contributor);
}
catch
{
return null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public interface IGitHubService
/// </summary>
/// <param name="contributor">The contributor to get the a full profile for.</param>
/// <returns></returns>
Task<BindableDeveloper> GetDeveloper(Contributor contributor);
Task<BindableDeveloper?> GetDeveloper(Contributor contributor);
}
}
79 changes: 79 additions & 0 deletions src/Quarrel/App.Services.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Quarrel © 2022

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Toolkit.Mvvm.Messaging;
using OwlCore.AbstractStorage;
using Quarrel.Services.Analytics;
using Quarrel.Services.APIs.GitHubService;
using Quarrel.Services.Discord;
using Quarrel.Services.Dispatcher;
using Quarrel.Services.Localization;
using Quarrel.Services.Storage;
using Quarrel.Services.Storage.Models;
using Quarrel.Services.Versioning;
using Quarrel.Services.Windows;
using Quarrel.ViewModels;
using Quarrel.ViewModels.Panels;
using Quarrel.ViewModels.SubPages;
using Quarrel.ViewModels.SubPages.DiscordStatus;
using Quarrel.ViewModels.SubPages.Host;
using Quarrel.ViewModels.SubPages.Meta;
using System;
using Windows.Storage;

namespace Quarrel
{
partial class App
{
private IServiceProvider ConfigureServices()
{
IFolderData appDataFolder = new FolderData(ApplicationData.Current.LocalFolder);

// Register Services
var services = new ServiceCollection();
services.AddSingleton<IMessenger, WeakReferenceMessenger>();
services.AddSingleton<ILocalizationService, LocalizationService>();
services.AddSingleton<IVersioningService, VersioningService>();
services.AddSingleton<IDiscordService, DiscordService>();
services.AddSingleton<IDispatcherService, DispatcherService>();
services.AddSingleton<IStorageService>(new StorageService(appDataFolder, JsonAsyncSerializer.Singleton));
services.AddSingleton<IWindowService, WindowService>();

// Other APIs
services.AddTransient<IGitHubService, GitHubService>();

#if DEV
services.AddSingleton<IAnalyticsService, LoggingAnalyticsService>();
#else
services.AddSingleton<IAnalyticsService, AppCenterService>();
#endif

// ViewModels
services.AddSingleton<WindowViewModel>();
services.AddSingleton<SubPageHostViewModel>();
services.AddTransient<LoginPageViewModel>();
services.AddSingleton<GuildsViewModel>();
services.AddSingleton<ChannelsViewModel>();
services.AddSingleton<MessagesViewModel>();
services.AddSingleton<CurrentUserViewModel>();

// SubPages
services.AddTransient<AboutPageViewModel>();
services.AddTransient<CreditPageViewModel>();
services.AddTransient<DiscordStatusViewModel>();

#if DEV
ApplyDitryOverrides(services);
#endif

return services.BuildServiceProvider();
}

#if DEV
private void ApplyDitryOverrides(ServiceCollection services)
{
// Fill with dirty service overrides for stress testing.
}
#endif
}
}
56 changes: 0 additions & 56 deletions src/Quarrel/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,13 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Toolkit.Mvvm.DependencyInjection;
using Microsoft.Toolkit.Mvvm.Messaging;
using OwlCore.AbstractStorage;
using Quarrel.Controls.Host;
using Quarrel.Helpers.LaunchArgs.Models;
using Quarrel.Messages;
using Quarrel.Services.Analytics;
using Quarrel.Services.APIs.GitHubService;
using Quarrel.Services.Discord;
using Quarrel.Services.Dispatcher;
using Quarrel.Services.Localization;
using Quarrel.Services.Storage;
using Quarrel.Services.Storage.Models;
using Quarrel.Services.Versioning;
using Quarrel.Services.Windows;
using Quarrel.ViewModels;
using Quarrel.ViewModels.Panels;
using Quarrel.ViewModels.SubPages;
using Quarrel.ViewModels.SubPages.DiscordStatus;
using Quarrel.ViewModels.SubPages.Host;
using Quarrel.ViewModels.SubPages.Meta;
using System;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.AppService;
using Windows.Storage;
using Windows.UI.Xaml;

namespace Quarrel
Expand Down Expand Up @@ -122,45 +106,5 @@ private void InitializeUI()
ILocalizationService localizationService = Services.GetRequiredService<ILocalizationService>();
root.FlowDirection = localizationService.IsRightToLeftLanguage ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
}

private IServiceProvider ConfigureServices()
{
IFolderData appDataFolder = new FolderData(ApplicationData.Current.LocalFolder);

// Register Services
var services = new ServiceCollection();
services.AddSingleton<IMessenger, WeakReferenceMessenger>();
services.AddSingleton<ILocalizationService, LocalizationService>();
services.AddSingleton<IVersioningService, VersioningService>();
services.AddSingleton<IDiscordService, DiscordService>();
services.AddSingleton<IDispatcherService, DispatcherService>();
services.AddSingleton<IStorageService>(new StorageService(appDataFolder, JsonAsyncSerializer.Singleton));
services.AddSingleton<IWindowService, WindowService>();

// Other APIs
services.AddTransient<IGitHubService, GitHubService>();

#if DEV
services.AddSingleton<IAnalyticsService, LoggingAnalyticsService>();
#else
services.AddSingleton<IAnalyticsService, AppCenterService>();
#endif

// ViewModels
services.AddSingleton<WindowViewModel>();
services.AddSingleton<SubPageHostViewModel>();
services.AddTransient<LoginPageViewModel>();
services.AddSingleton<GuildsViewModel>();
services.AddSingleton<ChannelsViewModel>();
services.AddSingleton<MessagesViewModel>();
services.AddSingleton<CurrentUserViewModel>();

// SubPages
services.AddTransient<AboutPageViewModel>();
services.AddTransient<CreditPageViewModel>();
services.AddTransient<DiscordStatusViewModel>();

return services.BuildServiceProvider();
}
}
}
Loading