未验证 提交 25689c69 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #46031 from sharwell/non-copyable-name

Make MetadataTypeName non-copyable
......@@ -23,7 +23,7 @@ public struct Key : IEquatable<Key>
private readonly byte _useCLSCompliantNameArityEncoding; // Using byte instead of bool for denser packing and smaller structure size
private readonly short _forcedArity;
internal Key(MetadataTypeName mdTypeName)
internal Key(in MetadataTypeName mdTypeName)
{
if (mdTypeName.IsNull)
{
......@@ -113,9 +113,9 @@ private int GetHashCodeName()
}
}
public Key ToKey()
public readonly Key ToKey()
{
return new Key(this);
return new Key(in this);
}
}
}
......@@ -15,6 +15,7 @@ namespace Microsoft.CodeAnalysis
/// Also, allows us to stop using strings in the APIs that accept only metadata names,
/// making usage of them less bug prone.
/// </summary>
[NonCopyable]
internal partial struct MetadataTypeName
{
/// <summary>
......@@ -244,7 +245,7 @@ public bool IsMangled
/// I.e. arity is inferred from the name and matching type must have the same
/// emitted name and arity.
/// </summary>
public bool UseCLSCompliantNameArityEncoding
public readonly bool UseCLSCompliantNameArityEncoding
{
get
{
......@@ -258,7 +259,7 @@ public bool UseCLSCompliantNameArityEncoding
/// If ForcedArity >= 0 and UseCLSCompliantNameArityEncoding, lookup may
/// fail because ForcedArity doesn't match the one encoded in the name.
/// </summary>
public int ForcedArity
public readonly int ForcedArity
{
get
{
......@@ -282,7 +283,7 @@ public ImmutableArray<string> NamespaceSegments
}
}
public bool IsNull
public readonly bool IsNull
{
get
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册