예제 #1
0
        public ProcedureSignature(string serviceName, string procedureName, string documentation, IProcedureHandler handler, GameScene gameScene, params string[] attributes)
        {
            Name = procedureName;
            FullyQualifiedName = serviceName + "." + Name;
            Documentation      = DocumentationUtils.ResolveCrefs(documentation);
            Handler            = handler;
            GameScene          = gameScene;
            Attributes         = attributes.ToList();
            Parameters         = handler.Parameters.Select(x => new ParameterSignature(FullyQualifiedName, x)).ToList();

            // Add parameter type attributes
            for (int position = 0; position < Parameters.Count; position++)
            {
                Attributes.AddRange(TypeUtils.ParameterTypeAttributes(position, Parameters [position].Type));
            }

            var returnType = handler.ReturnType;

            HasReturnType = (returnType != typeof(void));
            if (HasReturnType)
            {
                ReturnType = returnType;
                // Check it's a valid return type
                if (!TypeUtils.IsAValidType(returnType))
                {
                    throw new ServiceException(returnType + " is not a valid Procedure return type, " + "in " + FullyQualifiedName);
                }
                // Add return type attributes
                Attributes.AddRange(TypeUtils.ReturnTypeAttributes(returnType));
            }
        }
예제 #2
0
 public EnumerationSignature(string serviceName, string enumName, IList <EnumerationValueSignature> values, string documentation)
 {
     Name = enumName;
     FullyQualifiedName = serviceName + "." + Name;
     Values             = values;
     Documentation      = DocumentationUtils.ResolveCrefs(documentation);
 }
예제 #3
0
 public void WriteParams(IndentedTextWriter writer, OperationAnalyzer analyzer, SimplePropertyInfo spi, Param param)
 {
     writer.WriteLine(DocumentationUtils.CommentDocumentation(spi.MemberDocumentation /*FlattenedDocumentation*/));
     CmdletSourceWriter.WriteParamAttribute(writer, analyzer, spi, param);
     CmdletSourceWriter.WriteParamAliases(writer, analyzer, spi);
     writer.WriteLine("public object[] {0} {{ get; set; }}", spi.CmdletParameterName);
 }
예제 #4
0
 public void ResolveCrefs()
 {
     Assert.AreEqual(
         "<see cref=\"T:TestService\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"T:KRPC.Test.Service.TestService\" />"));
     Assert.AreEqual(
         "<see cref=\"M:TestService.ProcedureNoArgsNoReturn\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"M:KRPC.Test.Service.TestService.ProcedureNoArgsNoReturn\" />"));
     Assert.AreEqual(
         "<see cref=\"M:TestService.PropertyWithGetAndSet\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"P:KRPC.Test.Service.TestService.PropertyWithGetAndSet\" />"));
     Assert.AreEqual(
         "<see cref=\"T:TestService.TestEnum\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"T:KRPC.Test.Service.TestService.TestEnum\" />"));
     Assert.AreEqual(
         "<see cref=\"M:TestService.TestEnum.x\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"F:KRPC.Test.Service.TestService.TestEnum.x\" />"));
     Assert.AreEqual(
         "<see cref=\"T:TestService.TestClass\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"T:KRPC.Test.Service.TestService+TestClass\" />"));
     Assert.AreEqual(
         "<see cref=\"M:TestService.TestClass.FloatToString\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"M:KRPC.Test.Service.TestService.TestClass.FloatToString(System.Single)\" />"));
     Assert.AreEqual(
         "<see cref=\"M:TestService.TestClass.IntProperty\" />",
         DocumentationUtils.ResolveCrefs("<see cref=\"P:KRPC.Test.Service.TestService.TestClass.IntProperty\" />"));
 }
예제 #5
0
 public EnumerationValueSignature(string serviceName, string enumName, string valueName, int value, string documentation)
 {
     Name = valueName;
     FullyQualifiedName = serviceName + "." + enumName + "." + Name;
     Value         = value;
     Documentation = DocumentationUtils.ResolveCrefs(documentation);
 }
        public void Completion(Response response, dynamic args)
        {
            ArrayList    functions = DocumentationUtils.getInstance().getFunctionInDb();
            AdvplDocInfo info      = new AdvplDocInfo();

            info.functions = functions;
            SendResponse(response, info);
        }
예제 #7
0
 /// <summary>
 /// Create a service signature from a C# type annotated with the KRPCService attribute
 /// </summary>
 /// <param name="type">Type.</param>
 public ServiceSignature(Type type)
 {
     TypeUtils.ValidateKRPCService(type);
     Name          = TypeUtils.GetServiceName(type);
     Documentation = DocumentationUtils.ResolveCrefs(type.GetDocumentation());
     Classes       = new Dictionary <string, ClassSignature> ();
     Enumerations  = new Dictionary <string, EnumerationSignature> ();
     Procedures    = new Dictionary <string, ProcedureSignature> ();
     GameScene     = TypeUtils.GetServiceGameScene(type);
 }
예제 #8
0
 public void ResolveIncorrectCrefs()
 {
     Assert.Throws <ServiceException> (() => DocumentationUtils.ResolveCrefs("<see cref=\"\" />"));
     Assert.Throws <ServiceException> (() => DocumentationUtils.ResolveCrefs("<see cref=\"Foo\" />"));
     Assert.Throws <ServiceException> (() => DocumentationUtils.ResolveCrefs("<see cref=\"Foo.Bar\" />"));
     Assert.Throws <ServiceException> (() => DocumentationUtils.ResolveCrefs("<see cref=\"T:Foo.Bar\" />"));
     Assert.Throws <ServiceException> (() => DocumentationUtils.ResolveCrefs("<see cref=\"M:Foo.Bar\" />"));
     Assert.Throws <ServiceException> (() => DocumentationUtils.ResolveCrefs("<see cref=\"P:Foo.Bar\" />"));
     Assert.Throws <ServiceException> (() => DocumentationUtils.ResolveCrefs("<see cref=\"F:Foo.Bar\" />"));
 }
예제 #9
0
 /// <summary>
 /// Registers a <see cref="MaterialHeaderScopeItem"/> into the list
 /// </summary>
 /// <typeparam name="TEnum">A valid <see cref="struct"/> and <see cref="IConvertible"/></typeparam>
 /// <param name="title"><see cref="GUIContent"/> The title of the scope</param>
 /// <param name="expandable">The mask identifying the scope</param>
 /// <param name="action">The action that will be drawn if the scope is expanded</param>
 public void RegisterHeaderScope <TEnum>(GUIContent title, TEnum expandable, Action <Material> action)
     where TEnum : struct, IConvertible
 {
     m_Items.Add(new MaterialHeaderScopeItem()
     {
         headerTitle       = title,
         expandable        = Convert.ToUInt32(expandable),
         drawMaterialScope = action,
         url = DocumentationUtils.GetHelpURL <TEnum>(expandable)
     });
 }
예제 #10
0
        public ProcedureSignature(string serviceName, string procedureName, string documentation, IProcedureHandler handler, GameScene gameScene, params string[] attributes)
        {
            Name = procedureName;
            FullyQualifiedName = serviceName + "." + Name;
            Documentation      = DocumentationUtils.ResolveCrefs(documentation);
            Handler            = handler;
            GameScene          = gameScene;
            Attributes         = attributes.ToList();
            Parameters         = handler.Parameters.Select(x => new ParameterSignature(FullyQualifiedName, x)).ToList();

            // Add parameter type attributes
            for (int position = 0; position < Parameters.Count; position++)
            {
                Attributes.AddRange(TypeUtils.ParameterTypeAttributes(position, Parameters [position].Type));
            }

            // Create builders for the parameter types that are message types
            //ParameterBuilders = Parameters
            //    .Select (x => {
            //    try {
            //        return ProtocolBuffers.IsAMessageType (x.Type) ? ProtocolBuffers.BuilderForMessageType (x.Type) : null;
            //    } catch (ArgumentException) {
            //        throw new ServiceException ("Failed to instantiate a message builder for parameter type " + x.Type.Name);
            //    }
            //}).ToArray ();
            HasReturnType = (handler.ReturnType != typeof(void));
            if (HasReturnType)
            {
                ReturnType = handler.ReturnType;
                // Check it's a valid return type
                if (!TypeUtils.IsAValidType(ReturnType))
                {
                    throw new ServiceException(
                              ReturnType + " is not a valid Procedure return type, " +
                              "in " + FullyQualifiedName);
                }
                // Add return type attributes
                Attributes.AddRange(TypeUtils.ReturnTypeAttributes(ReturnType));
                // Create a builder if it's a message type
                //if (ProtocolBuffers.IsAMessageType (ReturnType)) {
                //    try {
                //        ReturnBuilder = ProtocolBuffers.BuilderForMessageType (ReturnType);
                //    } catch (ArgumentException) {
                //        throw new ServiceException ("Failed to instantiate a message builder for return type " + ReturnType.Name);
                //    }
                //}
            }
        }
예제 #11
0
        public static CompletionResults Create(ScriptFile scriptFile, int lineNumber, int columnNumber)
        {
            Collection <CompletionResult> functionsSql = DocumentationUtils.getInstance().getFunctionInDb();
            BufferRange replacedRange = null;

            // Only calculate the replacement range if there are completion results
            if (functionsSql.Count > 0)
            {
                replacedRange = new BufferRange(lineNumber, columnNumber, lineNumber, columnNumber);
            }
            return(new CompletionResults
            {
                Completions = GetCompletionsArray(functionsSql),
                ReplacedRange = replacedRange
            });

            throw new NotImplementedException();
        }
예제 #12
0
 public void ResolveIncorrectCrefs(string input)
 {
     Assert.Throws <DocumentationException> (() => DocumentationUtils.ResolveCrefs(input));
 }
예제 #13
0
 public void ResolveCrefs(string input, string output)
 {
     Assert.AreEqual(output, DocumentationUtils.ResolveCrefs(input));
 }
예제 #14
0
        internal ProcedureSignature(string serviceName, string procedureName, string documentation, IProcedureHandler handler, GameScene gameScene)
        {
            Name = procedureName;
            FullyQualifiedName = serviceName + "." + Name;
            Documentation      = DocumentationUtils.ResolveCrefs(documentation);
            Handler            = handler;
            GameScene          = gameScene;
            Parameters         = handler.Parameters.Select(x => new ParameterSignature(FullyQualifiedName, x)).ToList();

            var returnType = handler.ReturnType;

            HasReturnType = (returnType != typeof(void));
            if (HasReturnType)
            {
                ReturnType = returnType;
                // Check it's a valid return type
                if (!TypeUtils.IsAValidType(returnType))
                {
                    throw new ServiceException(returnType + " is not a valid Procedure return type, " + "in " + FullyQualifiedName);
                }
                ReturnIsNullable = handler.ReturnIsNullable;
            }

            var parts = procedureName.Split('_');

            if (parts.Length == 2)
            {
                if (parts [0] == ("get"))
                {
                    IsPropertyGetter = true;
                    PropertyName     = parts [1];
                }
                else if (parts [0] == "set")
                {
                    IsPropertySetter = true;
                    PropertyName     = parts [1];
                }
                else
                {
                    IsClassMember = true;
                    ClassName     = parts [0];
                }
            }
            else if (parts.Length == 3)
            {
                if (parts [1] == "get")
                {
                    IsClassMember    = true;
                    IsPropertyGetter = true;
                    PropertyName     = parts [2];
                }
                else if (parts [1] == "set")
                {
                    IsClassMember    = true;
                    ClassName        = parts [0];
                    IsPropertySetter = true;
                    PropertyName     = parts [2];
                }
                else if (parts [1] == "static")
                {
                    IsClassMember = true;
                    ClassName     = parts [0];
                    IsStatic      = true;
                }
            }
        }
예제 #15
0
 public ExceptionSignature(string serviceName, string className, string documentation)
 {
     Name = className;
     FullyQualifiedName = serviceName + "." + Name;
     Documentation      = DocumentationUtils.ResolveCrefs(documentation);
 }
        private void DrawRendererFeature(int index, ref SerializedProperty renderFeatureProperty)
        {
            Object rendererFeatureObjRef = renderFeatureProperty.objectReferenceValue;

            if (rendererFeatureObjRef != null)
            {
                bool   hasChangedProperties = false;
                string title;

                bool hasCustomTitle = GetCustomTitle(rendererFeatureObjRef.GetType(), out title);

                if (!hasCustomTitle)
                {
                    title = ObjectNames.GetInspectorTitle(rendererFeatureObjRef);
                }

                string tooltip;
                GetTooltip(rendererFeatureObjRef.GetType(), out tooltip);

                string helpURL;
                DocumentationUtils.TryGetHelpURL(rendererFeatureObjRef.GetType(), out helpURL);

                // Get the serialized object for the editor script & update it
                Editor           rendererFeatureEditor            = m_Editors[index];
                SerializedObject serializedRendererFeaturesEditor = rendererFeatureEditor.serializedObject;
                serializedRendererFeaturesEditor.Update();

                // Foldout header
                EditorGUI.BeginChangeCheck();
                SerializedProperty activeProperty = serializedRendererFeaturesEditor.FindProperty("m_Active");
                bool displayContent = CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent(title, tooltip), renderFeatureProperty, activeProperty, pos => OnContextClick(pos, index), null, null, helpURL);
                hasChangedProperties |= EditorGUI.EndChangeCheck();

                // ObjectEditor
                if (displayContent)
                {
                    if (!hasCustomTitle)
                    {
                        EditorGUI.BeginChangeCheck();
                        SerializedProperty nameProperty = serializedRendererFeaturesEditor.FindProperty("m_Name");
                        nameProperty.stringValue = ValidateName(EditorGUILayout.DelayedTextField(Styles.PassNameField, nameProperty.stringValue));
                        if (EditorGUI.EndChangeCheck())
                        {
                            hasChangedProperties = true;

                            // We need to update sub-asset name
                            rendererFeatureObjRef.name = nameProperty.stringValue;
                            AssetDatabase.SaveAssets();

                            // Triggers update for sub-asset name change
                            ProjectWindowUtil.ShowCreatedAsset(target);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    rendererFeatureEditor.OnInspectorGUI();
                    hasChangedProperties |= EditorGUI.EndChangeCheck();

                    EditorGUILayout.Space(EditorGUIUtility.singleLineHeight);
                }

                // Apply changes and save if the user has modified any settings
                if (hasChangedProperties)
                {
                    serializedRendererFeaturesEditor.ApplyModifiedProperties();
                    serializedObject.ApplyModifiedProperties();
                    ForceSave();
                }
            }
            else
            {
                CoreEditorUtils.DrawHeaderToggle(Styles.MissingFeature, renderFeatureProperty, m_FalseBool, pos => OnContextClick(pos, index));
                m_FalseBool.boolValue = false; // always make sure false bool is false
                EditorGUILayout.HelpBox(Styles.MissingFeature.tooltip, MessageType.Error);
                if (GUILayout.Button("Attempt Fix", EditorStyles.miniButton))
                {
                    ScriptableRendererData data = target as ScriptableRendererData;
                    data.ValidateRendererFeatures();
                }
            }
        }