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

Remove reflection from UWP sample startup path #456

Merged
merged 1 commit into from
Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 22 additions & 2 deletions build/CreateBlankAppCenterToken.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@ if(!(Test-Path -Path $TOKENS_FOLDER_RELATIVE_PATH)) {
$TOKENS_FOLDER_PATH = Resolve-Path -Path $TOKENS_FOLDER_RELATIVE_PATH

# AppCenter tokens
$APPCENTER_TOKENS_NAME = "AppCenter.txt"
$APPCENTER_TOKENS_NAME = "App.AppCenter.cs"
$APPCENTER_TOKENS_PATH = Join-Path -Path $TOKENS_FOLDER_PATH -ChildPath $APPCENTER_TOKENS_NAME
if (!(Test-Path -Path $APPCENTER_TOKENS_PATH))
{
echo "<APP_CENTER_SECRET>" > $APPCENTER_TOKENS_PATH
# Prepare the generated source
$APP_APPCENTER_TEXT =
@"
// <auto-generated/>
#pragma warning disable
#nullable enable

namespace ComputeSharp.SwapChain.Uwp;

/// <inheritdoc/>
partial class App
{
/// <summary>
/// The secret token for the AppService connection.
/// </summary>
private const string AppServiceSecret = "";
}
"@.Trim()

# Output the source to the target file
Add-Content $APP_APPCENTER_TEXT -Path $APPCENTER_TOKENS_PATH -NoNewline
}
8 changes: 2 additions & 6 deletions samples/ComputeSharp.SwapChain.Uwp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#if !DEBUG
using System;
using System.Diagnostics;
using System.Reflection;
#endif
using CommunityToolkit.Mvvm.DependencyInjection;
using ComputeSharp.SwapChain.Core.Services;
using ComputeSharp.SwapChain.Core.ViewModels;
#if !DEBUG
using ComputeSharp.SwapChain.Uwp.Extensions;
using ComputeSharp.SwapChain.Uwp.Services;
#endif
using ComputeSharp.SwapChain.Uwp.Views;
Expand Down Expand Up @@ -62,11 +60,9 @@ private static void ConfigureServices()
ServiceCollection services = new();

#if !DEBUG
if (!Debugger.IsAttached &&
Assembly.GetExecutingAssembly().TryReadAllTextFromManifestFile("Assets/ServiceTokens/AppCenter.txt", out string? secret) &&
Guid.TryParse(secret, out _))
if (Guid.TryParse(AppServiceSecret, out _) && !Debugger.IsAttached)
{
services.AddSingleton<IAnalyticsService>(new AppCenterService(secret!));
services.AddSingleton<IAnalyticsService>(new AppCenterService(AppServiceSecret));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\AssemblyExtensions.cs" />
<Compile Include="Assets\ServiceTokens\App.AppCenter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\SkipLocalsInitAttribute.cs" />
<Compile Include="Services\AppCenterService.cs" />
Expand All @@ -104,7 +104,6 @@
<Link>Assets\Textures\RustyMetal.png</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="Assets\ServiceTokens\AppCenter.txt" />
<Content Include="Assets\SmallTile.scale-100.png" />
<Content Include="Assets\SmallTile.scale-125.png" />
<Content Include="Assets\SmallTile.scale-150.png" />
Expand Down

This file was deleted.