public string GetText()
 {
     try
     {
         var fileInfo = new FileInfo(FilePath);
         return(fileInfo.Length > MaxSize ? "" : File.ReadAllText(FilePath));
     }
     catch (IOException)
     {
         XamarinSecurityScannerLogger.Log("Could not read file {0}.", FilePath);
         return("");
     }
 }
Example #2
0
        public CompilationUnitSyntax GetUnit()
        {
            var text = "";

            try
            {
                text = File.ReadAllText(FilePath);
            }
            catch (IOException)
            {
                XamarinSecurityScannerLogger.Log("Could not read file {0}.", FilePath);
            }

            SyntaxTree tree = CSharpSyntaxTree.ParseText(text);

            return(tree.GetCompilationUnitRoot());
        }
Example #3
0
        private bool IsOutdated(XElement element)
        {
            XAttribute minSdkVersion = element.Attributes(_minSdkVersion).FirstOrDefault();

            if (minSdkVersion == null)
            {
                return(false);
            }

            try
            {
                int version = int.Parse(minSdkVersion.Value);
                return(version < 11);
            }
            catch (FormatException)
            {
                XamarinSecurityScannerLogger.Log("Could not parse minSdkVersion to number.");
                return(false);
            }
        }
Example #4
0
        public XElement GetXElement()
        {
            string text;

            try
            {
                text = File.ReadAllText(FilePath);
            }
            catch (IOException)
            {
                XamarinSecurityScannerLogger.Log("Could not read file {0}.", FilePath);
                return(new XElement("Name", "Content"));
            }

            try
            {
                return(XElement.Parse(text, LoadOptions.SetLineInfo));
            }
            catch (XmlException)
            {
                XamarinSecurityScannerLogger.Log("Could not parse XML file {0}.", FilePath);
                return(new XElement("Name", "Content"));
            }
        }