Skip to content
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cSpell.words": [
"appsettings",
"Avalonia",
"Kiota"
"Kiota",
"onedrive"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<ProjectReference Include="..\..\nuget-packages\AStar.Dev.Functional.Extensions\AStar.Dev.Functional.Extensions.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.0" />
<PackageReference Include="Microsoft.Graph" Version="5.97.0" />
<PackageReference Include="Azure.Identity" Version="1.17.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
<PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
<PackageReference Include="Azure.Identity" Version="1.17.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Avalonia" Version="11.3.9" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.9" />
<!-- <PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.10" />-->
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.9" />
<!-- <PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />-->
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.9" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
Expand Down
8 changes: 4 additions & 4 deletions src/services/AStar.Dev.OneDrive.Client/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ namespace AStar.Dev.OneDrive.Client;

public sealed class AppSettings
{
public string ClientId { get; set; } = string.Empty;
public string TenantId { get; set; } = "common"; // or your tenant
public string ClientSecret { get; internal set; } = string.Empty;

// existing properties...
public string ClientId { get; set; } = "";
public string TenantId { get; set; } = "";
}

15 changes: 3 additions & 12 deletions src/services/AStar.Dev.OneDrive.Client/GraphClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,12 @@ public static GraphServiceClient CreateGraphClient(
return new GraphServiceClient(adapter);
}

private sealed class PolicyHandler : DelegatingHandler
private sealed class PolicyHandler(IAsyncPolicy<HttpResponseMessage> policy, Action<string>? logAction = null) : DelegatingHandler
{
private readonly IAsyncPolicy<HttpResponseMessage> _policy;
private readonly Action<string>? _logAction;

public PolicyHandler(IAsyncPolicy<HttpResponseMessage> policy, Action<string>? logAction = null)
{
_policy = policy;
_logAction = logAction;
}

protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
_logAction?.Invoke($"➡️ {request.Method} {request.RequestUri}");
return _policy.ExecuteAsync(ct => base.SendAsync(request, ct), cancellationToken);
logAction?.Invoke($"➡️ {request.Method} {request.RequestUri}");
return policy.ExecuteAsync(ct => base.SendAsync(request, ct), cancellationToken);
}
}
}
6 changes: 4 additions & 2 deletions src/services/AStar.Dev.OneDrive.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AStar.Dev.OneDrive.Client.Services;
using AStar.Dev.OneDrive.Client.ViewModels;
using AStar.Dev.OneDrive.Client.Views;
using Avalonia;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -76,9 +77,9 @@
?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
}

var logDir = Path.Combine(baseDir, "AStar.Dev", "AStar.OneDrive.Client", "logs");
var logDir = Path.Combine(baseDir, "astar-dev", "astar-dev-onedrive-client", "logs");
_ = Directory.CreateDirectory(logDir);
var logPath = Path.Combine(logDir, "AStar.OneDrive.Client-.log");
var logPath = Path.Combine(logDir, "astar-dev-onedrive-client-.log");

_ = loggerConfig.WriteTo.File(logPath, rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug);
}
Expand All @@ -95,6 +96,7 @@
_ = services.AddSingleton(appSettings);
_ = services.AddSingleton<ILoginService, LoginService>();
_ = services.AddTransient<MainWindowViewModel>();
_ = services.AddTransient<UserSettings>();
_ = services.AddTransient<OneDriveService>();
_ = services.AddSingleton<UserSettingsService>();
_ = services.AddTransient<MainWindow>();
Expand All @@ -105,5 +107,5 @@
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
//.UseReactiveUI();

Check warning on line 110 in src/services/AStar.Dev.OneDrive.Client/Program.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
}
Loading