Skip to content

Commit d9b7515

Browse files
authored
Make cdac APIs public but experimental (dotnet#111180)
1 parent a9d67ec commit d9b7515

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+191
-179
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<Import Project="..\Directory.Build.props" />
3+
<ItemGroup>
4+
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExperimentalAttribute">
5+
<_Parameter1>NETCDAC0001</_Parameter1>
6+
</AssemblyAttribute>
7+
</ItemGroup>
8+
</Project>

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/ContractRegistry.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.Diagnostics.DataContractReader;
99
/// <summary>
1010
/// A registry of all the contracts that may be provided by a target.
1111
/// </summary>
12-
internal abstract class ContractRegistry
12+
public abstract class ContractRegistry
1313
{
1414
/// <summary>
1515
/// Gets an instance of the Exception contract for the target.

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/Extensions/ICodeVersionsExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace Microsoft.Diagnostics.DataContractReader.Contracts.Extensions;
55

6-
internal static class ICodeVersionsExtensions
6+
public static class ICodeVersionsExtensions
77
{
8-
internal static NativeCodeVersionHandle GetActiveNativeCodeVersion(this ICodeVersions cv, TargetPointer methodDesc)
8+
public static NativeCodeVersionHandle GetActiveNativeCodeVersion(this ICodeVersions cv, TargetPointer methodDesc)
99
{
1010
ILCodeVersionHandle ilCodeVersionHandle = cv.GetActiveILCodeVersion(methodDesc);
1111
return cv.GetActiveNativeCodeVersionForILCodeVersion(methodDesc, ilCodeVersionHandle);

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/Extensions/IReJITExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts.Extensions;
77

8-
internal static class IReJITExtensions
8+
public static class IReJITExtensions
99
{
1010
public static IEnumerable<TargetNUInt> GetRejitIds(this IReJIT rejit, Target target, TargetPointer methodDesc)
1111
{

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ICodeVersions.cs

+17-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
88

9-
internal interface ICodeVersions : IContract
9+
public interface ICodeVersions : IContract
1010
{
1111
static string IContract.Name { get; } = nameof(CodeVersions);
1212

@@ -27,11 +27,12 @@ internal interface ICodeVersions : IContract
2727
public virtual bool CodeVersionManagerSupportsMethod(TargetPointer methodDesc) => throw new NotImplementedException();
2828
}
2929

30-
internal readonly struct ILCodeVersionHandle
30+
public readonly struct ILCodeVersionHandle
3131
{
32-
internal readonly TargetPointer Module;
33-
internal readonly uint MethodDefinition;
34-
internal readonly TargetPointer ILCodeVersionNode;
32+
// TODO-Layering: These members should be accessible only to contract implementations.
33+
public readonly TargetPointer Module;
34+
public readonly uint MethodDefinition;
35+
public readonly TargetPointer ILCodeVersionNode;
3536
private ILCodeVersionHandle(TargetPointer module, uint methodDef, TargetPointer ilCodeVersionNodeAddress)
3637
{
3738
if (module != TargetPointer.Null && ilCodeVersionNodeAddress != TargetPointer.Null)
@@ -49,23 +50,24 @@ private ILCodeVersionHandle(TargetPointer module, uint methodDef, TargetPointer
4950
}
5051

5152
// for more information on Explicit/Synthetic code versions see docs/design/features/code-versioning.md
52-
internal static ILCodeVersionHandle CreateExplicit(TargetPointer ilCodeVersionNodeAddress) =>
53+
public static ILCodeVersionHandle CreateExplicit(TargetPointer ilCodeVersionNodeAddress) =>
5354
new ILCodeVersionHandle(TargetPointer.Null, 0, ilCodeVersionNodeAddress);
54-
internal static ILCodeVersionHandle CreateSynthetic(TargetPointer module, uint methodDef) =>
55+
public static ILCodeVersionHandle CreateSynthetic(TargetPointer module, uint methodDef) =>
5556
new ILCodeVersionHandle(module, methodDef, TargetPointer.Null);
5657

5758
public static ILCodeVersionHandle Invalid { get; } = new(TargetPointer.Null, 0, TargetPointer.Null);
5859

5960
public bool IsValid => Module != TargetPointer.Null || ILCodeVersionNode != TargetPointer.Null;
6061

61-
internal bool IsExplicit => ILCodeVersionNode != TargetPointer.Null;
62+
public bool IsExplicit => ILCodeVersionNode != TargetPointer.Null;
6263
}
6364

64-
internal readonly struct NativeCodeVersionHandle
65+
public readonly struct NativeCodeVersionHandle
6566
{
6667
// no public constructors
67-
internal readonly TargetPointer MethodDescAddress;
68-
internal readonly TargetPointer CodeVersionNodeAddress;
68+
// TODO-Layering: These members should be accessible only to contract implementations.
69+
public readonly TargetPointer MethodDescAddress;
70+
public readonly TargetPointer CodeVersionNodeAddress;
6971
private NativeCodeVersionHandle(TargetPointer methodDescAddress, TargetPointer codeVersionNodeAddress)
7072
{
7173
if (methodDescAddress != TargetPointer.Null && codeVersionNodeAddress != TargetPointer.Null)
@@ -77,19 +79,19 @@ private NativeCodeVersionHandle(TargetPointer methodDescAddress, TargetPointer c
7779
}
7880

7981
// for more information on Explicit/Synthetic code versions see docs/design/features/code-versioning.md
80-
internal static NativeCodeVersionHandle CreateExplicit(TargetPointer codeVersionNodeAddress) =>
82+
public static NativeCodeVersionHandle CreateExplicit(TargetPointer codeVersionNodeAddress) =>
8183
new NativeCodeVersionHandle(TargetPointer.Null, codeVersionNodeAddress);
82-
internal static NativeCodeVersionHandle CreateSynthetic(TargetPointer methodDescAddress) =>
84+
public static NativeCodeVersionHandle CreateSynthetic(TargetPointer methodDescAddress) =>
8385
new NativeCodeVersionHandle(methodDescAddress, TargetPointer.Null);
8486

8587
public static NativeCodeVersionHandle Invalid { get; } = new(TargetPointer.Null, TargetPointer.Null);
8688

8789
public bool Valid => MethodDescAddress != TargetPointer.Null || CodeVersionNodeAddress != TargetPointer.Null;
8890

89-
internal bool IsExplicit => CodeVersionNodeAddress != TargetPointer.Null;
91+
public bool IsExplicit => CodeVersionNodeAddress != TargetPointer.Null;
9092
}
9193

92-
internal readonly struct CodeVersions : ICodeVersions
94+
public readonly struct CodeVersions : ICodeVersions
9395
{
9496
// throws NotImplementedException for all methods
9597
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IContract.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
77

8-
internal interface IContract
8+
public interface IContract
99
{
1010
static virtual string Name => throw new NotImplementedException();
1111
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IDacStreams.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
77

8-
internal interface IDacStreams : IContract
8+
public interface IDacStreams : IContract
99
{
1010
static string IContract.Name { get; } = nameof(DacStreams);
1111
public virtual string? StringFromEEAddress(TargetPointer address) => throw new NotImplementedException();
1212
}
1313

14-
internal readonly struct DacStreams : IDacStreams
14+
public readonly struct DacStreams : IDacStreams
1515
{
1616
// Everything throws NotImplementedException
1717
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IEcmaMetadata.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
88

9-
internal interface IEcmaMetadata : IContract
9+
public interface IEcmaMetadata : IContract
1010
{
1111
static string IContract.Name { get; } = nameof(EcmaMetadata);
1212
public virtual TargetSpan GetReadOnlyMetadataAddress(ModuleHandle handle) => throw new NotImplementedException();
1313
public virtual MetadataReader? GetMetadata(ModuleHandle module) => throw new NotImplementedException();
1414
}
1515

16-
internal readonly struct EcmaMetadata : IEcmaMetadata
16+
public readonly struct EcmaMetadata : IEcmaMetadata
1717
{
1818
// Everything throws NotImplementedException
1919
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IException.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
77

8-
internal record struct ExceptionData(
8+
public record struct ExceptionData(
99
TargetPointer Message,
1010
TargetPointer InnerException,
1111
TargetPointer StackTrace,
@@ -15,15 +15,15 @@ internal record struct ExceptionData(
1515
int HResult,
1616
int XCode);
1717

18-
internal interface IException : IContract
18+
public interface IException : IContract
1919
{
2020
static string IContract.Name { get; } = nameof(Exception);
2121

2222
public virtual TargetPointer GetNestedExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) => throw new NotImplementedException();
2323
public virtual ExceptionData GetExceptionData(TargetPointer managedException) => throw new NotImplementedException();
2424
}
2525

26-
internal readonly struct Exception : IException
26+
public readonly struct Exception : IException
2727
{
2828
// Everything throws NotImplementedException
2929
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IExecutionManager.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
77

8-
internal struct CodeBlockHandle
8+
public struct CodeBlockHandle
99
{
10+
// TODO-Layering: These members should be accessible only to contract implementations.
1011
public readonly TargetPointer Address;
11-
internal CodeBlockHandle(TargetPointer address) => Address = address;
12+
public CodeBlockHandle(TargetPointer address) => Address = address;
1213
}
1314

14-
internal interface IExecutionManager : IContract
15+
public interface IExecutionManager : IContract
1516
{
1617
static string IContract.Name { get; } = nameof(ExecutionManager);
1718
CodeBlockHandle? GetCodeBlockHandle(TargetCodePointer ip) => throw new NotImplementedException();
1819
TargetPointer GetMethodDesc(CodeBlockHandle codeInfoHandle) => throw new NotImplementedException();
1920
TargetCodePointer GetStartAddress(CodeBlockHandle codeInfoHandle) => throw new NotImplementedException();
2021
}
2122

22-
internal readonly struct ExecutionManager : IExecutionManager
23+
public readonly struct ExecutionManager : IExecutionManager
2324
{
2425

2526
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66

77
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
88

9-
internal readonly struct ModuleHandle
9+
public readonly struct ModuleHandle
1010
{
11-
internal ModuleHandle(TargetPointer address)
11+
public ModuleHandle(TargetPointer address)
1212
{
1313
Address = address;
1414
}
1515

16-
internal TargetPointer Address { get; }
16+
public TargetPointer Address { get; }
1717
}
1818

1919
[Flags]
20-
internal enum ModuleFlags
20+
public enum ModuleFlags
2121
{
2222
EditAndContinue = 0x00000008, // Edit and Continue is enabled for this module
2323
ReflectionEmit = 0x00000040, // Reflection.Emit was used to create this module
2424
}
2525

26-
internal record struct ModuleLookupTables(
26+
public record struct ModuleLookupTables(
2727
TargetPointer FieldDefToDesc,
2828
TargetPointer ManifestModuleReferences,
2929
TargetPointer MemberRefToDesc,
@@ -32,7 +32,7 @@ internal record struct ModuleLookupTables(
3232
TargetPointer TypeRefToMethodTable,
3333
TargetPointer MethodDefToILCodeVersioningState);
3434

35-
internal interface ILoader : IContract
35+
public interface ILoader : IContract
3636
{
3737
static string IContract.Name => nameof(Loader);
3838

@@ -52,7 +52,7 @@ internal interface ILoader : IContract
5252
public virtual bool IsCollectible(ModuleHandle handle) => throw new NotImplementedException();
5353
}
5454

55-
internal readonly struct Loader : ILoader
55+
public readonly struct Loader : ILoader
5656
{
5757
// Everything throws NotImplementedException
5858
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IObject.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
77

8-
internal interface IObject : IContract
8+
public interface IObject : IContract
99
{
1010
static string IContract.Name { get; } = nameof(Object);
1111
public virtual TargetPointer GetMethodTableAddress(TargetPointer address) => throw new NotImplementedException();
@@ -14,7 +14,7 @@ internal interface IObject : IContract
1414
public virtual bool GetBuiltInComData(TargetPointer address, out TargetPointer rcw, out TargetPointer ccw) => throw new NotImplementedException();
1515
}
1616

17-
internal readonly struct Object : IObject
17+
public readonly struct Object : IObject
1818
{
1919
// Everything throws NotImplementedException
2020
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IPlatformMetadata.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
77

8-
internal enum CodePointerFlags : byte
8+
public enum CodePointerFlags : byte
99
{
1010
HasArm32ThumbBit = 0x1,
1111
HasArm64PtrAuth = 0x2,
1212
}
1313

14-
internal interface IPlatformMetadata : IContract
14+
public interface IPlatformMetadata : IContract
1515
{
1616
static string IContract.Name { get; } = nameof(PlatformMetadata);
1717
TargetPointer GetPrecodeMachineDescriptor() => throw new NotImplementedException();
1818
CodePointerFlags GetCodePointerFlags() => throw new NotImplementedException();
1919
}
2020

21-
internal readonly struct PlatformMetadata : IPlatformMetadata
21+
public readonly struct PlatformMetadata : IPlatformMetadata
2222
{
2323

2424
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IPrecodeStubs.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
77

8-
internal interface IPrecodeStubs : IContract
8+
public interface IPrecodeStubs : IContract
99
{
1010
static string IContract.Name { get; } = nameof(PrecodeStubs);
1111
TargetPointer GetMethodDescFromStubAddress(TargetCodePointer entryPoint) => throw new NotImplementedException();
1212
}
1313

14-
internal readonly struct PrecodeStubs : IPrecodeStubs
14+
public readonly struct PrecodeStubs : IPrecodeStubs
1515
{
1616

1717
}

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IReJIT.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public enum RejitState
1212
Active
1313
}
1414

15-
internal interface IReJIT : IContract
15+
public interface IReJIT : IContract
1616
{
1717
static string IContract.Name { get; } = nameof(ReJIT);
1818

@@ -23,7 +23,7 @@ internal interface IReJIT : IContract
2323
TargetNUInt GetRejitId(ILCodeVersionHandle codeVersionHandle) => throw new NotImplementedException();
2424
}
2525

26-
internal readonly struct ReJIT : IReJIT
26+
public readonly struct ReJIT : IReJIT
2727
{
2828

2929
}

0 commit comments

Comments
 (0)