Пример #1
0
        private static Type FindTypeMatchingMovedTypeBasedOnNamespaceFromError(IEnumerable <string> lines)
        {
            string valueFromNormalizedMessage = APIUpdaterHelper.GetValueFromNormalizedMessage(lines, "Line=");
            int    num = (valueFromNormalizedMessage == null) ? -1 : int.Parse(valueFromNormalizedMessage);

            valueFromNormalizedMessage = APIUpdaterHelper.GetValueFromNormalizedMessage(lines, "Column=");
            int    num2 = (valueFromNormalizedMessage == null) ? -1 : int.Parse(valueFromNormalizedMessage);
            string valueFromNormalizedMessage2 = APIUpdaterHelper.GetValueFromNormalizedMessage(lines, "Script=");
            Type   result;

            if (num == -1 || num2 == -1 || valueFromNormalizedMessage2 == null)
            {
                result = null;
            }
            else
            {
                using (FileStream fileStream = File.Open(valueFromNormalizedMessage2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    IParser parser = ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.CSharp, new StreamReader(fileStream));
                    parser.Lexer.EvaluateConditionalCompilation = false;
                    parser.Parse();
                    string text = InvalidTypeOrNamespaceErrorTypeMapper.IsTypeMovedToNamespaceError(parser.CompilationUnit, num, num2);
                    if (text == null)
                    {
                        result = null;
                    }
                    else
                    {
                        result = APIUpdaterHelper.FindExactTypeMatchingMovedType(text);
                    }
                }
            }
            return(result);
        }
Пример #2
0
        public static bool IsReferenceToTypeWithChangedNamespace(string normalizedErrorMessage)
        {
            bool result;

            try
            {
                string[] lines = normalizedErrorMessage.Split(new char[]
                {
                    '\n'
                });
                string valueFromNormalizedMessage = APIUpdaterHelper.GetValueFromNormalizedMessage(lines, "EntityName=");
                Type   type = APIUpdaterHelper.FindExactTypeMatchingMovedType(valueFromNormalizedMessage) ?? APIUpdaterHelper.FindTypeMatchingMovedTypeBasedOnNamespaceFromError(lines);
                result = (type != null);
            }
            catch (ReflectionTypeLoadException ex)
            {
                throw new Exception(ex.Message + ex.LoaderExceptions.Aggregate("", (string acc, Exception curr) => acc + "\r\n\t" + curr.Message));
            }
            return(result);
        }