/// <summary> /// Gets the <see cref="IDbgDotNetRuntime"/> instance or throws if it's not a .NET runtime /// </summary> /// <param name="runtime">Runtime</param> /// <returns></returns> public static IDbgDotNetRuntime GetDotNetRuntime(this DbgRuntime runtime) { var dnRuntime = runtime.InternalRuntime as IDbgDotNetRuntime; Debug.Assert(dnRuntime != null); if (dnRuntime == null) { throw new InvalidOperationException(nameof(DbgRuntime.InternalRuntime) + " must implement " + nameof(IDbgDotNetRuntime)); } return(dnRuntime); }
/// <summary> /// Returns true if <paramref name="runtime"/> is a .NET runtime /// </summary> /// <param name="runtime">Runtime</param> /// <returns></returns> public static bool IsDotNetRuntime(this DbgRuntime runtime) => runtime.Tags.Any(a => StringComparer.Ordinal.Equals(PredefinedDotNetDbgRuntimeTags.DotNet, a));
/// <summary> /// Gets the internal .NET runtime or null if it's not a managed runtime /// </summary> /// <param name="runtime"></param> /// <returns></returns> public static DbgDotNetInternalRuntime?GetDotNetInternalRuntime(this DbgRuntime runtime) => runtime.InternalRuntime as DbgDotNetInternalRuntime;
/// <summary> /// Gets the reflection runtime or null if this isn't a managed runtime /// </summary> /// <param name="runtime">Debugger runtime</param> /// <returns></returns> public static DmdRuntime?GetReflectionRuntime(this DbgRuntime runtime) => (runtime.InternalRuntime as DbgDotNetInternalRuntime)?.ReflectionRuntime;