Make CharacterReader internal. (#19123)
* Make `CharacterReader` internal. And by extension, make the static classes which define extension methods on it internal. To do this, I had to make Avalonia.Base's internals visible to Avalonia.Designer.HostApp, as that has a dependency on it, and exclude `StringCompatibilityExtensions` from there as the one from Avalonia.Base is now visible. * Don't expose internals to HostApp. Exposing Avalonia.Base's internals to Avalonia.Designer.HostApp caused an issue with the dependency on `StringCompatibilityExtensions` - because the hostapp is loaded into the target app and `StringCompatibilityExtensions` is conditionally compiled, you ended up with it being loaded into an app which does not have `StringCompatibilityExtensions`. Instead, add `string` overloads of the internal APIs which take a `CharacterReader` so that they can be called even when `CharacterReader` isn't available. * Update API diff.
This commit is contained in:
@@ -7,6 +7,30 @@
|
||||
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Utilities.CharacterReader</Target>
|
||||
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Utilities.IdentifierParser</Target>
|
||||
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Utilities.KeywordParser</Target>
|
||||
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Utilities.StyleClassParser</Target>
|
||||
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0002</DiagnosticId>
|
||||
<Target>M:Avalonia.Diagnostics.AppliedStyle.get_HasActivator</Target>
|
||||
|
||||
@@ -2,11 +2,7 @@ using System;
|
||||
|
||||
namespace Avalonia.Utilities
|
||||
{
|
||||
// TODO12: This should not be public
|
||||
#if !BUILDTASK
|
||||
public
|
||||
#endif
|
||||
ref struct CharacterReader
|
||||
internal ref struct CharacterReader
|
||||
{
|
||||
private ReadOnlySpan<char> _s;
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@ using System.Globalization;
|
||||
|
||||
namespace Avalonia.Utilities
|
||||
{
|
||||
#if !BUILDTASK
|
||||
public
|
||||
#endif
|
||||
static class IdentifierParser
|
||||
internal static class IdentifierParser
|
||||
{
|
||||
public static ReadOnlySpan<char> ParseIdentifier(this
|
||||
#if NET7SDK
|
||||
|
||||
@@ -2,10 +2,7 @@ using System;
|
||||
|
||||
namespace Avalonia.Utilities
|
||||
{
|
||||
#if !BUILDTASK
|
||||
public
|
||||
#endif
|
||||
static class KeywordParser
|
||||
internal static class KeywordParser
|
||||
{
|
||||
public static bool CheckKeyword(this ref CharacterReader r, string keyword)
|
||||
{
|
||||
|
||||
@@ -3,10 +3,7 @@ using System.Globalization;
|
||||
|
||||
namespace Avalonia.Utilities
|
||||
{
|
||||
#if !BUILDTASK
|
||||
public
|
||||
#endif
|
||||
static class StyleClassParser
|
||||
internal static class StyleClassParser
|
||||
{
|
||||
public static ReadOnlySpan<char> ParseStyleClass(this ref CharacterReader r)
|
||||
{
|
||||
|
||||
+2
-4
@@ -22,8 +22,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
|
||||
|
||||
if (binding.Arguments.Count > 0 && binding.Arguments[0] is XamlAstTextNode bindingPathText)
|
||||
{
|
||||
var reader = new CharacterReader(bindingPathText.Text.AsSpan());
|
||||
var (nodes, _) = BindingExpressionGrammar.Parse(ref reader);
|
||||
var (nodes, _) = BindingExpressionGrammar.Parse(bindingPathText.Text);
|
||||
|
||||
if (convertedNode != null)
|
||||
{
|
||||
@@ -48,8 +47,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
|
||||
|
||||
if (bindingPathAssignment != null && bindingPathAssignment.Values[0] is XamlAstTextNode pathValue)
|
||||
{
|
||||
var reader = new CharacterReader(pathValue.Text.AsSpan());
|
||||
var (nodes, _) = BindingExpressionGrammar.Parse(ref reader);
|
||||
var (nodes, _) = BindingExpressionGrammar.Parse(pathValue.Text);
|
||||
|
||||
if (nodes.Count == 1 && nodes[0] is BindingExpressionGrammar.EmptyExpressionNode)
|
||||
{
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
|
||||
{
|
||||
XamlAstNamePropertyReference forgedReference;
|
||||
|
||||
var parsedPropertyName = PropertyParser.Parse(new CharacterReader(propertyName.AsSpan()));
|
||||
var parsedPropertyName = PropertyParser.Parse(propertyName);
|
||||
if(parsedPropertyName.owner == null)
|
||||
forgedReference = new XamlAstNamePropertyReference(lineInfo, selectorTypeReference,
|
||||
propertyName, selectorTypeReference);
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
using Avalonia.Data.Core;
|
||||
using System;
|
||||
using Avalonia.Data.Core;
|
||||
using Avalonia.Utilities;
|
||||
|
||||
namespace Avalonia.Markup.Xaml.Parsers
|
||||
{
|
||||
internal class PropertyParser
|
||||
{
|
||||
public static (string? ns, string? owner, string name) Parse(string text)
|
||||
{
|
||||
var r = new CharacterReader(text.AsSpan());
|
||||
return Parse(r);
|
||||
}
|
||||
|
||||
public static (string? ns, string? owner, string name) Parse(CharacterReader r)
|
||||
{
|
||||
if (r.End)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
||||
using Avalonia.Data.Core;
|
||||
using Avalonia.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Avalonia.Data.Core;
|
||||
using Avalonia.Utilities;
|
||||
|
||||
namespace Avalonia.Markup.Parsers
|
||||
{
|
||||
@@ -18,6 +18,12 @@ namespace Avalonia.Markup.Parsers
|
||||
{
|
||||
private static readonly List<INode> s_pool = new();
|
||||
|
||||
public static (List<INode> Nodes, SourceMode Mode) Parse(string text)
|
||||
{
|
||||
var r = new CharacterReader(text.AsSpan());
|
||||
return Parse(ref r);
|
||||
}
|
||||
|
||||
public static (List<INode> Nodes, SourceMode Mode) Parse(ref CharacterReader r)
|
||||
{
|
||||
var result = new List<INode>();
|
||||
|
||||
Reference in New Issue
Block a user