File: Data\InteropSyncBlockInfo.cs
Web Access
Project: src\src\runtime\src\native\managed\cdac\Microsoft.Diagnostics.DataContractReader.Contracts\Microsoft.Diagnostics.DataContractReader.Contracts.csproj (Microsoft.Diagnostics.DataContractReader.Contracts)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Diagnostics.DataContractReader.Data;

internal sealed class InteropSyncBlockInfo : IData<InteropSyncBlockInfo>
{
    static InteropSyncBlockInfo IData<InteropSyncBlockInfo>.Create(Target target, TargetPointer address)
        => new InteropSyncBlockInfo(target, address);

    public InteropSyncBlockInfo(Target target, TargetPointer address)
    {
        Target.TypeInfo type = target.GetTypeInfo(DataType.InteropSyncBlockInfo);

        RCW = type.Fields.TryGetValue(nameof(RCW), out Target.FieldInfo rcwField)
            ? target.ReadPointer(address + (ulong)rcwField.Offset)
            : TargetPointer.Null;
        CCW = type.Fields.TryGetValue(nameof(CCW), out Target.FieldInfo ccwField)
            ? target.ReadPointer(address + (ulong)ccwField.Offset)
            : TargetPointer.Null;
        CCF = type.Fields.TryGetValue(nameof(CCF), out Target.FieldInfo ccfField)
            ? target.ReadPointer(address + (ulong)ccfField.Offset)
            : TargetPointer.Null;
        TaggedMemory = type.Fields.TryGetValue(nameof(TaggedMemory), out Target.FieldInfo taggedMemoryField)
            ? target.ReadPointer(address + (ulong)taggedMemoryField.Offset)
            : TargetPointer.Null;
    }

    public TargetPointer RCW { get; init; }
    public TargetPointer CCW { get; init; }
    public TargetPointer CCF { get; init; }
    public TargetPointer TaggedMemory { get; init; }
}