Exemple #1
0
        private static void CheckPropertyML(
            Action <Diagnostic> reportDiagnostic,
            PropertyValueSyntax propValue,
            string name,
            string kindName)
        {
            // ISSUE: variable of a compiler-generated type
            CommaSeparatedIdentifierEqualsStringListSyntax stringListSyntax = ((MultilanguagePropertyValueSyntax)propValue).Value;

            if (stringListSyntax.Values.Count <= 0)
            {
                return;
            }
            foreach (IdentifierEqualsStringSyntax equalsStringSyntax in stringListSyntax.Values)
            {
                Action <Diagnostic> reportDiagnostic1 = reportDiagnostic;
                // ISSUE: variable of a compiler-generated type
                StringLiteralValueSyntax stringLiteral = equalsStringSyntax.StringLiteral;
                string input = stringLiteral != null?SyntaxNodeExtensions.GetLiteralValue(stringLiteral).ToString() : (string)null;

                Location location  = propValue.GetLocation();
                string   kindName1 = kindName;
                string   name1     = name;
                EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(reportDiagnostic1, input, location, kindName1, name1);
            }
        }
Exemple #2
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);
 }
Exemple #3
0
 private static void CheckProperty(
     Action <Diagnostic> reportDiagnostic,
     PropertyValueSyntax propValue,
     string name,
     string kindName)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(reportDiagnostic, propValue.ToString(), propValue.GetLocation(), kindName, name);
 }
Exemple #4
0
        private static void CheckFieldName(
            SyntaxNodeAnalysisContext syntaxNodeAnalysisContext,
            SyntaxNode syntaxNode)
        {
            string nameStringValue = syntaxNode.GetNameStringValue();

            EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(new Action <Diagnostic>(syntaxNodeAnalysisContext.ReportDiagnostic), nameStringValue, syntaxNode.GetLocation(), syntaxNode.Kind.ToString(), nameStringValue);
        }
Exemple #5
0
 private static void CheckTextConst(
     SyntaxNodeAnalysisContext syntaxNodeAnalysisContext,
     TextConstDataTypeSyntax textConst)
 {
     foreach (IdentifierEqualsStringSyntax equalsStringSyntax in textConst.Multilanguage.Values)
     {
         EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(new Action <Diagnostic>(syntaxNodeAnalysisContext.ReportDiagnostic), equalsStringSyntax.StringLiteral.ToString(), equalsStringSyntax.GetLocation(), NavTypeKind.TextConst.ToString(), ((VariableDeclarationSyntax)textConst.Parent.Parent).Name.ToString());
     }
 }
Exemple #6
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);
        }
Exemple #7
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);
                }
            }
        }
Exemple #8
0
 private static void CheckObjectName(
     SymbolAnalysisContext symbolAnalysisContext,
     ITypeSymbol applicationObject)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(new Action <Diagnostic>(symbolAnalysisContext.ReportDiagnostic), applicationObject.Name, applicationObject.GetLocation(), applicationObject.Kind.ToString(), "Name");
 }
Exemple #9
0
 private static void CheckLabel(
     SyntaxNodeAnalysisContext syntaxNodeAnalysisContext,
     LabelDataTypeSyntax label)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(new Action <Diagnostic>(syntaxNodeAnalysisContext.ReportDiagnostic), label.Label.LabelText.Value.ValueText, label.GetLocation(), NavTypeKind.Label.ToString(), ((VariableDeclarationSyntax)label.Parent.Parent).Name.ToString());
 }