-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKnownTypes.cs
More file actions
32 lines (27 loc) · 1.05 KB
/
KnownTypes.cs
File metadata and controls
32 lines (27 loc) · 1.05 KB
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
using System.Linq;
using Microsoft.CodeAnalysis;
namespace StructId;
/// <summary>
/// Provides access to some common types and properties used in the compilation.
/// </summary>
/// <param name="Compilation">The compilation used to resolve the known types.</param>
public record KnownTypes(Compilation Compilation)
{
public string StructIdNamespace => IStructId?.ContainingNamespace.ToFullName() ?? "StructId";
/// <summary>
/// System.String
/// </summary>
public INamedTypeSymbol String { get; } = Compilation.GetTypeByMetadataName("System.String")!;
/// <summary>
/// StructId.IStructId
/// </summary>
public INamedTypeSymbol? IStructId { get; } = Compilation
.GetAllTypes(true)
.FirstOrDefault(x => x.MetadataName == "IStructId" && x.IsGeneratedByStructId());
/// <summary>
/// StructId.IStructId{T}
/// </summary>
public INamedTypeSymbol? IStructIdT { get; } = Compilation
.GetAllTypes(true)
.FirstOrDefault(x => x.MetadataName == "IStructId`1" && x.IsGeneratedByStructId());
}