Skip to content

Commit

Permalink
fix: enable more code analyzers & fix locking on this issue
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 26, 2024
1 parent 1f0bb6e commit feffb4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Shokofin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages {

private readonly ILogger<Plugin> Logger;

private readonly object Lock = new();

/// <summary>
/// The last time the base URL and base path was updated.
/// </summary>
Expand All @@ -43,7 +45,7 @@ public string BaseUrl {
if (CachedBaseUrl is not null && LastBaseUrlUpdate is not null && DateTime.Now - LastBaseUrlUpdate < BaseUrlUpdateDelay)
return CachedBaseUrl;

lock(this) {
lock (Lock) {
LastBaseUrlUpdate = DateTime.Now;
if (_configurationManager.GetNetworkConfiguration() is not { } networkOptions) {
CachedBaseUrl = "http://localhost:8096/";
Expand Down Expand Up @@ -78,12 +80,12 @@ public string BasePath {
if (CachedBasePath is not null && LastBaseUrlUpdate is not null && DateTime.Now - LastBaseUrlUpdate < BaseUrlUpdateDelay)
return CachedBasePath;

lock(this) {
lock (Lock) {
LastBaseUrlUpdate = DateTime.Now;
if (_configurationManager.GetNetworkConfiguration() is not { } networkOptions) {
CachedBaseUrl = "http://localhost:8096/";
CachedBasePath = string.Empty;
return CachedBaseUrl;
return CachedBasePath;
}

var protocol = networkOptions.RequireHttps && networkOptions.EnableHttps ? "https" : "http";
Expand Down
6 changes: 6 additions & 0 deletions Shokofin/Shokofin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<PackageReference Include="DotNet.Glob" Version="3.1.*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup>

<Target Name="CopySignalRDLLsToOutputPath" AfterTargets="Build">
<ItemGroup>
<BasePackage Include="$(NuGetPackageRoot)\microsoft.aspnetcore.signalr.client\$(SignalRVersion)\lib\$(TargetFramework)\Microsoft.AspNetCore.SignalR.Client.dll" />
Expand Down

0 comments on commit feffb4d

Please sign in to comment.