/
Metadata.cs
63 lines (53 loc) · 2.01 KB
/
Metadata.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// An Id that can be used to identify a metadata instance. If two metadata instances
/// have the same id then they are guaranteed to have the same content. If two metadata
/// instances have different ids, then the contents may or may not be the same. As such,
/// the id is useful as a key in a cache when a client wants to share data for a metadata
/// reference as long as it has not changed.
/// </summary>
public sealed class MetadataId
{
private MetadataId()
{
}
internal static MetadataId CreateNewId() => new MetadataId();
}
/// <summary>
/// Represents immutable assembly or module CLI metadata.
/// </summary>
public abstract class Metadata : IDisposable
{
internal readonly bool IsImageOwner;
/// <summary>
/// The id for this metadata instance. If two metadata instances have the same id, then
/// they have the same content. If they have different ids they may or may not have the
/// same content.
/// </summary>
public MetadataId Id { get; }
internal Metadata(bool isImageOwner, MetadataId id)
{
this.IsImageOwner = isImageOwner;
this.Id = id;
}
/// <summary>
/// Retrieves the <see cref="MetadataImageKind"/> for this instance.
/// </summary>
public abstract MetadataImageKind Kind { get; }
/// <summary>
/// Releases any resources associated with this instance.
/// </summary>
public abstract void Dispose();
protected abstract Metadata CommonCopy();
/// <summary>
/// Creates a copy of this object.
/// </summary>
public Metadata Copy()
{
return CommonCopy();
}
}
}