Esempio n. 1
0
 private static void VerifyValue(
     CompilationAnalysisContext context,
     NavAppManifest manifest,
     string input,
     string propertyName)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(new Action <Diagnostic>(context.ReportDiagnostic), input, manifest.GetDiagnosticLocation(propertyName), "app.json", propertyName);
 }
Esempio n. 2
0
        private static void CheckAppManifest(
            CompilationAnalysisContext compilationAnalysisContext)
        {
            NavAppManifest manifest = AppSourceCopConfigurationProvider.GetManifest(compilationAnalysisContext.Compilation);

            if (manifest == null)
            {
                return;
            }
            EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(compilationAnalysisContext, manifest, manifest.AppBrief, "brief");
            EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(compilationAnalysisContext, manifest, manifest.AppDescription, "description");
            EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(compilationAnalysisContext, manifest, manifest.AppName, "name");
            EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(compilationAnalysisContext, manifest, manifest.AppPublisher, "publisher");
            EmailAndPhoneNoMustNotBePresentInTheSource.CheckTranslations(compilationAnalysisContext, manifest);
        }
Esempio n. 3
0
        private static void CheckTranslations(
            CompilationAnalysisContext compilationAnalysisContext,
            NavAppManifest manifest)
        {
            if (!manifest.CompilerFeatures.ShouldGenerateTranslationFile())
            {
                return;
            }
            List <string> stringList = new List <string>();

            foreach (string supportedCountry in AppSourceCopConfigurationProvider.GetSupportedCountries(compilationAnalysisContext.Compilation))
            {
                if (LocalizationHelper.CountryCodeToLanguageCodes.ContainsKey(supportedCountry))
                {
                    stringList.Add(supportedCountry);
                }
            }
            if (stringList.Count == 0 || EmailAndPhoneNoMustNotBePresentInTheSource.GetLanguageCodesForSupportedCountries((IEnumerable <string>)stringList).Count == 0)
            {
                return;
            }
            foreach (string xliffLanguageFile in LanguageFileUtilities.GetXliffLanguageFiles(compilationAnalysisContext.Compilation.FileSystem, manifest.AppName))
            {
                try
                {
                    MemoryStream memoryStream = new MemoryStream(compilationAnalysisContext.Compilation.FileSystem.ReadBytes(xliffLanguageFile));
                    XmlDocument  xmlDocument  = new XmlDocument();
                    xmlDocument.Load((Stream)memoryStream);
                    Location propertyLocation = AppSourceCopConfigurationProvider.GetAppSourceCopConfigurationPropertyLocation(compilationAnalysisContext.Compilation, "SupportedCountries");
                    foreach (XmlNode xmlNode in xmlDocument.GetElementsByTagName("trans-unit", "urn:oasis:names:tc:xliff:document:1.2"))
                    {
                        string str = xmlNode.Attributes["id"].Value;
                        foreach (XmlNode childNode in xmlNode.ChildNodes)
                        {
                            if (SemanticFacts.IsSameName("target", childNode.LocalName))
                            {
                                EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(new Action <Diagnostic>(compilationAnalysisContext.ReportDiagnostic), childNode.InnerText, propertyLocation, xliffLanguageFile, string.Format("{0}:{1}", (object)str, (object)childNode.LocalName));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobalLogger.LogException(ex);
                }
            }
        }