Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Xml readonly annotation #51798

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public async Task WriteElementAsync(XElement e, CancellationToken cancellationTo
}
}

private string? GetPrefixOfNamespace(XNamespace ns, bool allowDefaultNamespace)
private readonly string? GetPrefixOfNamespace(XNamespace ns, bool allowDefaultNamespace)
{
string namespaceName = ns.NamespaceName;
if (namespaceName.Length == 0) return string.Empty;
Expand Down Expand Up @@ -556,7 +556,7 @@ private void FlushElement()
}
}

private string? GetPrefixOfNamespace(XNamespace ns, bool allowDefaultNamespace)
private readonly string? GetPrefixOfNamespace(XNamespace ns, bool allowDefaultNamespace)
{
string namespaceName = ns.NamespaceName;
if (namespaceName.Length == 0) return string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal struct BinXmlSqlDecimal
internal uint m_data3;
internal uint m_data4;

public bool IsPositive
public readonly bool IsPositive
{
get
{
Expand Down Expand Up @@ -139,7 +139,7 @@ private static char ChFromDigit(uint uiDigit)
return (char)(uiDigit + '0');
}

public decimal ToDecimal()
public readonly decimal ToDecimal()
{
if ((int)m_data4 != 0 || m_bScale > 28)
throw new XmlException(SR.SqlTypes_ArithOverflow, (string?)null);
Expand Down Expand Up @@ -246,7 +246,7 @@ public override string ToString()

// Is this RE numeric valid?
[System.Diagnostics.Conditional("DEBUG")]
private void AssertValid()
private readonly void AssertValid()
{
// Scale,Prec in range
Debug.Assert(m_bScale <= s_NUMERIC_MAX_PRECISION, "m_bScale <= NUMERIC_MAX_PRECISION", "In AssertValid");
Expand Down Expand Up @@ -277,7 +277,7 @@ internal struct BinXmlSqlMoney
public BinXmlSqlMoney(int v) { _data = v; }
public BinXmlSqlMoney(long v) { _data = v; }

public decimal ToDecimal()
public readonly decimal ToDecimal()
{
bool neg;
ulong v;
Expand All @@ -296,7 +296,7 @@ public decimal ToDecimal()
return new decimal(unchecked((int)v), unchecked((int)(v >> 32)), 0, neg, MoneyScale);
}

public override string ToString()
public override readonly string ToString()
{
decimal money = ToDecimal();
// Formatting of SqlMoney: At least two digits after decimal point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,34 @@ public void Clear()
this.prefix = this.localname = this.namespaceUri = string.Empty;
}

public bool MatchNs(string lname, string nsUri)
public readonly bool MatchNs(string lname, string nsUri)
{
return lname == this.localname && nsUri == this.namespaceUri;
}

public bool MatchPrefix(string prefix, string lname)
public readonly bool MatchPrefix(string prefix, string lname)
{
return lname == this.localname && prefix == this.prefix;
}

public void CheckPrefixNS(string prefix, string namespaceUri)
public readonly void CheckPrefixNS(string prefix, string namespaceUri)
{
if (this.prefix == prefix && this.namespaceUri != namespaceUri)
throw new XmlException(SR.XmlBinary_NoRemapPrefix, new string[] { prefix, this.namespaceUri, namespaceUri });
}

public override int GetHashCode()
public override readonly int GetHashCode()
{
return this.prefix.GetHashCode() ^ this.localname.GetHashCode();
}

public int GetNSHashCode()
public readonly int GetNSHashCode()
{
return HashCode.Combine(this.namespaceUri, this.localname);
}


public override bool Equals([NotNullWhen(true)] object? other)
public override readonly bool Equals([NotNullWhen(true)] object? other)
{
if (other is QName that)
{
Expand All @@ -115,7 +115,7 @@ public override bool Equals([NotNullWhen(true)] object? other)
return false;
}

public override string ToString()
public override readonly string ToString()
{
if (prefix.Length == 0)
return this.localname;
Expand Down Expand Up @@ -185,7 +185,7 @@ public void Set(QName n, int pos)
this.prevHash = 0;
}

public void GetLocalnameAndNamespaceUri(out string localname, out string namespaceUri)
public readonly void GetLocalnameAndNamespaceUri(out string localname, out string namespaceUri)
{
localname = this.name.localname;
namespaceUri = this.name.namespaceUri;
Expand All @@ -198,12 +198,12 @@ public int GetLocalnameAndNamespaceUriAndHash(out string localname, out string n
return this.hashCode = this.name.GetNSHashCode();
}

public bool MatchNS(string localname, string namespaceUri)
public readonly bool MatchNS(string localname, string namespaceUri)
{
return this.name.MatchNs(localname, namespaceUri);
}

public bool MatchHashNS(int hash, string localname, string namespaceUri)
public readonly bool MatchHashNS(int hash, string localname, string namespaceUri)
{
return this.hashCode == hash && this.name.MatchNs(localname, namespaceUri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,15 +807,15 @@ public void Init(int initialPageSize)
/// <summary>
/// Return the page on which the next node will be allocated.
/// </summary>
public XPathNode[] NextNodePage
public readonly XPathNode[] NextNodePage
{
get { return _page; }
}

/// <summary>
/// Return the page index that the next node will be given.
/// </summary>
public int NextNodeIndex
public readonly int NextNodeIndex
{
get { return _pageInfo.NodeCount; }
}
Expand Down Expand Up @@ -867,31 +867,31 @@ public void Initialize(IXmlLineInfo? lineInfo)
/// <summary>
/// Return the type of the cached text block.
/// </summary>
public TextBlockType TextType
public readonly TextBlockType TextType
{
get { return _textType; }
}

/// <summary>
/// Returns true if text has been cached.
/// </summary>
public bool HasText
public readonly bool HasText
{
get { return _textType != TextBlockType.None; }
}

/// <summary>
/// Returns the line number of the last text block to be cached.
/// </summary>
public int LineNumber
public readonly int LineNumber
{
get { return _lineNum; }
}

/// <summary>
/// Returns the line position of the last text block to be cached.
/// </summary>
public int LinePosition
public readonly int LinePosition
{
get { return _linePos; }
}
Expand Down
Loading