Start adding IDisposableAnalyzers to projects
This commit is contained in:
parent
eb5f76a447
commit
afc195286f
|
@ -19,6 +19,7 @@
|
||||||
<PackageVersion Include="DotNet.Glob" Version="3.1.3" />
|
<PackageVersion Include="DotNet.Glob" Version="3.1.3" />
|
||||||
<PackageVersion Include="EFCoreSecondLevelCacheInterceptor" Version="3.9.2" />
|
<PackageVersion Include="EFCoreSecondLevelCacheInterceptor" Version="3.9.2" />
|
||||||
<PackageVersion Include="FsCheck.Xunit" Version="2.16.6" />
|
<PackageVersion Include="FsCheck.Xunit" Version="2.16.6" />
|
||||||
|
<PackageVersion Include="IDisposableAnalyzers" Version="4.0.7" />
|
||||||
<PackageVersion Include="Jellyfin.XmlTv" Version="10.8.0" />
|
<PackageVersion Include="Jellyfin.XmlTv" Version="10.8.0" />
|
||||||
<PackageVersion Include="libse" Version="3.6.13" />
|
<PackageVersion Include="libse" Version="3.6.13" />
|
||||||
<PackageVersion Include="LrcParser" Version="2023.524.0" />
|
<PackageVersion Include="LrcParser" Version="2023.524.0" />
|
||||||
|
|
|
@ -173,4 +173,18 @@
|
||||||
<!-- error on RS0030: Do not used banned APIs -->
|
<!-- error on RS0030: Do not used banned APIs -->
|
||||||
<Rule Id="RS0030" Action="Error" />
|
<Rule Id="RS0030" Action="Error" />
|
||||||
</Rules>
|
</Rules>
|
||||||
|
|
||||||
|
<Rules AnalyzerId="IDisposableAnalyzers" RuleNamespace="IDisposableAnalyzers.Correctness">
|
||||||
|
<!-- disable warning IDISP001: Dispose created -->
|
||||||
|
<Rule Id="IDISP001" Action="Info" />
|
||||||
|
<!-- TODO: Enable when false positives are fixed -->
|
||||||
|
<!-- disable warning IDISP003: Dispose previous before re-assigning -->
|
||||||
|
<Rule Id="IDISP003" Action="Info" />
|
||||||
|
<!-- disable warning IDISP004: Don't ignore created IDisposable -->
|
||||||
|
<Rule Id="IDISP004" Action="Info" />
|
||||||
|
<!-- disable warning IDISP007: Don't dispose injected -->
|
||||||
|
<Rule Id="IDISP007" Action="Info" />
|
||||||
|
<!-- disable warning IDISP008: Don't assign member with injected and created disposables -->
|
||||||
|
<Rule Id="IDISP008" Action="Info" />
|
||||||
|
</Rules>
|
||||||
</RuleSet>
|
</RuleSet>
|
||||||
|
|
|
@ -31,8 +31,12 @@
|
||||||
<ProjectReference Include="..\..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
|
<ProjectReference Include="..\..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Code analysers-->
|
<!-- Code Analyzers-->
|
||||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="IDisposableAnalyzers">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
|
|
@ -122,8 +122,8 @@ public class SkiaEncoder : IImageEncoder
|
||||||
var svg = new SKSvg();
|
var svg = new SKSvg();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
svg.Load(path);
|
using var picture = svg.Load(path);
|
||||||
return new ImageDimensions(Convert.ToInt32(svg.Picture.CullRect.Width), Convert.ToInt32(svg.Picture.CullRect.Height));
|
return new ImageDimensions(Convert.ToInt32(picture.CullRect.Width), Convert.ToInt32(picture.CullRect.Height));
|
||||||
}
|
}
|
||||||
catch (FormatException skiaColorException)
|
catch (FormatException skiaColorException)
|
||||||
{
|
{
|
||||||
|
@ -432,7 +432,8 @@ public class SkiaEncoder : IImageEncoder
|
||||||
|
|
||||||
// scale image (the FromImage creates a copy)
|
// scale image (the FromImage creates a copy)
|
||||||
var imageInfo = new SKImageInfo(width, height, bitmap.ColorType, bitmap.AlphaType, bitmap.ColorSpace);
|
var imageInfo = new SKImageInfo(width, height, bitmap.ColorType, bitmap.AlphaType, bitmap.ColorSpace);
|
||||||
using var resizedBitmap = SKBitmap.FromImage(ResizeImage(bitmap, imageInfo));
|
using var resizedImage = ResizeImage(bitmap, imageInfo);
|
||||||
|
using var resizedBitmap = SKBitmap.FromImage(resizedImage);
|
||||||
|
|
||||||
// If all we're doing is resizing then we can stop now
|
// If all we're doing is resizing then we can stop now
|
||||||
if (!hasBackgroundColor && !hasForegroundColor && blur == 0 && !hasIndicator)
|
if (!hasBackgroundColor && !hasForegroundColor && blur == 0 && !hasIndicator)
|
||||||
|
|
|
@ -19,7 +19,6 @@ public static class SkiaHelper
|
||||||
public static SKBitmap? GetNextValidImage(SkiaEncoder skiaEncoder, IReadOnlyList<string> paths, int currentIndex, out int newIndex)
|
public static SKBitmap? GetNextValidImage(SkiaEncoder skiaEncoder, IReadOnlyList<string> paths, int currentIndex, out int newIndex)
|
||||||
{
|
{
|
||||||
var imagesTested = new Dictionary<int, int>();
|
var imagesTested = new Dictionary<int, int>();
|
||||||
SKBitmap? bitmap = null;
|
|
||||||
|
|
||||||
while (imagesTested.Count < paths.Count)
|
while (imagesTested.Count < paths.Count)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +27,7 @@ public static class SkiaHelper
|
||||||
currentIndex = 0;
|
currentIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap = skiaEncoder.Decode(paths[currentIndex], false, null, out _);
|
SKBitmap? bitmap = skiaEncoder.Decode(paths[currentIndex], false, null, out _);
|
||||||
|
|
||||||
imagesTested[currentIndex] = 0;
|
imagesTested[currentIndex] = 0;
|
||||||
|
|
||||||
|
@ -36,11 +35,12 @@ public static class SkiaHelper
|
||||||
|
|
||||||
if (bitmap is not null)
|
if (bitmap is not null)
|
||||||
{
|
{
|
||||||
break;
|
newIndex = currentIndex;
|
||||||
|
return bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newIndex = currentIndex;
|
newIndex = currentIndex;
|
||||||
return bitmap;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,12 +189,12 @@ public partial class StripCollageBuilder
|
||||||
|
|
||||||
// Scale image. The FromBitmap creates a copy
|
// Scale image. The FromBitmap creates a copy
|
||||||
var imageInfo = new SKImageInfo(cellWidth, cellHeight, currentBitmap.ColorType, currentBitmap.AlphaType, currentBitmap.ColorSpace);
|
var imageInfo = new SKImageInfo(cellWidth, cellHeight, currentBitmap.ColorType, currentBitmap.AlphaType, currentBitmap.ColorSpace);
|
||||||
using var resizedBitmap = SKBitmap.FromImage(SkiaEncoder.ResizeImage(currentBitmap, imageInfo));
|
using var resizeImage = SkiaEncoder.ResizeImage(currentBitmap, imageInfo);
|
||||||
|
|
||||||
// draw this image into the strip at the next position
|
// draw this image into the strip at the next position
|
||||||
var xPos = x * cellWidth;
|
var xPos = x * cellWidth;
|
||||||
var yPos = y * cellHeight;
|
var yPos = y * cellHeight;
|
||||||
canvas.DrawBitmap(resizedBitmap, xPos, yPos);
|
canvas.DrawImage(resizeImage, xPos, yPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,12 @@
|
||||||
<Compile Include="..\..\SharedVersion.cs" />
|
<Compile Include="..\..\SharedVersion.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Code analysers-->
|
<!-- Code Analyzers-->
|
||||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="IDisposableAnalyzers">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
|
|
||||||
<!-- Code Analyzers-->
|
<!-- Code Analyzers-->
|
||||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="IDisposableAnalyzers">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
<!-- Code Analyzers-->
|
<!-- Code Analyzers-->
|
||||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="IDisposableAnalyzers">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
|
|
||||||
<!-- Code Analyzers-->
|
<!-- Code Analyzers-->
|
||||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="IDisposableAnalyzers">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user