Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ csharp_style_unused_value_assignment_preference = discard_variable:suggestion

# C# code style - Index and range preferences
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#index-and-range-preferences
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion

# C# code style - Miscellaneous preferences
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#miscellaneous-preferences
Expand Down
3 changes: 0 additions & 3 deletions src/GraphQLParser.ApiTests/GraphQL-Parser.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ namespace GraphQLParser.AST
public GraphQLComment() { }
public override GraphQLParser.AST.ASTNodeKind Kind { get; }
public GraphQLParser.ROM Text { get; set; }
public string TextString { get; }
}
public class GraphQLDirective : GraphQLParser.AST.ASTNode, GraphQLParser.AST.INamedNode
{
Expand Down Expand Up @@ -193,7 +192,6 @@ namespace GraphQLParser.AST
public GraphQLName() { }
public override GraphQLParser.AST.ASTNodeKind Kind { get; }
public GraphQLParser.ROM Value { get; set; }
public string ValueString { get; }
}
public class GraphQLNamedType : GraphQLParser.AST.GraphQLType, GraphQLParser.AST.INamedNode
{
Expand Down Expand Up @@ -258,7 +256,6 @@ namespace GraphQLParser.AST
public GraphQLScalarValue(GraphQLParser.AST.ASTNodeKind kind) { }
public override GraphQLParser.AST.ASTNodeKind Kind { get; }
public GraphQLParser.ROM Value { get; set; }
public string ValueString { get; }
public override string? ToString() { }
}
public class GraphQLSchemaDefinition : GraphQLParser.AST.ASTNode, GraphQLParser.AST.IHasDirectivesNode
Expand Down
22 changes: 2 additions & 20 deletions src/GraphQLParser/AST/GraphQLComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,15 @@
namespace GraphQLParser.AST
{
/// <inheritdoc cref="ASTNodeKind.Comment"/>
[DebuggerDisplay("{TextString}")]
[DebuggerDisplay("{Text}")]
public class GraphQLComment : ASTNode
{
private ROM _text;
private string? _textString;

/// <inheritdoc/>
public override ASTNodeKind Kind => ASTNodeKind.Comment;

/// <summary>
/// Comment value represented as <see cref="ROM"/>.
/// </summary>
public ROM Text
{
get => _text;
set
{
_text = value;
_textString = null;
}
}

/// <summary>
/// Gets comment value represented as string. The value of this property is cached and in sync with <see cref="Text"/>.
/// The first time this property is accessed, memory in the managed heap will be allocated for it.
/// In scenarios where minimum memory consumption is required, use the <see cref="Text"/> property.
/// </summary>
public string TextString => _textString ??= (string)Text;
public ROM Text { get; set; }
}
}
22 changes: 2 additions & 20 deletions src/GraphQLParser/AST/GraphQLName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,15 @@
namespace GraphQLParser.AST
{
/// <inheritdoc cref="ASTNodeKind.Name"/>
[DebuggerDisplay("{ValueString}")]
[DebuggerDisplay("{Value}")]
public class GraphQLName : ASTNode
{
private ROM _value;
private string? _valueString;

/// <inheritdoc/>
public override ASTNodeKind Kind => ASTNodeKind.Name;

/// <summary>
/// Name value represented as <see cref="ROM"/>.
/// </summary>
public ROM Value
{
get => _value;
set
{
_value = value;
_valueString = null;
}
}

/// <summary>
/// Gets name value represented as string. The value of this property is cached and in sync with <see cref="Value"/>.
/// The first time this property is accessed, memory in the managed heap will be allocated for it.
/// In scenarios where minimum memory consumption is required, use the <see cref="Value"/> property.
/// </summary>
public string ValueString => _valueString ??= (string)Value;
public ROM Value { get; set; }
}
}
21 changes: 2 additions & 19 deletions src/GraphQLParser/AST/GraphQLScalarValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ namespace GraphQLParser.AST
/// <br/>
/// <see cref="ASTNodeKind.NullValue">Null</see>
/// </summary>
[DebuggerDisplay("{ValueString}")]
[DebuggerDisplay("{Value}")]
public class GraphQLScalarValue : GraphQLValue
{
private readonly ASTNodeKind _kind;
private ROM _value;
private string? _valueString;

/// <summary>
/// Creates scalar node with the specified kind.
Expand All @@ -41,22 +39,7 @@ public GraphQLScalarValue(ASTNodeKind kind)
/// <summary>
/// Scalar value represented as <see cref="ROM"/>.
/// </summary>
public ROM Value
{
get => _value;
set
{
_value = value;
_valueString = null;
}
}

/// <summary>
/// Gets scalar value represented as string. The value of this property is cached and in sync with <see cref="Value"/>.
/// The first time this property is accessed, memory in the managed heap will be allocated for it.
/// In scenarios where minimum memory consumption is required, use the <see cref="Value"/> property.
/// </summary>
public string ValueString => _valueString ??= (string)Value;
public ROM Value { get; set; }

/// <inheritdoc/>
public override string? ToString() => Kind == ASTNodeKind.StringValue ? $"\"{Value}\"" : Value.ToString();
Expand Down
1 change: 0 additions & 1 deletion src/GraphQLParser/GraphQLParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<AssemblyName>GraphQL-Parser</AssemblyName>
<PackageTags>GraphQL;json;api;parser</PackageTags>
<NoWarn Condition="'$(TargetFramework)' == 'netstandard2.1'">$(NoWarn);IDE0057</NoWarn> <!--Slice can be simplified-->
</PropertyGroup>

<ItemGroup>
Expand Down