internal DkmClrType(DkmClrModuleInstance module, DkmClrAppDomain appDomain, Type lmrType) { _module = module; _appDomain = appDomain; _lmrType = lmrType; _evalAttributes = GetEvalAttributes(lmrType); }
internal override EvaluationContextBase CreateTypeContext( DkmClrAppDomain appDomain, ImmutableArray<MetadataBlock> metadataBlocks, Guid moduleVersionId, int typeToken, bool useReferencedModulesOnly) { if (useReferencedModulesOnly) { // Avoid using the cache for referenced assemblies only // since this should be the exceptional case. var compilation = metadataBlocks.ToCompilationReferencedModulesOnly(moduleVersionId); return EvaluationContext.CreateTypeContext( compilation, moduleVersionId, typeToken); } var previous = appDomain.GetMetadataContext<CSharpMetadataContext>(); var context = EvaluationContext.CreateTypeContext( previous, metadataBlocks, moduleVersionId, typeToken); // New type context is not attached to the AppDomain since it is less // re-usable than the previous attached method context. (We could hold // on to it if we don't have a previous method context but it's unlikely // that we evaluated a type-level expression before a method-level.) Debug.Assert(context != previous.EvaluationContext); return context; }
internal override EvaluationContextBase CreateMethodContext( DkmClrAppDomain appDomain, ImmutableArray<MetadataBlock> metadataBlocks, Lazy<ImmutableArray<AssemblyReaders>> unusedLazyAssemblyReaders, object symReader, Guid moduleVersionId, int methodToken, int methodVersion, int ilOffset, int localSignatureToken) { var previous = appDomain.GetDataItem<CSharpMetadataContext>(); var context = EvaluationContext.CreateMethodContext( previous, metadataBlocks, symReader, moduleVersionId, methodToken, methodVersion, ilOffset, localSignatureToken); if (previous == null || context != previous.EvaluationContext) { appDomain.SetDataItem(DkmDataCreationDisposition.CreateAlways, new CSharpMetadataContext(context)); } return context; }
internal override string GetArrayDisplayString(DkmClrAppDomain appDomain, Type lmrType, ReadOnlyCollection<int> sizes, ReadOnlyCollection<int> lowerBounds, ObjectDisplayOptions options) { Debug.Assert(lmrType.IsArray); Type originalLmrType = lmrType; // Strip off all array types. We'll process them at the end. while (lmrType.IsArray) { lmrType = lmrType.GetElementType(); } var pooled = PooledStringBuilder.GetInstance(); var builder = pooled.Builder; builder.Append('{'); // We're showing the type of a value, so "dynamic" does not apply. bool unused; builder.Append(GetTypeName(new TypeAndCustomInfo(DkmClrType.Create(appDomain, lmrType)), escapeKeywordIdentifiers: false, sawInvalidIdentifier: out unused)); // NOTE: call our impl directly, since we're coupled anyway. var numSizes = sizes.Count; builder.Append('['); for (int i = 0; i < numSizes; i++) { if (i > 0) { builder.Append(", "); } var lowerBound = lowerBounds[i]; var size = sizes[i]; if (lowerBound == 0) { builder.Append(FormatLiteral(size, options)); } else { builder.Append(FormatLiteral(lowerBound, options)); builder.Append(".."); builder.Append(FormatLiteral(size + lowerBound - 1, options)); } } builder.Append(']'); lmrType = originalLmrType.GetElementType(); // Strip off one layer (already handled). while (lmrType.IsArray) { builder.Append('['); builder.Append(',', lmrType.GetArrayRank() - 1); builder.Append(']'); lmrType = lmrType.GetElementType(); } builder.Append('}'); return pooled.ToStringAndFree(); }
internal DkmClrType( DkmClrModuleInstance module, DkmClrAppDomain appDomain, Type lmrType, DkmClrObjectFavoritesInfo favorites = null ) { _module = module; _appDomain = appDomain; _lmrType = lmrType; _evalAttributes = GetEvalAttributes(lmrType); _favorites = favorites; }
internal DkmClrRuntimeInstance( Assembly[] assemblies, GetModuleDelegate getModule = null, GetMemberValueDelegate getMemberValue = null, bool enableNativeDebugging = false) : base(enableNativeDebugging) { getModule ??= (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null); this.Assemblies = assemblies; this.Modules = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray(); _defaultModule = getModule(this, null); _appDomain = new DkmClrAppDomain(this); this.GetMemberValue = getMemberValue; }
internal DkmClrRuntimeInstance( Assembly[] assemblies, GetModuleDelegate getModule = null, GetMemberValueDelegate getMemberValue = null) { if (getModule == null) { getModule = (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null); } this.Assemblies = assemblies; this.Modules = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray(); _defaultModule = getModule(this, null); _appDomain = new DkmClrAppDomain(this); _getMemberValue = getMemberValue; }
internal DkmClrRuntimeInstance( Assembly[] assemblies, GetModuleDelegate getModule = null, GetMemberValueDelegate getMemberValue = null) { if (getModule == null) { getModule = (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null); } this.Assemblies = assemblies; this.Modules = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray(); _defaultModule = getModule(this, null); _appDomain = new DkmClrAppDomain(this); _getMemberValue = getMemberValue; }
internal override EvaluationContextBase CreateMethodContext( DkmClrAppDomain appDomain, ImmutableArray<MetadataBlock> metadataBlocks, Lazy<ImmutableArray<AssemblyReaders>> unusedLazyAssemblyReaders, object symReader, Guid moduleVersionId, int methodToken, int methodVersion, uint ilOffset, int localSignatureToken, bool useReferencedModulesOnly) { if (useReferencedModulesOnly) { // Avoid using the cache for referenced assemblies only // since this should be the exceptional case. var compilation = metadataBlocks.ToCompilationReferencedModulesOnly(moduleVersionId); return EvaluationContext.CreateMethodContext( compilation, symReader, moduleVersionId, methodToken, methodVersion, ilOffset, localSignatureToken); } var previous = appDomain.GetMetadataContext<CSharpMetadataContext>(); var context = EvaluationContext.CreateMethodContext( previous, metadataBlocks, symReader, moduleVersionId, methodToken, methodVersion, ilOffset, localSignatureToken); if (context != previous.EvaluationContext) { appDomain.SetMetadataContext(new CSharpMetadataContext(metadataBlocks, context)); } return context; }
internal override EvaluationContextBase CreateTypeContext( DkmClrAppDomain appDomain, ImmutableArray<MetadataBlock> metadataBlocks, Guid moduleVersionId, int typeToken) { var previous = appDomain.GetDataItem<CSharpMetadataContext>(); var context = EvaluationContext.CreateTypeContext( appDomain.GetDataItem<CSharpMetadataContext>(), metadataBlocks, moduleVersionId, typeToken); // New type context is not attached to the AppDomain since it is less // re-usable than the previous attached method context. (We could hold // on to it if we don't have a previous method context but it's unlikely // that we evaluated a type-level expression before a method-level.) Debug.Assert(previous == null || context != previous.EvaluationContext); return context; }
internal override void RemoveDataItem(DkmClrAppDomain appDomain) { appDomain.RemoveMetadataContext<CSharpMetadataContext>(); }
public static DkmClrType Create(DkmClrAppDomain appDomain, Type type) { return(new DkmClrType(appDomain.RuntimeInstance.DefaultModule, appDomain, type)); }
private static DkmClrModuleInstance GetModule(DkmClrAppDomain appDomain, string moduleName) { var modules = appDomain.GetClrModuleInstances(); foreach (var module in modules) { if (string.Equals(module.Name, moduleName, StringComparison.OrdinalIgnoreCase)) { return module; } } return null; }
internal override bool RemoveDataItem(DkmClrAppDomain appDomain) { return appDomain.RemoveDataItem<CSharpMetadataContext>(); }
public static DkmClrType Create(DkmClrAppDomain appDomain, Type type) { return new DkmClrType(appDomain.RuntimeInstance.DefaultModule, appDomain, type); }
internal abstract string GetArrayDisplayString(DkmClrAppDomain appDomain, Type lmrType, ReadOnlyCollection<int> sizes, ReadOnlyCollection<int> lowerBounds, ObjectDisplayOptions options);
private static bool ShouldTryAgainWithMoreMetadataBlocks(DkmClrAppDomain appDomain, ImmutableArray<AssemblyIdentity> missingAssemblyIdentities, ref ImmutableArray<MetadataBlock> references) { return ShouldTryAgainWithMoreMetadataBlocks( (AssemblyIdentity assemblyIdentity, out uint size) => appDomain.GetMetaDataBytesPtr(assemblyIdentity.GetDisplayName(), out size), missingAssemblyIdentities, ref references); }
private static TypeAndCustomInfo GetTupleFieldTypeAndInfo( DkmClrAppDomain appDomain, FieldInfo field, CustomTypeInfoTypeArgumentMap customTypeInfoMap) { var declaringTypeDef = field.DeclaringType.GetGenericTypeDefinition(); var fieldDef = declaringTypeDef.GetTupleField(field.Name); var fieldType = DkmClrType.Create(appDomain, field.FieldType); var fieldTypeInfo = customTypeInfoMap.SubstituteCustomTypeInfo(fieldDef.FieldType, null); return new TypeAndCustomInfo(fieldType, fieldTypeInfo); }
internal abstract EvaluationContextBase CreateTypeContext( DkmClrAppDomain appDomain, ImmutableArray<MetadataBlock> metadataBlocks, Guid moduleVersionId, int typeToken);
internal abstract EvaluationContextBase CreateMethodContext( DkmClrAppDomain appDomain, ImmutableArray<MetadataBlock> metadataBlocks, Lazy<ImmutableArray<AssemblyReaders>> lazyAssemblyReaders, object symReader, Guid moduleVersionId, int methodToken, int methodVersion, int ilOffset, int localSignatureToken);
internal abstract bool RemoveDataItem(DkmClrAppDomain appDomain);