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

Commit 8569b4a

Browse files
authored
Merge pull request #580 from UWPCommunity/rewrite/main
Merge
2 parents b1ecb67 + 42cbbb2 commit 8569b4a

File tree

10 files changed

+229
-88
lines changed

10 files changed

+229
-88
lines changed

Quarrel.sln

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.RichPresence", "src
3636
EndProject
3737
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.Samples.RichPresence", "samples\Quarrel.Samples.RichPresence\Quarrel.Samples.RichPresence.csproj", "{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}"
3838
EndProject
39+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{E3BFEBEE-5570-4885-B4C7-2CB3E7B04C60}"
40+
EndProject
41+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.Testing.DirtyServices", "tests\Quarrel.Testing.DirtyServices\Quarrel.Testing.DirtyServices.csproj", "{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}"
42+
EndProject
3943
Global
4044
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4145
Alpha|Any CPU = Alpha|Any CPU
@@ -444,6 +448,46 @@ Global
444448
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}.Release|ARM64.ActiveCfg = Debug|ARM64
445449
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}.Release|x64.ActiveCfg = Debug|x64
446450
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE}.Release|x86.ActiveCfg = Debug|x86
451+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|Any CPU.ActiveCfg = Debug|Any CPU
452+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|Any CPU.Build.0 = Debug|Any CPU
453+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM.ActiveCfg = Debug|Any CPU
454+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM.Build.0 = Debug|Any CPU
455+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM64.ActiveCfg = Debug|Any CPU
456+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|ARM64.Build.0 = Debug|Any CPU
457+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x64.ActiveCfg = Debug|Any CPU
458+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x64.Build.0 = Debug|Any CPU
459+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x86.ActiveCfg = Debug|Any CPU
460+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Alpha|x86.Build.0 = Debug|Any CPU
461+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
462+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
463+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM.ActiveCfg = Debug|Any CPU
464+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM.Build.0 = Debug|Any CPU
465+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM64.ActiveCfg = Debug|Any CPU
466+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|ARM64.Build.0 = Debug|Any CPU
467+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x64.ActiveCfg = Debug|Any CPU
468+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x64.Build.0 = Debug|Any CPU
469+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x86.ActiveCfg = Debug|Any CPU
470+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Debug|x86.Build.0 = Debug|Any CPU
471+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|Any CPU.ActiveCfg = Insider|Any CPU
472+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|Any CPU.Build.0 = Insider|Any CPU
473+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM.ActiveCfg = Insider|Any CPU
474+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM.Build.0 = Insider|Any CPU
475+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM64.ActiveCfg = Insider|Any CPU
476+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|ARM64.Build.0 = Insider|Any CPU
477+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x64.ActiveCfg = Insider|Any CPU
478+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x64.Build.0 = Insider|Any CPU
479+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x86.ActiveCfg = Insider|Any CPU
480+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Insider|x86.Build.0 = Insider|Any CPU
481+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
482+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|Any CPU.Build.0 = Release|Any CPU
483+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM.ActiveCfg = Release|Any CPU
484+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM.Build.0 = Release|Any CPU
485+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM64.ActiveCfg = Release|Any CPU
486+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|ARM64.Build.0 = Release|Any CPU
487+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x64.ActiveCfg = Release|Any CPU
488+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x64.Build.0 = Release|Any CPU
489+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x86.ActiveCfg = Release|Any CPU
490+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x86.Build.0 = Release|Any CPU
447491
EndGlobalSection
448492
GlobalSection(SolutionProperties) = preSolution
449493
HideSolutionNode = FALSE
@@ -456,6 +500,7 @@ Global
456500
{7B631D3A-F353-4557-B848-A68140341F53} = {29E0E840-B85F-4209-933B-8369DB2EA187}
457501
{BA8BE893-2B4D-4213-A4AF-53AA28BF2E46} = {7B631D3A-F353-4557-B848-A68140341F53}
458502
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE} = {7B631D3A-F353-4557-B848-A68140341F53}
503+
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2} = {E3BFEBEE-5570-4885-B4C7-2CB3E7B04C60}
459504
EndGlobalSection
460505
GlobalSection(ExtensibilityGlobals) = postSolution
461506
SolutionGuid = {2B4323A3-5C28-4929-AB1C-20CE992D6024}

azure-pipelines-package-alpha.yml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pool:
2222

2323
variables:
2424
solution: '**/Quarrel.App.sln'
25-
buildPlatform: 'x86|x64|arm|arm64'
25+
buildPlatform: 'x86|x64|arm'
2626
buildConfiguration: 'Alpha'
2727
installerDirectory: './QuarrelInstaller'
2828
appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'
@@ -53,7 +53,7 @@ steps:
5353
displayName: Place AppCenterToken
5454
inputs:
5555
targetType: 'inline'
56-
script: 'Copy-Item $Env:APP_CENTER_TOKEN_PATH -Destination "$($Env:BUILD_SOURCESDIRECTORY)/src/Quarrel/Assets/Tokens/AppCenter/"'
56+
script: 'Copy-Item $Env:APP_CENTER_TOKEN_PATH -Destination "$($Env:BUILD_SOURCESDIRECTORY)/Quarrel/src/Quarrel/Assets/Tokens/AppCenter/"'
5757
env:
5858
APP_CENTER_TOKEN_PATH: $(appCenterToken.secureFilePath)
5959

@@ -80,29 +80,28 @@ steps:
8080
/p:PackageCertificateKeyFile="$(signingCertificate.secureFilePath)"
8181
/p:PackageCertificateThumbprint="$(SignedCertificateThumbprint-Alpha)"
8282
/p:PackageCertificatePassword="$(SignCertificatePassword-Alpha)"
83-
/p:AppInstallerUri="${siteUri}"
83+
/p:AppInstallerUri="$(siteUri)"
8484
/p:AppInstallerUpdateFrequency=1
85-
/p:AppInstallerCheckForUpdateFrequency=OnApplicationRun'
85+
/p:AppInstallerCheckForUpdateFrequency=OnApplicationRun
86+
/p:GenerateAppInstallerFile=true'
8687

8788
- powershell: |
8889
[Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")
8990
$doc = [System.Xml.Linq.XDocument]::Load(
9091
"$(appxPackageDir)/Quarrel.appinstaller")
91-
$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}MainBundle"
92-
$bundle = $doc.Root.Element($xName).Attribute("Uri").Value.Replace("${siteUri}", "");
93-
Copy-Item $bundle -Destination ($(build.artifactStagingDirectory) + $bundle.Replace("/", "_"));
92+
$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}MainBundle";
93+
$bundle = $doc.Root.Element($xName).Attribute("Uri").Value.Replace("$(siteUri)", "");
94+
95+
Copy-Item "$(appxPackageDir)\$($bundle)" -Destination "$(build.artifactStagingDirectory)\$($bundle.Replace("/", "_"))";
9496
$doc.Root.Element($xName).Attribute("Uri").Value =
95-
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/Quarrel.appinstaller" +
96-
$bundle.Replace("/", "_");
97+
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/$($bundle.Replace("/", "_"))";
9798
98-
$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}Dependencies"
99-
100-
foreach ($element in $doc.Root.Elements($xName)){
101-
$dep = $element.Attribute("Uri").Value.Replace("${siteUri}", "");
102-
Copy-Item $dep -Destination ($(build.artifactStagingDirectory) + $dep.Replace("/", "_"));
99+
$xName = "{http://schemas.microsoft.com/appx/appinstaller/2017/2}Dependencies";
100+
foreach ($element in $doc.Root.Element($xName).Elements()){
101+
$dep = $element.Attribute("Uri").Value.Replace("$(siteUri)", "");
102+
Copy-Item "$(appxPackageDir)\$($dep)" -Destination "$(build.artifactStagingDirectory)\$($dep.Replace("/", "_"))";
103103
$element.Attribute("Uri").Value =
104-
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/Quarrel.appinstaller" +
105-
$dep.Replace("/", "_");
104+
"https://github.com/UWPCommunity/Quarrel/releases/download/alpha-v$(Build.BuildNumber)/$($dep.Replace("/", "_"))";
106105
}
107106
$doc.Save("$(appInstaller)")
108107
displayName: 'Fix appinstaller'
@@ -121,14 +120,8 @@ steps:
121120
changeLogCompareToRelease: 'lastFullRelease'
122121
changeLogType: 'commitBased'
123122
assets: |
124-
'$(build.artifactStagingDirectory)/*'
125-
126-
- task: CopyFiles@2
127-
displayName: Copy artifacts to QuarrelInstaller repo
128-
inputs:
129-
SourceFolder: '$(build.artifactStagingDirectory)'
130-
Contents: '**'
131-
TargetFolder: '$(installerDirectory)'
123+
$(build.artifactStagingDirectory)\*.msixbundle
124+
$(build.artifactStagingDirectory)\*.appx
132125
133126
- script: |
134127
git config --global user.email $(GitHub-Email)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Quarrel © 2022
2+
3+
namespace Microsoft.Extensions.DependencyInjection
4+
{
5+
/// <summary>
6+
/// A class containing extensions for the <see cref="ServiceCollection"/> class.
7+
/// </summary>
8+
public static class ServiceCollectionExtensions
9+
{
10+
/// <summary>
11+
/// Replaces the service a singleton service in the <see cref="ServiceCollection"/>.
12+
/// </summary>
13+
public static void OverrideSingleton<TService, TOldImpl, TNewImpl>(this ServiceCollection services)
14+
where TService : class
15+
where TOldImpl : class, TService
16+
where TNewImpl : class, TService
17+
{
18+
var oldDesc = ServiceDescriptor.Singleton<TService, TOldImpl>();
19+
services.Remove(oldDesc);
20+
services.AddSingleton<TService, TNewImpl>();
21+
}
22+
}
23+
}

src/Quarrel.ViewModels/Services/APIs/GitHubService/GitHubService.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,19 @@ public GitHubService(IAnalyticsService analyticsService)
6464

6565
return result;
6666
}
67-
67+
6868
/// <inheritdoc/>
69-
public async Task<BindableDeveloper> GetDeveloper(Contributor contributor)
69+
public async Task<BindableDeveloper?> GetDeveloper(Contributor contributor)
7070
{
71-
var user = await _gitHubApiService.GetUserAsync(contributor.Name);
72-
return new BindableDeveloper(user, contributor);
71+
try
72+
{
73+
var user = await _gitHubApiService.GetUserAsync(contributor.Name);
74+
return new BindableDeveloper(user, contributor);
75+
}
76+
catch
77+
{
78+
return null;
79+
}
7380
}
7481
}
7582
}

src/Quarrel.ViewModels/Services/APIs/GitHubService/IGitHubService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public interface IGitHubService
2222
/// </summary>
2323
/// <param name="contributor">The contributor to get the a full profile for.</param>
2424
/// <returns></returns>
25-
Task<BindableDeveloper> GetDeveloper(Contributor contributor);
25+
Task<BindableDeveloper?> GetDeveloper(Contributor contributor);
2626
}
2727
}

src/Quarrel/App.Services.cs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Quarrel © 2022
2+
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Toolkit.Mvvm.Messaging;
5+
using OwlCore.AbstractStorage;
6+
using Quarrel.Services.Analytics;
7+
using Quarrel.Services.APIs.GitHubService;
8+
using Quarrel.Services.Discord;
9+
using Quarrel.Services.Dispatcher;
10+
using Quarrel.Services.Localization;
11+
using Quarrel.Services.Storage;
12+
using Quarrel.Services.Storage.Models;
13+
using Quarrel.Services.Versioning;
14+
using Quarrel.Services.Windows;
15+
using Quarrel.ViewModels;
16+
using Quarrel.ViewModels.Panels;
17+
using Quarrel.ViewModels.SubPages;
18+
using Quarrel.ViewModels.SubPages.DiscordStatus;
19+
using Quarrel.ViewModels.SubPages.Host;
20+
using Quarrel.ViewModels.SubPages.Meta;
21+
using System;
22+
using Windows.Storage;
23+
24+
namespace Quarrel
25+
{
26+
partial class App
27+
{
28+
private IServiceProvider ConfigureServices()
29+
{
30+
IFolderData appDataFolder = new FolderData(ApplicationData.Current.LocalFolder);
31+
32+
// Register Services
33+
var services = new ServiceCollection();
34+
services.AddSingleton<IMessenger, WeakReferenceMessenger>();
35+
services.AddSingleton<ILocalizationService, LocalizationService>();
36+
services.AddSingleton<IVersioningService, VersioningService>();
37+
services.AddSingleton<IDiscordService, DiscordService>();
38+
services.AddSingleton<IDispatcherService, DispatcherService>();
39+
services.AddSingleton<IStorageService>(new StorageService(appDataFolder, JsonAsyncSerializer.Singleton));
40+
services.AddSingleton<IWindowService, WindowService>();
41+
42+
// Other APIs
43+
services.AddTransient<IGitHubService, GitHubService>();
44+
45+
#if DEV
46+
services.AddSingleton<IAnalyticsService, LoggingAnalyticsService>();
47+
#else
48+
services.AddSingleton<IAnalyticsService, AppCenterService>();
49+
#endif
50+
51+
// ViewModels
52+
services.AddSingleton<WindowViewModel>();
53+
services.AddSingleton<SubPageHostViewModel>();
54+
services.AddTransient<LoginPageViewModel>();
55+
services.AddSingleton<GuildsViewModel>();
56+
services.AddSingleton<ChannelsViewModel>();
57+
services.AddSingleton<MessagesViewModel>();
58+
services.AddSingleton<CurrentUserViewModel>();
59+
60+
// SubPages
61+
services.AddTransient<AboutPageViewModel>();
62+
services.AddTransient<CreditPageViewModel>();
63+
services.AddTransient<DiscordStatusViewModel>();
64+
65+
#if DEV
66+
ApplyDitryOverrides(services);
67+
#endif
68+
69+
return services.BuildServiceProvider();
70+
}
71+
72+
#if DEV
73+
private void ApplyDitryOverrides(ServiceCollection services)
74+
{
75+
// Fill with dirty service overrides for stress testing.
76+
}
77+
#endif
78+
}
79+
}

src/Quarrel/App.xaml.cs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,13 @@
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Toolkit.Mvvm.DependencyInjection;
55
using Microsoft.Toolkit.Mvvm.Messaging;
6-
using OwlCore.AbstractStorage;
76
using Quarrel.Controls.Host;
87
using Quarrel.Helpers.LaunchArgs.Models;
98
using Quarrel.Messages;
10-
using Quarrel.Services.Analytics;
11-
using Quarrel.Services.APIs.GitHubService;
12-
using Quarrel.Services.Discord;
13-
using Quarrel.Services.Dispatcher;
149
using Quarrel.Services.Localization;
15-
using Quarrel.Services.Storage;
16-
using Quarrel.Services.Storage.Models;
17-
using Quarrel.Services.Versioning;
18-
using Quarrel.Services.Windows;
19-
using Quarrel.ViewModels;
20-
using Quarrel.ViewModels.Panels;
21-
using Quarrel.ViewModels.SubPages;
22-
using Quarrel.ViewModels.SubPages.DiscordStatus;
23-
using Quarrel.ViewModels.SubPages.Host;
24-
using Quarrel.ViewModels.SubPages.Meta;
2510
using System;
2611
using Windows.ApplicationModel.Activation;
2712
using Windows.ApplicationModel.AppService;
28-
using Windows.Storage;
2913
using Windows.UI.Xaml;
3014

3115
namespace Quarrel
@@ -122,45 +106,5 @@ private void InitializeUI()
122106
ILocalizationService localizationService = Services.GetRequiredService<ILocalizationService>();
123107
root.FlowDirection = localizationService.IsRightToLeftLanguage ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
124108
}
125-
126-
private IServiceProvider ConfigureServices()
127-
{
128-
IFolderData appDataFolder = new FolderData(ApplicationData.Current.LocalFolder);
129-
130-
// Register Services
131-
var services = new ServiceCollection();
132-
services.AddSingleton<IMessenger, WeakReferenceMessenger>();
133-
services.AddSingleton<ILocalizationService, LocalizationService>();
134-
services.AddSingleton<IVersioningService, VersioningService>();
135-
services.AddSingleton<IDiscordService, DiscordService>();
136-
services.AddSingleton<IDispatcherService, DispatcherService>();
137-
services.AddSingleton<IStorageService>(new StorageService(appDataFolder, JsonAsyncSerializer.Singleton));
138-
services.AddSingleton<IWindowService, WindowService>();
139-
140-
// Other APIs
141-
services.AddTransient<IGitHubService, GitHubService>();
142-
143-
#if DEV
144-
services.AddSingleton<IAnalyticsService, LoggingAnalyticsService>();
145-
#else
146-
services.AddSingleton<IAnalyticsService, AppCenterService>();
147-
#endif
148-
149-
// ViewModels
150-
services.AddSingleton<WindowViewModel>();
151-
services.AddSingleton<SubPageHostViewModel>();
152-
services.AddTransient<LoginPageViewModel>();
153-
services.AddSingleton<GuildsViewModel>();
154-
services.AddSingleton<ChannelsViewModel>();
155-
services.AddSingleton<MessagesViewModel>();
156-
services.AddSingleton<CurrentUserViewModel>();
157-
158-
// SubPages
159-
services.AddTransient<AboutPageViewModel>();
160-
services.AddTransient<CreditPageViewModel>();
161-
services.AddTransient<DiscordStatusViewModel>();
162-
163-
return services.BuildServiceProvider();
164-
}
165109
}
166110
}

0 commit comments

Comments
 (0)