ReadAttributeString() public method

Reads an attribute value as a string.
public ReadAttributeString ( string attributeName ) : string
attributeName string Name of the attribute to read.
return string
Example #1
0
        private void ReadModule(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineModule(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementModule, parent);
            context.ClearModule();
        }
Example #2
0
        private static void ReadFxCopReport(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineReport(reader.ReadAttributeString(SchemaStrings.AttributeVersion));
            reader.ReadChildren(SchemaStrings.ElementFxCopReport, parent);
            context.ClearReport();
        }
Example #3
0
        private static void ReadResource(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineResource(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementResource, parent);
            context.ClearResource();
        }
Example #4
0
        private static void ReadTarget(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineTarget(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementTarget, parent);
            context.ClearTarget();
        }
Example #5
0
        private static void ReadMember(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineMember(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementMember, parent);
            context.ClearMember();
        }
Example #6
0
        private static void ReadResolution(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineResolution(
                name: reader.ReadAttributeString(SchemaStrings.AttributeName),
                formatString: reader.ReadElementContentAsString());
        }
Example #7
0
        private void ReadRule(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineRule(
                typeName: reader.ReadAttributeString(SchemaStrings.AttributeTypeName),
                category: reader.ReadAttributeString(SchemaStrings.AttributeCategory),
                checkId: reader.ReadAttributeString(SchemaStrings.AttributeCheckId));

            reader.ReadChildren(SchemaStrings.ElementRule, parent);

            if (RuleRead != null)
            {
                RuleRead(context);
            }

            context.ClearRule();
        }
Example #8
0
        private void ReadMessage(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            string messageId   = reader.ReadAttributeString(SchemaStrings.AttributeId);
            string typename    = reader.ReadAttributeString(SchemaStrings.AttributeTypeName);
            string category    = reader.ReadAttributeString(SchemaStrings.AttributeCategory);
            string checkId     = reader.ReadAttributeString(SchemaStrings.AttributeCheckId);
            string fixCategory = reader.ReadAttributeString(SchemaStrings.AttributeFixCategory);
            string status      = reader.ReadAttributeString(SchemaStrings.AttributeStatus);

            context.RefineMessage(checkId, typename, messageId, category, fixCategory, status);

            if ("Excluded".Equals(status) || "ExcludedInSource".Equals(status))
            {
                // FxCop doesn't actually emit message details for most excluded items
                // and so we must fire here for these items, as the scan for child
                // <Issue> elements may not produce anything. FxCop seems to emit
                // issues for excluded items which are at the namespace level only.
                if (ResultRead != null)
                {
                    ResultRead(context);
                }
            }

            reader.ReadChildren(SchemaStrings.ElementMessage, parent);

            context.ClearMessage();
        }
Example #9
0
        private void ReadIssue(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            string name      = reader.ReadAttributeString(SchemaStrings.AttributeName);
            string certainty = reader.ReadAttributeString(SchemaStrings.AttributeCertainty);
            string level     = reader.ReadAttributeString(SchemaStrings.AttributeLevel);

            string path = reader.ReadAttributeString(SchemaStrings.AttributePath);
            string file = reader.ReadAttributeString(SchemaStrings.AttributeFile);
            int?   line = reader.ReadAttributeInt(SchemaStrings.AttributeLine);

            string message = reader.ReadElementContentAsString();

            context.RefineIssue(message, name, certainty, level, path, file, line);

            if (IssueRead != null)
            {
                IssueRead(context);
            }

            context.ClearIssue();
        }
Example #10
0
        private void ReadIssue(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            string resolutionName = reader.ReadAttributeString(SchemaStrings.AttributeName);
            string certainty      = reader.ReadAttributeString(SchemaStrings.AttributeCertainty);
            string level          = reader.ReadAttributeString(SchemaStrings.AttributeLevel);

            string path = reader.ReadAttributeString(SchemaStrings.AttributePath);
            string file = reader.ReadAttributeString(SchemaStrings.AttributeFile);
            int?   line = reader.ReadAttributeInt(SchemaStrings.AttributeLine);

            string message = null;

            if (_readingProjectFile)
            {
                // FxCop does not emit a resolution name attribute in cases where it is "Default"
                resolutionName = resolutionName ?? "Default";
                reader.ReadChildren(SchemaStrings.ElementIssue, parent, out message);
                context.RefineIssue(message, message == null ? resolutionName : null, certainty, level, path, file, line);
            }
            else
            {
                // An FxCop project file Issue has a fully-formed output
                // message as its element content.
                message = reader.ReadElementContentAsString();
                context.RefineIssue(message, resolutionName, certainty, level, path, file, line);
            }

            if (ResultRead != null)
            {
                ResultRead(context);
            }

            context.ClearIssue();
        }
Example #11
0
        private static void ReadType(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            if (context.Exception)
            {
                ReadExceptionType(reader, parent);
            }
            else
            {
                context.RefineType(reader.ReadAttributeString(SchemaStrings.AttributeName));
                reader.ReadChildren(SchemaStrings.ElementType, parent);
                context.ClearType();
            }
        }
Example #12
0
        private void ReadException(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            string ruleId = reader.ReadAttributeString(SchemaStrings.AttributeKeyword);
            string kind = reader.ReadAttributeString(SchemaStrings.AttributeKind);
            string checkId = reader.ReadAttributeString(SchemaStrings.AttributeCheckId);
            string target = reader.ReadAttributeString(SchemaStrings.AttributeTarget);

            context.RefineException(true, ruleId, target);

            reader.ReadChildren(SchemaStrings.ElementException, parent);

            string exception = MakeExceptionMessage(kind, checkId, context.ExceptionType, context.ExceptionMessage, context.StackTrace, context.InnerExceptionType, context.InnerExceptionMessage, context.InnerStackTrace);
            context.RefineIssue(exception, null, null, null, null, null, null);

            if (ResultRead != null)
            {
                ResultRead(context);
            }

            context.ClearIssue();
            context.ClearException();
        }
Example #13
0
        private static void ReadFxCopReport(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineReport(reader.ReadAttributeString(SchemaStrings.AttributeVersion));
            reader.ReadChildren(SchemaStrings.ElementFxCopReport, parent);
            context.ClearReport();
        }
Example #14
0
        private static void ReadResource(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineResource(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementResource, parent);
            context.ClearResource();
        }
Example #15
0
        private static void ReadType(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            if (context.Exception)
            {
                ReadExceptionType(reader, parent);
            }
            else
            {
                context.RefineType(reader.ReadAttributeString(SchemaStrings.AttributeName));
                reader.ReadChildren(SchemaStrings.ElementType, parent);
                context.ClearType();
            }
        }
Example #16
0
        private static void ReadTarget(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineTarget(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementTarget, parent);
            context.ClearTarget();
        }
Example #17
0
        private void ReadException(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            string ruleId = reader.ReadAttributeString(SchemaStrings.AttributeKeyword);
            string kind = reader.ReadAttributeString(SchemaStrings.AttributeKind);
            string checkId = reader.ReadAttributeString(SchemaStrings.AttributeCheckId);
            string target = reader.ReadAttributeString(SchemaStrings.AttributeTarget);

            context.RefineException(true, ruleId, target);

            reader.ReadChildren(SchemaStrings.ElementException, parent);

            string exception = MakeExceptionMessage(kind, checkId, context.ExceptionType, context.ExceptionMessage, context.StackTrace, context.InnerExceptionType, context.InnerExceptionMessage, context.InnerStackTrace);
            context.RefineIssue(exception, null, null, null, null, null, null);

            if (ResultRead != null)
            {
                ResultRead(context);
            }

            context.ClearIssue();
            context.ClearException();
        }
Example #18
0
        private static void ReadMember(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineMember(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementMember, parent);
            context.ClearMember();
        }
Example #19
0
        private void ReadIssue(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            string name = reader.ReadAttributeString(SchemaStrings.AttributeName);
            string certainty = reader.ReadAttributeString(SchemaStrings.AttributeCertainty);
            string level = reader.ReadAttributeString(SchemaStrings.AttributeLevel);

            string path = reader.ReadAttributeString(SchemaStrings.AttributePath);
            string file = reader.ReadAttributeString(SchemaStrings.AttributeFile);
            int? line = reader.ReadAttributeInt(SchemaStrings.AttributeLine);

            string message = reader.ReadElementContentAsString();

            context.RefineIssue(message, name, certainty, level, path, file, line);

            if (ResultRead != null)
            {
                ResultRead(context);
            }

            context.ClearIssue();
        }
Example #20
0
        private void ReadNamespace(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            context.RefineNamespace(reader.ReadAttributeString(SchemaStrings.AttributeName));
            reader.ReadChildren(SchemaStrings.ElementNamespace, parent);
            context.ClearNamespace();
        }
Example #21
0
        private void ReadMessage(SparseReader reader, object parent)
        {
            Context context = (Context)parent;

            string messageId = reader.ReadAttributeString(SchemaStrings.AttributeId);
            string typename = reader.ReadAttributeString(SchemaStrings.AttributeTypeName);
            string category = reader.ReadAttributeString(SchemaStrings.AttributeCategory);
            string checkId = reader.ReadAttributeString(SchemaStrings.AttributeCheckId);
            string fixCategory = reader.ReadAttributeString(SchemaStrings.AttributeFixCategory);
            string status = reader.ReadAttributeString(SchemaStrings.AttributeStatus);

            context.RefineMessage(checkId, typename, messageId, category, fixCategory, status);

            if ("Excluded".Equals(status) || "ExcludedInSource".Equals(status))
            {
                // FxCop doesn't actually emit message details for most excluded items
                // and so we must fire here for these items, as the scan for child
                // <Issue> elements may not produce anything. FxCop seems to emit
                // issues for excluded items which are at the namespace level only.
                if (ResultRead != null)
                {
                    ResultRead(context);
                }
            }

            reader.ReadChildren(SchemaStrings.ElementMessage, parent);

            context.ClearMessage();
        }