Skip to content

[fix-finder] Add missing using declarations for SKFont instances in SKFontTest #3992

Description

@github-actions

Problem

SKFontTest.cs has 27 test methods that create new SKFont(...) without a using declaration, leaking the native Skia font handle when the test completes. The file already uses using var font = new SKFont() in 14 other tests, so the inconsistency is clear.

Location

  • File(s): tests/Tests/SkiaSharp/SKFontTest.cs
  • Line(s): 83, 112, 125, 143, 154, 164, 183, 194, 217, 229, 242, 250, 258, 276, and others

Current Code

var font = new SKFont(SKTypeface.Default);

var widths = font.GetGlyphWidths("Hello World!", out var bounds);
// ... assertions ...

Suggested Fix

using var font = new SKFont(SKTypeface.Default);

var widths = font.GetGlyphWidths("Hello World!", out var bounds);
// ... assertions ...

Apply the same pattern to all ~27 instances in this file where var font = new SKFont(...) appears without using. The fix is purely mechanical: add using before var on each declaration.

SkiaSharp Guidelines

  • Does NOT modify any *.generated.cs file
  • Does NOT change existing public API signatures (ABI stable)
  • Does NOT use default parameters in public methods
  • Does NOT use .NET 6+ APIs without #if guards
  • Follows existing code style and naming conventions

Acceptance Criteria

  • All var font = new SKFont(...) declarations in SKFontTest.cs use using var font = new SKFont(...)
  • No test logic is changed — only the using keyword is added
  • All tests pass: dotnet test tests/SkiaSharp.Tests.Console/SkiaSharp.Tests.Console.csproj
  • No new warnings introduced

Part of #3976

Generated by Nightly Fix Finder · ● 4.5M ·

  • expires on May 22, 2026, 10:43 PM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

Status
New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions