public WellKnownMemberResolver(DmdAppDomain appDomain)
 {
     lockObj        = new object();
     checkedModules = new HashSet <DmdModule>();
     this.appDomain = appDomain ?? throw new ArgumentNullException(nameof(appDomain));
     wellKnownTypes = new DmdType[WELL_KNOWN_TYPES_COUNT];
 }
 public ReflectionAssemblyLoader(DbgEvaluationContext context, DbgStackFrame frame, DmdAppDomain appDomain, CancellationToken cancellationToken)
 {
     this.context           = context;
     this.frame             = frame;
     this.appDomain         = appDomain;
     this.cancellationToken = cancellationToken;
 }
Beispiel #3
0
 public EvalArgumentConverter(DbgEngineImpl engine, FuncEval funcEval, AppDomainMirror appDomain, DmdAppDomain reflectionAppDomain)
 {
     this.engine              = engine;
     this.funcEval            = funcEval;
     this.appDomain           = appDomain;
     this.reflectionAppDomain = reflectionAppDomain;
 }
Beispiel #4
0
 public static TypeCache GetOrCreate(DmdAppDomain reflectionAppDomain)
 {
     if (reflectionAppDomain.TryGetData(out TypeCache? typeCache))
     {
         return(typeCache);
     }
     return(GetOrCreateTypeCacheCore(reflectionAppDomain));
        internal DbgDotNetValue CreateDotNetValue_CorDebug(CorValue value, DmdAppDomain reflectionAppDomain, bool tryCreateStrongHandle, bool closeOnContinue = true)
        {
            debuggerThread.VerifyAccess();
            if (value is null)
            {
                return(new SyntheticValue(reflectionAppDomain.System_Void, new DbgDotNetRawValue(DbgSimpleValueType.Void)));
            }

            try {
                var type = new ReflectionTypeCreator(this, reflectionAppDomain).Create(value.ExactType);

                if (tryCreateStrongHandle && !value.IsNull && !value.IsHandle && value.IsReference && !type.IsPointer && !type.IsFunctionPointer && !type.IsByRef)
                {
                    var derefValue   = value.GetDereferencedValue(out int hr);
                    var strongHandle = derefValue?.CreateHandle(CorDebugHandleType.HANDLE_STRONG);
                    Debug2.Assert(derefValue is null || !(strongHandle is null) || type == type.AppDomain.System_TypedReference);
                    if (!(strongHandle is null))
                    {
                        value = strongHandle;
                    }
                }

                var dnValue = new DbgDotNetValueImpl(this, new DbgCorValueHolder(this, value, type));
                if (closeOnContinue)
                {
                    lock (lockObj)
                        dotNetValuesToCloseOnContinue.Add(dnValue);
                }
                return(dnValue);
            }
            catch {
                dnDebugger.DisposeHandle(value);
                throw;
            }
        }
        internal DbgDotNetValue CreateDotNetValue_MonoDebug(DmdAppDomain reflectionAppDomain, Value value, DmdType realTypeOpt)
        {
            debuggerThread.VerifyAccess();
            if (value == null)
            {
                return(new SyntheticNullValue(realTypeOpt ?? reflectionAppDomain.System_Object));
            }
            DmdType type;

            if (value is PrimitiveValue pv)
            {
                type = MonoValueTypeCreator.CreateType(this, value, reflectionAppDomain.System_Object);
            }
            else if (value is StructMirror sm)
            {
                type = GetReflectionType(reflectionAppDomain, sm.Type, realTypeOpt);
            }
            else
            {
                Debug.Assert(value is ObjectMirror);
                type = GetReflectionType(reflectionAppDomain, ((ObjectMirror)value).Type, realTypeOpt);
            }
            var valueLocation = new NoValueLocation(type, value);

            return(CreateDotNetValue_MonoDebug(valueLocation));
        }
 public ReflectionTypeCreator(DbgEngineImpl engine, DmdAppDomain reflectionAppDomain)
 {
     this.engine = engine;
     this.reflectionAppDomain = reflectionAppDomain;
     typesList        = null;
     recursionCounter = 0;
 }
Beispiel #8
0
 public WellKnownMemberResolver(DmdAppDomain appDomain)
 {
     lockObj        = new object();
     checkedModules = new HashSet <DmdModule>();
     this.appDomain = appDomain ?? throw new ArgumentNullException(nameof(appDomain));
     wellKnownTypes = new DmdType[DmdWellKnownTypeUtils.WellKnownTypesCount];
 }
Beispiel #9
0
 public static DmdType ToDmdType(Type type, DmdAppDomain appDomain)
 {
     if ((object)type == null)
     {
         return(null);
     }
     return(appDomain.GetTypeThrow(type));
 }
 public DmdFunctionPointerType(DmdAppDomain appDomain, DmdMethodSignature methodSignature, IList <DmdCustomModifier> customModifiers) : base(customModifiers)
 {
     AppDomain            = appDomain ?? throw new ArgumentNullException(nameof(appDomain));
     this.methodSignature = methodSignature ?? throw new ArgumentNullException(nameof(methodSignature));
     IsFullyResolved      = ((DmdTypeBase)methodSignature.ReturnType).IsFullyResolved &&
                            DmdTypeUtilities.IsFullyResolved(methodSignature.GetParameterTypes()) &&
                            DmdTypeUtilities.IsFullyResolved(methodSignature.GetVarArgsParameterTypes());
 }
Beispiel #11
0
 public static DmdType?ToDmdType(Type?type, DmdAppDomain appDomain)
 {
     if (type is null)
     {
         return(null);
     }
     return(appDomain.GetTypeThrow(type));
 }
Beispiel #12
0
 public EvalArgumentConverter(DbgEngineImpl engine, DnEval dnEval, CorAppDomain appDomain, DmdAppDomain reflectionAppDomain, List <CorValue> createdValues)
 {
     this.engine              = engine;
     this.dnEval              = dnEval;
     this.appDomain           = appDomain;
     this.reflectionAppDomain = reflectionAppDomain;
     this.createdValues       = createdValues;
 }
Beispiel #13
0
        ModuleContext CreateModuleContext(DmdAppDomain appDomain)
        {
            var context = new ModuleContext();

            context.AssemblyResolver = new DnlibAssemblyResolverImpl(this, appDomain);
            context.Resolver         = new Resolver(context.AssemblyResolver);
            return(context);
        }
Beispiel #14
0
 public static DmdType[]? ToDmdType(this IList <Type>?types, DmdAppDomain appDomain)
 {
     if (types is null)
     {
         return(null);
     }
     return(ToDmdTypeNoNull(types, appDomain));
 }
Beispiel #15
0
 public static DmdType ToDmdTypeNoNull(Type type, DmdAppDomain appDomain)
 {
     if (type is null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     return(appDomain.GetTypeThrow(type));
 }
Beispiel #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="appDomain">AppDomain</param>
 /// <param name="value">Value</param>
 public ConstantInt32ILValue(DmdAppDomain appDomain, int value)
 {
     if (appDomain == null)
     {
         throw new ArgumentNullException(nameof(appDomain));
     }
     Type  = appDomain.System_Int32;
     Value = value;
 }
 static string GetRequiredAssemblyFileName(DmdAppDomain appDomain)
 {
     // Check if it's .NET Core
     if (StringComparer.OrdinalIgnoreCase.Equals(appDomain.CorLib.GetName().Name, "System.Private.CoreLib"))
     {
         return("System.Linq.dll");
     }
     return("System.Core.dll");
 }
Beispiel #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="appDomain">AppDomain</param>
 /// <param name="value">Value</param>
 public ConstantInt64ILValue(DmdAppDomain appDomain, long value)
 {
     if (appDomain is null)
     {
         throw new ArgumentNullException(nameof(appDomain));
     }
     Type  = appDomain.System_Int64;
     Value = value;
 }
Beispiel #19
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="appDomain">AppDomain</param>
 /// <param name="value">Value</param>
 public ConstantFloatILValue(DmdAppDomain appDomain, double value)
 {
     if (appDomain is null)
     {
         throw new ArgumentNullException(nameof(appDomain));
     }
     Type  = appDomain.System_Double;
     Value = value;
 }
Beispiel #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="appDomain">AppDomain</param>
 /// <param name="value">Value</param>
 protected ConstantNativeIntILValue(DmdAppDomain appDomain, long value)
 {
     if (appDomain is null)
     {
         throw new ArgumentNullException(nameof(appDomain));
     }
     Type       = appDomain.System_IntPtr;
     this.value = value;
 }
Beispiel #21
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="appDomain">AppDomain</param>
 /// <param name="size">Size of memory</param>
 public NativeMemoryILValue(DmdAppDomain appDomain, int size)
 {
     if (appDomain is null)
     {
         throw new ArgumentNullException(nameof(appDomain));
     }
     Type = appDomain.System_Void.MakePointerType();
     data = new byte[size];
 }
Beispiel #22
0
 public ReflectionTypeCreator(DbgEngineImpl engine, DmdAppDomain reflectionAppDomain)
 {
     Debug.Assert(engine.CheckMonoDebugThread());
     this.engine = engine;
     this.reflectionAppDomain = reflectionAppDomain;
     typeCache        = TypeCache.GetOrCreate(reflectionAppDomain);
     typesList        = null;
     recursionCounter = 0;
 }
Beispiel #23
0
        public static DbgDotNetValue TryCreateSyntheticValue(DmdAppDomain appDomain, object constant)
        {
            var type = TryGetType(appDomain, constant);

            if ((object)type != null)
            {
                return(TryCreateSyntheticValue(type, constant));
            }
            return(null);
        }
Beispiel #24
0
 public DynamicViewMembersValueNodeProvider(DbgDotNetValueNodeProviderFactory valueNodeProviderFactory, LanguageValueNodeFactory valueNodeFactory, DbgDotNetValue instanceValue, DmdType expectedType, string valueExpression, DmdAppDomain appDomain, DbgValueNodeEvaluationOptions evalOptions)
     : base(valueNodeFactory, dynamicViewName, valueExpression + ", " + PredefinedFormatSpecifiers.DynamicView, default, evalOptions)
 {
     this.valueNodeProviderFactory = valueNodeProviderFactory;
     this.instanceValue            = instanceValue;
     this.expectedType             = expectedType;
     this.valueExpression          = valueExpression;
     this.appDomain             = appDomain;
     dynamicViewProxyExpression = string.Empty;
 }
Beispiel #25
0
        static MethodCache GetOrCreate(DmdAppDomain reflectionAppDomain)
        {
            if (reflectionAppDomain.TryGetData(out MethodCache methodCache))
            {
                return(methodCache);
            }
            return(GetOrCreateMethodCacheCore(reflectionAppDomain));

            MethodCache GetOrCreateMethodCacheCore(DmdAppDomain reflectionAppDomain2) =>
            reflectionAppDomain2.GetOrCreateData(() => new MethodCache(reflectionAppDomain2));
        }
Beispiel #26
0
        public static TypeCache GetOrCreate(DmdAppDomain reflectionAppDomain)
        {
            if (reflectionAppDomain.TryGetData(out TypeCache typeCache))
            {
                return(typeCache);
            }
            return(GetOrCreateTypeCacheCore(reflectionAppDomain));

            TypeCache GetOrCreateTypeCacheCore(DmdAppDomain reflectionAppDomain2) =>
            reflectionAppDomain2.GetOrCreateData(() => new TypeCache());
        }
        static DmdType TryGetType(DmdAppDomain appDomain, object value)
        {
            if (value == null)
            {
                return(null);
            }

            var type = value.GetType();

            switch (Type.GetTypeCode(type))
            {
            case TypeCode.Boolean:          return(appDomain.System_Boolean);

            case TypeCode.Char:                     return(appDomain.System_Char);

            case TypeCode.SByte:            return(appDomain.System_SByte);

            case TypeCode.Byte:                     return(appDomain.System_Byte);

            case TypeCode.Int16:            return(appDomain.System_Int16);

            case TypeCode.UInt16:           return(appDomain.System_UInt16);

            case TypeCode.Int32:            return(appDomain.System_Int32);

            case TypeCode.UInt32:           return(appDomain.System_UInt32);

            case TypeCode.Int64:            return(appDomain.System_Int64);

            case TypeCode.UInt64:           return(appDomain.System_UInt64);

            case TypeCode.Single:           return(appDomain.System_Single);

            case TypeCode.Double:           return(appDomain.System_Double);

            case TypeCode.Decimal:          return(appDomain.System_Decimal);

            case TypeCode.DateTime:         return(appDomain.System_DateTime);

            case TypeCode.String:           return(appDomain.System_String);
            }
            if (type == typeof(IntPtr))
            {
                return(appDomain.System_IntPtr);
            }
            if (type == typeof(UIntPtr))
            {
                return(appDomain.System_UIntPtr);
            }

            return(null);
        }
        internal DbgDotNetValue CreateDotNetValue_MonoDebug(DmdAppDomain reflectionAppDomain, Value value, DmdType?realTypeOpt)
        {
            debuggerThread.VerifyAccess();
            if (value is null)
            {
                return(new SyntheticNullValue(realTypeOpt ?? reflectionAppDomain.System_Object));
            }
            DmdType type;

            if (value is PrimitiveValue pv || value is PointerValue ptr)
            {
                type = MonoValueTypeCreator.CreateType(this, value, reflectionAppDomain.System_Object);
            }
Beispiel #29
0
        IList <DmdType> Convert(DmdAppDomain reflectionAppDomain, TypeMirror[] typeArgs)
        {
            if (typeArgs.Length == 0)
            {
                return(Array.Empty <DmdType>());
            }
            var types = new DmdType[typeArgs.Length];

            for (int i = 0; i < types.Length; i++)
            {
                types[i] = engine.GetReflectionType(reflectionAppDomain, typeArgs[i], null);
            }
            return(types);
        }
        IList <DmdType> Convert(DmdAppDomain reflectionAppDomain, CorType[] typeArgs)
        {
            if (typeArgs.Length == 0)
            {
                return(Array.Empty <DmdType>());
            }
            var types = new DmdType[typeArgs.Length];
            var reflectionTypeCreator = new ReflectionTypeCreator(engine, reflectionAppDomain);

            for (int i = 0; i < types.Length; i++)
            {
                types[i] = reflectionTypeCreator.Create(typeArgs[i]);
            }
            return(types);
        }