Browse Source

Hide TextRange. It has no public usage. (#20893)

* Hide TextRange. It has no public usage.

* Update api diff
pull/20895/head
Benedikt Stebner 1 week ago
committed by GitHub
parent
commit
ada1e72ce8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      api/Avalonia.Headless.XUnit.nupkg.xml
  2. 4
      api/Avalonia.Headless.nupkg.xml
  3. 4
      api/Avalonia.LinuxFramebuffer.nupkg.xml
  4. 4
      api/Avalonia.Skia.nupkg.xml
  5. 4
      api/Avalonia.Win32.Interoperability.nupkg.xml
  6. 16
      api/Avalonia.nupkg.xml
  7. 66
      src/Avalonia.Base/Media/TextFormatting/FormattedTextSource.cs
  8. 70
      src/Avalonia.Base/Media/TextFormatting/TextRange.cs
  9. 5
      tests/Avalonia.Skia.UnitTests/Media/TextFormatting/MultiBufferTextSource.cs

4
api/Avalonia.Headless.XUnit.nupkg.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
@ -73,4 +73,4 @@
<Left>baseline/Avalonia.Headless.XUnit/lib/net8.0/Avalonia.Headless.XUnit.dll</Left>
<Right>current/Avalonia.Headless.XUnit/lib/net8.0/Avalonia.Headless.XUnit.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>

4
api/Avalonia.Headless.nupkg.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
@ -37,4 +37,4 @@
<Left>baseline/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Left>
<Right>current/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>

4
api/Avalonia.LinuxFramebuffer.nupkg.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
@ -37,4 +37,4 @@
<Left>baseline/Avalonia.LinuxFramebuffer/lib/net8.0/Avalonia.LinuxFramebuffer.dll</Left>
<Right>current/Avalonia.LinuxFramebuffer/lib/net8.0/Avalonia.LinuxFramebuffer.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>

4
api/Avalonia.Skia.nupkg.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
@ -169,4 +169,4 @@
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>

4
api/Avalonia.Win32.Interoperability.nupkg.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
@ -37,4 +37,4 @@
<Left>baseline/Avalonia.Win32.Interoperability/lib/net8.0-windows7.0/Avalonia.Win32.Interoperability.dll</Left>
<Right>current/Avalonia.Win32.Interoperability/lib/net8.0-windows7.0/Avalonia.Win32.Interoperability.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>

16
api/Avalonia.nupkg.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
@ -163,6 +163,12 @@
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Media.TextFormatting.TextRange</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.IGeometryContext2</Target>
@ -631,6 +637,12 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Media.TextFormatting.TextRange</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.IGeometryContext2</Target>
@ -5221,4 +5233,4 @@
<Left>baseline/Avalonia/lib/netstandard2.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>

66
src/Avalonia.Base/Media/TextFormatting/FormattedTextSource.cs

@ -132,5 +132,71 @@ namespace Avalonia.Media.TextFormatting
return Math.Min(length, text.Length);
}
/// <summary>
/// References a portion of a text buffer.
/// </summary>
private readonly record struct TextRange
{
public TextRange(int start, int length)
{
Start = start;
Length = length;
}
/// <summary>
/// Gets the start.
/// </summary>
/// <value>
/// The start.
/// </value>
public int Start { get; }
/// <summary>
/// Gets the length.
/// </summary>
/// <value>
/// The length.
/// </value>
public int Length { get; }
/// <summary>
/// Gets the end.
/// </summary>
/// <value>
/// The end.
/// </value>
public int End => Start + Length - 1;
/// <summary>
/// Returns a specified number of contiguous elements from the start of the slice.
/// </summary>
/// <param name="length">The number of elements to return.</param>
/// <returns>A <see cref="TextRange"/> that contains the specified number of elements from the start of this slice.</returns>
public TextRange Take(int length)
{
if (length > Length)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
return new TextRange(Start, length);
}
/// <summary>
/// Bypasses a specified number of elements in the slice and then returns the remaining elements.
/// </summary>
/// <param name="length">The number of elements to skip before returning the remaining elements.</param>
/// <returns>A <see cref="TextRange"/> that contains the elements that occur after the specified index in this slice.</returns>
public TextRange Skip(int length)
{
if (length > Length)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
return new TextRange(Start + length, Length - length);
}
}
}
}

70
src/Avalonia.Base/Media/TextFormatting/TextRange.cs

@ -1,70 +0,0 @@
using System;
namespace Avalonia.Media.TextFormatting
{
/// <summary>
/// References a portion of a text buffer.
/// </summary>
public readonly record struct TextRange
{
public TextRange(int start, int length)
{
Start = start;
Length = length;
}
/// <summary>
/// Gets the start.
/// </summary>
/// <value>
/// The start.
/// </value>
public int Start { get; }
/// <summary>
/// Gets the length.
/// </summary>
/// <value>
/// The length.
/// </value>
public int Length { get; }
/// <summary>
/// Gets the end.
/// </summary>
/// <value>
/// The end.
/// </value>
public int End => Start + Length - 1;
/// <summary>
/// Returns a specified number of contiguous elements from the start of the slice.
/// </summary>
/// <param name="length">The number of elements to return.</param>
/// <returns>A <see cref="TextRange"/> that contains the specified number of elements from the start of this slice.</returns>
public TextRange Take(int length)
{
if (length > Length)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
return new TextRange(Start, length);
}
/// <summary>
/// Bypasses a specified number of elements in the slice and then returns the remaining elements.
/// </summary>
/// <param name="length">The number of elements to skip before returning the remaining elements.</param>
/// <returns>A <see cref="TextRange"/> that contains the elements that occur after the specified index in this slice.</returns>
public TextRange Skip(int length)
{
if (length > Length)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
return new TextRange(Start + length, Length - length);
}
}
}

5
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/MultiBufferTextSource.cs

@ -1,4 +1,5 @@
using Avalonia.Media.TextFormatting;
using System;
using Avalonia.Media.TextFormatting;
namespace Avalonia.Skia.UnitTests.Media.TextFormatting
{
@ -14,8 +15,6 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
_runTexts = new[] { "A123456789", "B123456789", "C123456789", "D123456789", "E123456789" };
}
public static TextRange TextRange => new TextRange(0, 50);
public TextRun? GetTextRun(int textSourceIndex)
{
if (textSourceIndex >= 50)

Loading…
Cancel
Save