Esempio n. 1
0
        public override IEnumerable <Diagnosis> GatherDiagnoses()
        {
            var diagnoses = new List <Diagnosis>();

            foreach (var variable in variables)
            {
                var d = new Diagnosis("Script uses variable " + variable, Diagnosis.Severity.Note);
                diagnoses.Add(d);
            }

            return(diagnoses);
        }
Esempio n. 2
0
        IEnumerable <Yarn.Analysis.Diagnosis> AnalyseEnvironment()
        {
            var deprecations = new List <Deprecation>();

            deprecations.Add(new Deprecation(
                                 typeof(Yarn.Unity.VariableStorageBehaviour),
                                 "SetNumber",
                                 "This method is obsolete, and will not be called in future " +
                                 "versions of Yarn Spinner. Use SetValue instead."
                                 ));

            deprecations.Add(new Deprecation(
                                 typeof(Yarn.Unity.VariableStorageBehaviour),
                                 "GetNumber",
                                 "This method is obsolete, and will not be called in future " +
                                 "versions of Yarn Spinner. Use GetValue instead."
                                 ));

            var results = new List <Yarn.Analysis.Diagnosis>();

            var assemblies = System.AppDomain.CurrentDomain.GetAssemblies();


            foreach (var assembly in assemblies)
            {
                foreach (var type in assembly.GetTypes())
                {
                    foreach (var deprecation in deprecations)
                    {
                        if (!type.IsSubclassOf(deprecation.type))
                        {
                            continue;
                        }

                        foreach (var method in type.GetMethods())
                        {
                            if (method.Name == deprecation.methodName && method.DeclaringType == type)
                            {
                                var message = "{0} implements the {1} method. {2}";
                                message = string.Format(message, type.Name, deprecation.methodName, deprecation.usageNotes);
                                var diagnosis = new Yarn.Analysis.Diagnosis(message, Yarn.Analysis.Diagnosis.Severity.Warning);
                                results.Add(diagnosis);
                            }
                        }
                    }
                }
            }
            return(results);
        }