protected override string InitializeCore(DbgEvaluationContext context, DbgStackFrame frame, CancellationToken cancellationToken) { if ((evalOptions & DbgValueNodeEvaluationOptions.NoFuncEval) != 0) { return(PredefinedEvaluationErrorMessages.FuncEvalDisabled); } var proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType); if ((object)proxyCtor == null) { var loadState = enumerableType.AppDomain.GetOrCreateData <ForceLoadAssemblyState>(); if (Interlocked.Exchange(ref loadState.Counter, 1) == 0) { var loader = new ReflectionAssemblyLoader(context, frame, enumerableType.AppDomain, cancellationToken); if (loader.TryLoadAssembly(GetRequiredAssemblyFullName(context.Runtime))) { proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType); } } if ((object)proxyCtor == null) { var asmFilename = GetRequiredAssemblyFilename(context.Runtime); var asm = enumerableType.AppDomain.GetAssembly(Path.GetFileNameWithoutExtension(asmFilename)); if (asm == null) { return(string.Format(dnSpy_Roslyn_Shared_Resources.SystemCoreDllNotLoaded, asmFilename)); } return(string.Format(dnSpy_Roslyn_Shared_Resources.TypeDoesNotExistInAssembly, EnumerableDebugViewHelper.GetDebugViewTypeDisplayName(enumerableType), asmFilename)); } } var runtime = context.Runtime.GetDotNetRuntime(); var proxyTypeResult = runtime.CreateInstance(context, frame, proxyCtor, new[] { instanceValue }, DbgDotNetInvokeOptions.None, cancellationToken); if (proxyTypeResult.HasError) { return(proxyTypeResult.ErrorMessage); } resultsViewProxyExpression = valueNodeProviderFactory.GetNewObjectExpression(proxyCtor, valueExpression); getResultsViewValue = proxyTypeResult.Value; valueNodeProviderFactory.GetMemberCollections(getResultsViewValue.Type, evalOptions, out membersCollection, out _); return(null); }
protected override string InitializeCore(DbgEvaluationContext context, DbgStackFrame frame, CancellationToken cancellationToken) { if ((evalOptions & DbgValueNodeEvaluationOptions.NoFuncEval) != 0) { return(PredefinedEvaluationErrorMessages.FuncEvalDisabled); } var proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType); if ((object)proxyCtor == null) { var loadState = enumerableType.AppDomain.GetOrCreateData <ForceLoadAssemblyState>(); if (Interlocked.Increment(ref loadState.Counter) == 1) { var loader = new ReflectionAssemblyLoader(context, frame, enumerableType.AppDomain, cancellationToken); if (loader.TryLoadAssembly(GetRequiredAssemblyFullName(context.Runtime))) { proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType); } } if ((object)proxyCtor == null) { return(string.Format(dnSpy_Roslyn_Shared_Resources.SystemCoreDllNotLoaded, GetRequiredAssemblyFileName(context.Runtime))); } } var runtime = context.Runtime.GetDotNetRuntime(); var proxyTypeResult = runtime.CreateInstance(context, frame, proxyCtor, new[] { instanceValue }, cancellationToken); if (proxyTypeResult.HasError) { return(proxyTypeResult.ErrorMessage); } getResultsViewValue = proxyTypeResult.Value; valueNodeProviderFactory.GetMemberCollections(getResultsViewValue.Type, evalOptions, out membersCollection, out _); return(null); }