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 CheckApplicationObjects(SymbolAnalysisContext symbolAnalysisContext)
        {
            ITypeSymbol symbol = (ITypeSymbol)symbolAnalysisContext.Symbol;

            EmailAndPhoneNoMustNotBePresentInTheSource.CheckObjectName(symbolAnalysisContext, symbol);
            EmailAndPhoneNoMustNotBePresentInTheSource.CheckObjectCaptions(symbolAnalysisContext, symbol);
        }
Exemple #3
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 #4
0
 private static void CheckProperty(
     Action <Diagnostic> reportDiagnostic,
     PropertyValueSyntax propValue,
     string name,
     string kindName)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.VerifyValue(reportDiagnostic, propValue.ToString(), propValue.GetLocation(), kindName, name);
 }
Exemple #5
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 #6
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 #7
0
        private static void CheckSyntax(
            SyntaxNodeAnalysisContext syntaxNodeAnalysisContext)
        {
            SyntaxKind kind = syntaxNodeAnalysisContext.Node.Kind;

            if ((uint)kind <= 321U)
            {
                if ((uint)kind <= 307U)
                {
                    if (kind != SyntaxKind.TextConstDataType)
                    {
                        if (kind != SyntaxKind.LabelDataType)
                        {
                            return;
                        }
                        EmailAndPhoneNoMustNotBePresentInTheSource.CheckLabel(syntaxNodeAnalysisContext, (LabelDataTypeSyntax)syntaxNodeAnalysisContext.Node);
                        return;
                    }
                    EmailAndPhoneNoMustNotBePresentInTheSource.CheckTextConst(syntaxNodeAnalysisContext, (TextConstDataTypeSyntax)syntaxNodeAnalysisContext.Node);
                    return;
                }
                if (kind != SyntaxKind.Field)
                {
                    if (kind != SyntaxKind.FieldModification)
                    {
                        return;
                    }
                }
                else
                {
                    SyntaxNode node = syntaxNodeAnalysisContext.Node;
                    EmailAndPhoneNoMustNotBePresentInTheSource.CheckCaptions(new Action <Diagnostic>(syntaxNodeAnalysisContext.ReportDiagnostic), node);
                    EmailAndPhoneNoMustNotBePresentInTheSource.CheckFieldName(syntaxNodeAnalysisContext, node);
                    return;
                }
            }
            else if ((uint)kind <= 337U)
            {
                if (kind != SyntaxKind.PageField && kind != SyntaxKind.PageAction)
                {
                    return;
                }
            }
            else if (kind != SyntaxKind.ActionModifyChange && kind != SyntaxKind.ControlModifyChange)
            {
                return;
            }
            SyntaxNode node1 = syntaxNodeAnalysisContext.Node;

            EmailAndPhoneNoMustNotBePresentInTheSource.CheckCaptions(new Action <Diagnostic>(syntaxNodeAnalysisContext.ReportDiagnostic), node1);
            EmailAndPhoneNoMustNotBePresentInTheSource.CheckPageFieldTooltips(new Action <Diagnostic>(syntaxNodeAnalysisContext.ReportDiagnostic), node1);
            EmailAndPhoneNoMustNotBePresentInTheSource.CheckFieldName(syntaxNodeAnalysisContext, node1);
        }
Exemple #8
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 #9
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 #10
0
 private static void VerifyValue(
     Action <Diagnostic> reportDiagnostic,
     string input,
     Location location,
     string kindName,
     string name)
 {
     if (string.IsNullOrWhiteSpace(input))
     {
         return;
     }
     input = input.Trim();
     if (!EmailAndPhoneNoMustNotBePresentInTheSource.IsContainsEmail(input) && !EmailAndPhoneNoMustNotBePresentInTheSource.IsContainsPhoneNo(input))
     {
         return;
     }
     reportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule026EmailAndPhoneNoMustNotBePresentInTheSource, location, (object)kindName, (object)name));
 }
Exemple #11
0
        private static ISet <string> GetLanguageCodesForSupportedCountries(
            IEnumerable <string> countries)
        {
            PooledHashSet <string> instance = PooledHashSet <string> .GetInstance();

            try
            {
                foreach (string country in countries)
                {
                    instance.UnionWith(EmailAndPhoneNoMustNotBePresentInTheSource.GetSupportedLocales(country));
                }
                return((ISet <string>)instance.ToImmutableHashSet <string>());
            }
            finally
            {
                instance.Free();
            }
        }
Exemple #12
0
        private static void CheckCaptionsTooltips(
            Action <Diagnostic> reportDiagnostic,
            PropertyValueSyntax propValue,
            PropertyKind propKind,
            string name)
        {
            if (propValue == null)
            {
                return;
            }
            switch (propValue.Kind)
            {
            case SyntaxKind.MultilanguagePropertyValue:
                EmailAndPhoneNoMustNotBePresentInTheSource.CheckPropertyML(reportDiagnostic, propValue, name, propKind.ToString());
                break;

            case SyntaxKind.LabelPropertyValue:
                EmailAndPhoneNoMustNotBePresentInTheSource.CheckProperty(reportDiagnostic, propValue, name, propKind.ToString());
                break;
            }
        }
Exemple #13
0
 private static void CheckObjectCaptions(
     SymbolAnalysisContext symbolAnalysisContext,
     ITypeSymbol applicationObject)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.CheckCaptions(new Action <Diagnostic>(symbolAnalysisContext.ReportDiagnostic), applicationObject.DeclaringSyntaxReference.GetSyntax());
 }
Exemple #14
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 #15
0
 private static void CheckPageFieldTooltips(
     Action <Diagnostic> reportDiagnostic,
     SyntaxNode syntaxNode)
 {
     EmailAndPhoneNoMustNotBePresentInTheSource.CheckCaptionsTooltips(reportDiagnostic, syntaxNode.GetPropertyValue(PropertyKind.ToolTip) ?? syntaxNode.GetPropertyValue(PropertyKind.ToolTipML), PropertyKind.ToolTip, syntaxNode.GetNameStringValue());
 }
Exemple #16
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());
 }