Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Text;
using Microsoft.CodeAnalysis.EmbeddedLanguages.VirtualChars;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.ExternalAccess.AspNetCore.EmbeddedLanguages
{
internal readonly struct AspNetCoreVirtualChar
internal readonly struct AspNetCoreVirtualChar : IEquatable<AspNetCoreVirtualChar>
{
private readonly VirtualChar _virtualChar;

Expand All @@ -17,8 +18,15 @@ internal AspNetCoreVirtualChar(VirtualChar virtualChar)
_virtualChar = virtualChar;
}

/// <inheritdoc cref="VirtualChar.Rune"/>
public Rune Rune => _virtualChar.Rune;
/// <summary>
/// Returns the Unicode scalar value as an integer.
/// </summary>
public int RuneValue
{
// Rune is an internal shim with netstandard2.0 and accessing it throws an internal access exception.
// Expose integer value. Can be converted back to Rune by caller.
get => _virtualChar.Rune.Value;
}

/// <inheritdoc cref="VirtualChar.SurrogateChar"/>
public char SurrogateChar => _virtualChar.SurrogateChar;
Expand All @@ -31,5 +39,14 @@ internal AspNetCoreVirtualChar(VirtualChar virtualChar)

/// <inheritdoc cref="VirtualChar.ToString"/>
public override string ToString() => _virtualChar.ToString();

/// <inheritdoc cref="VirtualChar.Equals(object)"/>
public override bool Equals(object? obj) => _virtualChar.Equals(obj);

/// <inheritdoc cref="VirtualChar.Equals(VirtualChar)"/>
public bool Equals(AspNetCoreVirtualChar other) => _virtualChar.Equals(other._virtualChar);

/// <inheritdoc cref="VirtualChar.GetHashCode"/>
public override int GetHashCode() => _virtualChar.GetHashCode();
}
}