Esempio n. 1
0
            private string GetComponentName(IValueReference <TValue> componentValue,
                                            [CanBeNull] IReifiedType <TValue> objectNamesType,
                                            [CanBeNull] IMetadataMethodLite getInspectorTitleMethod,
                                            IStackFrame frame,
                                            IValueFetchOptions options, IValueServicesFacade <TValue> services)
            {
                if (objectNamesType != null && getInspectorTitleMethod != null)
                {
                    try
                    {
                        var inspectorTitle = objectNamesType.CallStaticMethod(frame, options, getInspectorTitleMethod,
                                                                              componentValue.GetValue(options));
                        var stringValueRole =
                            new SimpleValueReference <TValue>(inspectorTitle, frame, services.RoleFactory)
                            .AsStringSafe(options);
                        if (stringValueRole != null)
                        {
                            return(stringValueRole.GetString());
                        }
                    }
                    catch (Exception e)
                    {
                        myLogger.Error(e, "Unable to fetch object names for {0}", componentValue);
                    }
                }

                return(componentValue.GetPrimaryRole(options).ReifiedType.MetadataType.ShortName);
            }
Esempio n. 2
0
 public GameObjectChildrenGroup(IValueReference <TValue> transformReference,
                                IValueServicesFacade <TValue> services)
     : base("Children")
 {
     myTransformReference = transformReference;
     myServices           = services;
 }
Esempio n. 3
0
        private IEnumerable <IValueEntity> EnumerateMembersWithBaseNode(IObjectValueRole <TValue> valueRole,
                                                                        IPresentationOptions options,
                                                                        CancellationToken token,
                                                                        IValueServicesFacade <TValue> valueServices)
        {
            var baseRole = FindNextBaseRoleWithVisibleMembers(valueRole);

            if (baseRole != null)
            {
                yield return(new ConcreteObjectRoleReference <TValue>(baseRole, "base", false, ValueOriginKind.Base, ValueFlags.None).ToValue(valueServices));
            }

            var propertiesAndFields = GetPropertiesAndFields(valueRole)
                                      .Where(IsAllowedReference)
                                      .OrderBy(IdentityFunc <IValueReference <TValue> > .Instance, ByNameReferenceComparer <TValue> .Instance);

            foreach (var member in ChildrenRenderingUtil.RenderReferencesWithVisibilityGroups(propertiesAndFields, options, token, valueServices))
            {
                yield return(member);
            }

            foreach (var staticMember in ChildrenRenderingUtil.EnumerateStaticMembersIfNeeded(valueRole, options, token, valueServices))
            {
                yield return(staticMember);
            }
        }
Esempio n. 4
0
 public GameObjectsGroup(IObjectValueRole <TValue> valueRole, IMetadataMethodLite getRootObjectMethod,
                         IValueServicesFacade <TValue> valueServices)
     : base("Game Objects")
 {
     myValueRole           = valueRole;
     myGetRootObjectMethod = getRootObjectMethod;
     myValueServices       = valueServices;
 }
 public GameObjectChildrenGroup(IObjectValueRole <TValue> gameObjectRole,
                                IValueServicesFacade <TValue> valueServices, ILogger logger)
     : base("Children")
 {
     myGameObjectRole = gameObjectRole;
     myValueServices  = valueServices;
     myLogger         = logger;
 }
Esempio n. 6
0
 public ChildrenGroup(IObjectValueRole <TValue> serializedObjectRole,
                      IValueServicesFacade <TValue> valueServices,
                      ILogger logger)
     : base("Serialized Properties")
 {
     mySerializedObjectRole = serializedObjectRole;
     myValueServices        = valueServices;
     myLogger = logger;
 }
 public GameObjectsGroup(IObjectValueRole <TValue> sceneValueRole, IMetadataMethodLite getRootObjectsMethod,
                         IValueServicesFacade <TValue> valueServices, ILogger logger)
     : base("Game objects")
 {
     mySceneValueRole       = sceneValueRole;
     myGetRootObjectsMethod = getRootObjectsMethod;
     myValueServices        = valueServices;
     myLogger = logger;
 }
 public UnityAdditionalValuesProvider(IDebuggerSession session, IValueServicesFacade <TValue> valueServices,
                                      IUnityOptions unityOptions, ILogger logger)
 {
     // We can't use EvaluationOptions here, it hasn't been set yet
     mySession       = session;
     myValueServices = valueServices;
     myUnityOptions  = unityOptions;
     myLogger        = logger;
 }
 public ArrayElementsGroup(IObjectValueRole <TValue> serializedPropertyRole, int arraySize,
                           MethodSelector getMethodElementSelector,
                           IValueServicesFacade <TValue> valueServices,
                           ILogger logger)
     : base($"[0..{arraySize - 1}]")
 {
     mySerializedPropertyRole = serializedPropertyRole;
     myArraySize = arraySize;
     myGetMethodElementSelector = getMethodElementSelector;
     myValueServices            = valueServices;
     myLogger = logger;
 }
Esempio n. 10
0
        private IEnumerable <IValueEntity> EnumerateMembersFlat(IObjectValueRole <TValue> valueRole,
                                                                IPresentationOptions options,
                                                                CancellationToken token,
                                                                IValueServicesFacade <TValue> valueServices)
        {
            var sortedReferences = ChildrenRenderingUtil.CollectMembersByOverridingRules(valueRole, token)
                                   .Where(IsAllowedReference)
                                   .OrderBy(IdentityFunc <IValueReference <TValue> > .Instance, ByNameReferenceComparer <TValue> .Instance);

            foreach (var memberValue in ChildrenRenderingUtil.RenderReferencesWithVisibilityGroups(sortedReferences, options, token, valueServices))
            {
                yield return(memberValue);
            }

            foreach (var staticMember in ChildrenRenderingUtil.EnumerateStaticMembersIfNeeded(valueRole, options, token, valueServices))
            {
                yield return(staticMember);
            }
        }
 public static string GetThrownExceptionMessage <TValue>(EvaluatorExceptionThrownException <TValue> exception,
                                                         IStackFrame frame,
                                                         IValueServicesFacade <TValue> valueServices,
                                                         IValueFetchOptions valueFetchOptions,
                                                         ILogger logger)
     where TValue : class
 {
     try
     {
         var reference = new SimpleValueReference <TValue>(exception.Exception, frame, valueServices.RoleFactory);
         return(reference.AsObjectSafe(valueFetchOptions)
                ?.GetInstancePropertyReference("Message", true)
                ?.AsStringSafe(valueFetchOptions)?.GetString());
     }
     catch (Exception e)
     {
         // Argh! Exception thrown while trying to get information about a thrown exception!
         logger.LogExceptionSilently(e);
         return(null);
     }
 }
Esempio n. 12
0
            private string GetComponentName(IValueReference <TValue> componentValue,
                                            [CanBeNull] IReifiedType <TValue> objectNamesType,
                                            [CanBeNull] IMetadataMethodLite getInspectorTitleMethod,
                                            IStackFrame frame,
                                            IValueFetchOptions options,
                                            IValueServicesFacade <TValue> services,
                                            out bool isNameFromValue)
            {
                if (objectNamesType != null && getInspectorTitleMethod != null)
                {
                    try
                    {
                        var inspectorTitle = objectNamesType.CallStaticMethod(frame, options, getInspectorTitleMethod,
                                                                              componentValue.GetValue(options));
                        var stringValueRole =
                            new SimpleValueReference <TValue>(inspectorTitle, frame, services.RoleFactory)
                            .AsStringSafe(options);
                        if (stringValueRole != null)
                        {
                            isNameFromValue = true;
                            return(stringValueRole.GetString());
                        }
                    }
                    catch (EvaluatorAbortedException e)
                    {
                        myLogger.LogExceptionSilently(e);
                    }
                    catch (Exception e)
                    {
                        myLogger.Warn(e, ExceptionOrigin.Algorithmic,
                                      $"Unable to fetch object names for {componentValue}");
                    }
                }

                isNameFromValue = false;
                return(componentValue.GetPrimaryRole(options).ReifiedType.MetadataType.ShortName);
            }
 public static IReifiedType <TValue> GetReifiedType <TValue>(this IValueServicesFacade <TValue> valueServices,
                                                             IStackFrame frame, string aqn)
     where TValue : class
 {
     return((IReifiedType <TValue>)valueServices.TypeUniverse.GetReifiedType(frame, aqn));
 }
Esempio n. 14
0
        public static IValueEntity GetScenePathValue <TValue>([CanBeNull] IObjectValueRole <TValue> gameObjectRole,
                                                              IPresentationOptions options,
                                                              IValueServicesFacade <TValue> valueServices,
                                                              ILogger logger)
            where TValue : class
        {
            if (gameObjectRole == null)
            {
                return(null);
            }
            return(logger.CatchEvaluatorException <TValue, IValueEntity>(() =>
            {
                // Only available in the editor. Not available for players, where we'll display nothing.
                // TODO: Hand roll this for players. Simply follow transform.parent
                // However, this will obviously be more expensive to calculate
                var frame = gameObjectRole.ValueReference.OriginatingFrame;
                var animationUtilityType =
                    valueServices.GetReifiedType(frame, "UnityEditor.AnimationUtility, UnityEditor")
                    ?? valueServices.GetReifiedType(frame, "UnityEditor.AnimationUtility, UnityEditor.CoreModule");
                var method = animationUtilityType?.MetadataType.GetMethods()
                             .FirstOrDefault(ourCalculateTransformPathSelector);
                if (method == null)
                {
                    logger.Trace(
                        "Unable to get metadata for AnimationUtility.CalculateTransformPath method. Is this a player?");
                    return null;
                }

                var targetTransformReference = gameObjectRole.GetInstancePropertyReference("transform");
                var targetTransformRole = targetTransformReference?.AsObjectSafe(options);
                // Search in bases - transform might be a RectTransform or a Transform, and root is defined on Transform
                var rootTransformReference = targetTransformRole?.GetInstancePropertyReference("root", true);
                var rootTransformRole = rootTransformReference?.AsObjectSafe(options);

                if (targetTransformRole == null || rootTransformRole == null)
                {
                    logger.Warn("Unable to evaluate gameObject.transform and/or gameObject.transform.root or values are null.");
                    return null;
                }

                var rootTransformName = rootTransformRole.GetInstancePropertyReference("name", true)
                                        ?.AsStringSafe(options)?.GetString() ?? "";

                var pathValue = animationUtilityType.CallStaticMethod(frame, options, method,
                                                                      targetTransformReference.GetValue(options), rootTransformReference.GetValue(options));
                var path = new SimpleValueReference <TValue>(pathValue, frame, valueServices.RoleFactory)
                           .AsStringSafe(options)?.GetString();
                if (path == null)
                {
                    // We expect empty string at least
                    logger.Warn("Unexpected null returned from AnimationUtility.CalculateTransformPath");
                    return null;
                }

                var fullPath = path.IsNullOrEmpty() ? rootTransformName : rootTransformName + "/" + path;
                var fullPathValue = valueServices.ValueFactory.CreateString(frame, options, fullPath);

                // Don't show type presentation. This is informational, rather than an actual property
                var simpleReference = new SimpleValueReference <TValue>(fullPathValue, null, "Scene path",
                                                                        ValueOriginKind.Property,
                                                                        ValueFlags.None | ValueFlags.IsReadOnly | ValueFlags.IsDefaultTypePresentation, frame,
                                                                        valueServices.RoleFactory);

                // Wrap the simple reference - the default StringValuePresenter will display the simple reference as a
                // string property, with syntax colouring, quotes and type name. Our TextValuePresenter will handle the
                // TextValueReference and use the flags we've set
                return new TextValueReference <TValue>(simpleReference, valueServices.RoleFactory).ToValue(
                    valueServices);
            },
                                                                         exception => logger.LogThrownUnityException(exception, gameObjectRole.ValueReference.OriginatingFrame,
                                                                                                                     valueServices, options)));
        }
 public UnityAdditionalValuesProvider(IDebuggerSession session, IValueServicesFacade <Value> valueServices,
                                      IUnityOptions unityOptions, ILogger logger)
     : base(session, valueServices, unityOptions, logger)
 {
 }