Smokey '/Library/Frameworks/Mono.framework/Versions/1.2.4/lib/mono/gac/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll' report: 1. TypeName: InfiniteRecursion CheckID: SU1000 Category: Usage Kind: Error Location: get_TypeInference in XmlSchemaInference.cs:96 Cause: A method is calling itself directly or indirectly an infinite number of times. Rule Description: A method that is recursively calling itself an infinite number of times will use an infinite amount of CPU and stack space. This is rarely a good thing. How to Fix Violations: Either remove the recursion or add a base case to terminate the recursion. C# Example: public class Recursion { public override int GetHashCode() { return base.GetHashCode(); // this is fine, but would be bad without the base. } public static int Fibonacci(int n) { if (n < 2) // base case terminates the recursion return n; return Fibonacci(n - 1) + Fibonacci(n - 2); } } 2-8. TypeName: NullDeref CheckID: SU1001 Category: Usage Kind: Error Location: MakeBaseTypeAsEmptiable in XmlSchemaInference.cs:585 SplitList in XmlSchemaUtil.cs:275 GenerateSerializers in SerializationCodeGenerator.cs:186 GetTypeNamespace in XmlReflectionImporter.cs:439 SetMapBaseType in XmlSchemaImporter.cs:284 CheckChoiceType in XmlSchemaImporter.cs:1489 Find in XmlSchemas.cs:176 Cause: A method is using a reference which is sometimes null. Rule Description: If a reference is initialized to null then all of the code paths leading to the use of that method have to set it to a non-null value. How to Fix Violations: Either check to see if the reference is null before using it or ensure that it is always set before using it. C# Example: public class Create { public StreamWriter Writer(string path, bool truncate, bool open) { FileStream stream = null; StreamWriter writer = null; if (truncate && open) stream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write); else stream = new FileStream(path, FileMode.Truncate, FileAccess.Write); if (stream != null) // need the if because not all code paths create a stream { stream.Seek(0, SeekOrigin.End); writer = new StreamWriter(stream); } return writer; } } 9. TypeName: EqualsRequiresNullCheck1 CheckID: SU1002 Category: Usage Kind: Error Location: op_Equality in BuiltInDatatype.cs:1670 Cause: A class Equals or operator== method is not checking its arguments for null. Rule Description: The Equals and operator== methods should not throw exceptions so it's important to check that the arguments are null before calling any methods on the arguments. See the code below for how Microsoft recommends implementing these methods or for more details. How to Fix Violations: Check the arguments for null. C# Example: class Customer { public override bool Equals(object rhsObj) { if (rhsObj == null) // as is a little expensive, so skip it if we can return false; Customer rhs = rhsObj as Customer; if ((object) rhs == null) // null checks should be done via object to avoid infinite recursion return false; return name == rhs.name && address == rhs.address; } public bool Equals(Customer rhs) // provide a typed overload for efficiency { if ((object) rhs == null) return false; return name == rhs.name && address == rhs.address; } public static bool operator==(Customer lhs, Customer rhs) { // If both are null, or both are the same instance, return true. if (object.ReferenceEquals(lhs, rhs)) return true; // If one is null, but not both, return false. if ((object) lhs == null || (object) rhs == null) return false; // Return true if the fields match: return lhs.name == rhs.name && lhs.address == rhs.address; } public static bool operator!=(Customer lhs, Customer rhs) { return !(lhs == rhs); } private string name, address; } 10. TypeName: EqualsCantCast1 CheckID: SU1004 Category: Usage Kind: Error Location: Equals in XmlTypeMapElementInfo.cs:168 Cause: An class Equals method is throwing an exception via a cast expression. Rule Description: The Equals method should not throw exceptions so cast expressions should not be used. See the code below for how Microsoft recommends implementing these methods or for more details. How to Fix Violations: Use an as expression (note that checking the types with GetType is not recommended because classes may be subclassed). C# Example: class Customer { public override bool Equals(object rhsObj) { if (rhsObj == null) // as is a little expensive, so skip it if we can return false; Customer rhs = rhsObj as Customer; if ((object) rhs == null) // null checks should be done via object to avoid infinite recursion return false; return name == rhs.name && address == rhs.address; } public bool Equals(Customer rhs) // provide a typed overload for efficiency { if ((object) rhs == null) return false; return name == rhs.name && address == rhs.address; } public static bool operator==(Customer lhs, Customer rhs) { // If both are null, or both are the same instance, return true. if (object.ReferenceEquals(lhs, rhs)) return true; // If one is null, but not both, return false. if ((object) lhs == null || (object) rhs == null) return false; // Return true if the fields match: return lhs.name == rhs.name && lhs.address == rhs.address; } public static bool operator!=(Customer lhs, Customer rhs) { return !(lhs == rhs); } private string name, address; } 11-164. TypeName: MethodCanBeMadeStatic CheckID: SP1001 Category: Performance Kind: Warning Location: yyExpecting in Parser.cs:287 yyDefault in Parser.cs:337 println in Parser.cs:1169 yyExpecting in PatternParser.cs:288 yyDefault in PatternParser.cs:338 println in PatternParser.cs:1165 IsNodeType in PatternTokenizer.cs:475 IsOperatorName in PatternTokenizer.cs:488 IsAxisName in PatternTokenizer.cs:501 IsWhitespace in DTMXPathDocumentWriter.cs:663 IsWhitespace in DTMXPathDocumentWriter2.cs:750 ParseLang in Compiler.cs:696 ParseDataType in Compiler.cs:701 ParseOrder in Compiler.cs:714 ParseCaseOrder in Compiler.cs:727 IsHtmlElement in HtmlEmitter.cs:206 FormatErrorMessage in ScriptCompilerInfo.cs:123 MoveNavigatorToNext in XslKey.cs:142 AddIndex in XslKey.cs:189 ParseMappedPrefixes in XslStylesheet.cs:174 HasStripSpace in XslStylesheet.cs:226 Resolve in XslFunctions.cs:252 IndexInParent in XslFunctions.cs:531 Choice in DTDObjectModel.cs:550 GetCharacterReference in DTDReader.cs:723 SkipWhitespace in XmlDeclaration.cs:132 GetNodeTypeFromString in XmlDocument.cs:533 ParseName in XmlDocument.cs:768 MakeReaderErrorMessage in XmlDocument.cs:982 GetParentNode in XmlDocumentNavigator.cs:750 HasFeature in XmlImplementation.cs:60 CompareString in XmlNamespaceManager.cs:316 IsContent in XmlReader.cs:509 GetBase64Byte in XmlReaderBinarySupport.cs:282 SkipIgnorableBase64Chars in XmlReaderBinarySupport.cs:301 EscapeRelativeUriBody in XmlResolver.cs:76 SkipWhitespaceInString in XmlTextReader.cs:2100 UnescapeRelativeUriBody in XmlUrlResolver.cs:85 Round in DefaultContext.cs:1230 IsNodeType in Tokenizer.cs:474 IsOperatorName in Tokenizer.cs:487 IsAxisName in Tokenizer.cs:500 GetXmlReader in XslCompiledTransform.cs:187 ValidateParam in XsltArgumentList.cs:142 MarkAsMixed in XmlSchemaInference.cs:784 CreateElement in XmlSchemaInference.cs:1088 GetSafeNs in XmlSchemaSet.cs:263 GetEnumValue_XmlSchemaForm in XmlSchemaSerializer.cs:139 GetEnumValue_XmlSchemaDerivationMethod in XmlSchemaSerializer.cs:168 GetEnumValue_XmlSchemaUse in XmlSchemaSerializer.cs:1115 GetEnumValue_XmlSchemaContentProcessing in XmlSchemaSerializer.cs:2122 set_BaseItemType in XmlSchemaSimpleTypeList.cs:80 ProcessKeyEntryOne in XmlSchemaValidator.cs:1129 SkipWhitespace in XmlSchemaXPath.cs:265 AddClassAttributes in MapCodeGenerator.cs:594 CreateError in ReflectionHelper.cs:71 GenerateGetListCount in SerializationCodeGenerator.cs:1056 IsReadOnly in SerializationCodeGenerator.cs:2090 GetArrayDeclaration in SerializationCodeGenerator.cs:2279 GenerateInitializeList in SerializationCodeGenerator.cs:2320 GetCast in SerializationCodeGenerator.cs:2725 GetCast in SerializationCodeGenerator.cs:2730 GetTypeOf in SerializationCodeGenerator.cs:2735 GetTypeOf in SerializationCodeGenerator.cs:2740 Params in SerializationCodeGenerator.cs:2823 FindHook in SerializationCodeGeneratorConfiguration.cs:105 GetKey in SoapAttributeOverrides.cs:89 AddMappingMetadata in SoapCodeExporter.cs:113 ImportMembersMapping in SoapSchemaImporter.cs:113 CreateTypeException in SoapReflectionImporter.cs:499 CreateStructException in SoapReflectionImporter.cs:504 GetDefaultValue in SoapReflectionImporter.cs:509 GetKey in XmlAttributeOverrides.cs:78 AddMappingMetadata in XmlCodeExporter.cs:119 get_TypeName in XmlMembersMapping.cs:87 get_TypeNamespace in XmlMembersMapping.cs:92 ImportTextElementInfo in XmlReflectionImporter.cs:1049 CanBeNull in XmlReflectionImporter.cs:1082 GetDefaultValue in XmlReflectionImporter.cs:1112 ExportAnyType in XmlSchemaExporter.cs:69 ExportTypeMapping in XmlSchemaExporter.cs:190 FindElement in XmlSchemaExporter.cs:380 FindComplexType in XmlSchemaExporter.cs:390 ImportNamespace in XmlSchemaExporter.cs:563 GetSchemaXmlNodeType in XmlSchemaExporter.cs:586 GetSchemaXmlSerializableType in XmlSchemaExporter.cs:596 GetSchemaSimpleListType in XmlSchemaExporter.cs:614 ExportDefaultValue in XmlSchemaExporter.cs:651 CompileSchemas in XmlSchemaExporter.cs:845 InitializeExtensions in XmlSchemaImporter.cs:174 ImportMembersMapping in XmlSchemaImporter.cs:354 ImportSchemaType in XmlSchemaImporter.cs:360 ImportSchemaType in XmlSchemaImporter.cs:366 ImportSchemaType in XmlSchemaImporter.cs:372 ImportMembersMapping in XmlSchemaImporter.cs:440 CollectAttributeUsesNonOverlap in XmlSchemaImporter.cs:744 GetContentBaseType in XmlSchemaImporter.cs:1248 CanBeAnyElement in XmlSchemaImporter.cs:1501 CanBeIXmlSerializable in XmlSchemaImporter.cs:1534 CreateElementInfo in XmlSchemaImporter.cs:1567 GetDocumentation in XmlSchemaImporter.cs:1885 get_IsCompiled in XmlSchemas.cs:81 Find in XmlSchemas.cs:156 EnsureArrayList in XmlSerializationReader.cs:101 EnsureHashtable in XmlSerializationReader.cs:108 get_IsReturnValue in XmlSerializationReader.cs:135 set_IsReturnValue in XmlSerializationReader.cs:138 CreateCtorHasSecurityException in XmlSerializationReader.cs:217 CreateInaccessibleConstructorException in XmlSerializationReader.cs:228 CreateInvalidCastException in XmlSerializationReader.cs:242 CreateReadOnlyCollectionException in XmlSerializationReader.cs:249 CreateUnknownConstantException in XmlSerializationReader.cs:256 EnsureArrayIndex in XmlSerializationReader.cs:274 FixupArrayRefs in XmlSerializationReader.cs:294 GetArrayLength in XmlSerializationReader.cs:300 IsXmlnsAttribute in XmlSerializationReader.cs:362 ShrinkArray in XmlSerializationReader.cs:791 get_DecodeName in XmlSerializationReader.cs:1115 set_DecodeName in XmlSerializationReader.cs:1116 CollapseWhitespace in XmlSerializationReader.cs:1122 CreateBadDerivationException in XmlSerializationReader.cs:1134 CreateInvalidCastException in XmlSerializationReader.cs:1140 CreateMissingIXmlSerializableType in XmlSerializationReader.cs:1146 ReadString in XmlSerializationReader.cs:1152 ReadTypedNull in XmlSerializationReader.cs:1158 IsReadOnly in XmlSerializationReaderInterpreter.cs:577 SetMemberValue in XmlSerializationReaderInterpreter.cs:583 GetMemberValue in XmlSerializationReaderInterpreter.cs:604 CreateInstance in XmlSerializationReaderInterpreter.cs:748 InitializeList in XmlSerializationReaderInterpreter.cs:761 CreateChoiceIdentifierValueException in XmlSerializationWriter.cs:118 CreateInvalidChoiceIdentifierValueException in XmlSerializationWriter.cs:127 CreateMismatchChoiceException in XmlSerializationWriter.cs:135 CreateUnknownAnyElementException in XmlSerializationWriter.cs:141 CreateUnknownTypeException in XmlSerializationWriter.cs:152 WriteRpcResult in XmlSerializationWriter.cs:746 CreateInvalidAnyTypeException in XmlSerializationWriter.cs:921 CreateInvalidAnyTypeException in XmlSerializationWriter.cs:927 CreateInvalidEnumValueException in XmlSerializationWriter.cs:932 FromXmlQualifiedName in XmlSerializationWriter.cs:944 WriteSerializable in XmlSerializationWriter.cs:956 get_EscapeName in XmlSerializationWriter.cs:962 set_EscapeName in XmlSerializationWriter.cs:963 GetMemberValue in XmlSerializationWriterInterpreter.cs:275 GetListCount in XmlSerializationWriterInterpreter.cs:442 GetEnumXmlValue in XmlSerializationWriterInterpreter.cs:502 Deserialize in XmlSerializer.cs:486 Deserialize in XmlSerializer.cs:492 Deserialize in XmlSerializer.cs:498 Serialize in XmlSerializer.cs:549 LoadFromSatelliteAssembly in XmlSerializer.cs:787 CreateSerializer in XmlSerializerFactory.cs:54 CreateSerializer in XmlSerializerFactory.cs:91 CreateSerializer in XmlSerializerFactory.cs:112 Cause: An instance method calls no instance methods and refers to no instance fields. Rule Description: Instance methods require a this pointer so that they can reference fields associated with the object. When an instance method is called the caller must push the this pointer onto the stack. But if the method never makes use of the this pointer it's pointless to push it. Now this doesn't sound like much, but dense code is very important on modern processors and if saving a few bytes means your time critical code now fits into the LI cache it will be a big win. How to Fix Violations: Make the method static. C# Example: public class LoadXml { public LoadXml(Stream schemaStream) { m_settings = new XmlReaderSettings(); m_settings.Schemas.Add(XmlSchema.Read(schemaStream, DoValidationEvent)); m_settings.ValidationEventHandler += DoValidationEvent; m_settings.ValidationType = ValidationType.Schema; } public XmlDocument Load(Stream xmlStream) { XmlDocument xml = new XmlDocument(); xml.Load(XmlReader.Create(xmlStream, m_settings)); return xml; } // This method doesn't use instance methods/fields so it should be static. private static void DoValidationEvent(object sender, ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Warning) Console.WriteLine(e.Message); else throw e.Exception; } private XmlReaderSettings m_settings; } 165-421. TypeName: UseStringEmpty CheckID: SP1002 Category: Performance Kind: Warning Location: ParseIdentifier in PatternTokenizer.cs:222 System.Void Mono.Xml.Schema.XsdIdentityStep::.ctor() FillAttributeFieldValue in XsdIdentityState.cs:194 MatchesNamespace in XsdParticleValidationState.cs:637 ReadExternalSchema in XsdValidatingReader.cs:1470 ValidateWildcardAllowsNamespaceName in XsdWildcard.cs:183 ValidateWildcardSubset in XsdWildcard.cs:211 Compile in DTMXPathDocumentBuilder.cs:157 ProcessElement in DTMXPathDocumentBuilder.cs:305 WriteStartElement in DTMXPathDocumentBuilder.cs:345 Init in DTMXPathDocumentWriter.cs:116 WriteStartElement in DTMXPathDocumentWriter.cs:493 WriteStartAttribute in DTMXPathDocumentWriter.cs:544 get_Name in DTMXPathNavigator.cs:165 Compile in DTMXPathDocumentBuilder2.cs:164 ProcessElement in DTMXPathDocumentBuilder2.cs:331 AtomicIndex in DTMXPathDocumentBuilder2.cs:444 NonAtomicIndex in DTMXPathDocumentBuilder2.cs:464 Init in DTMXPathDocumentWriter2.cs:125 AtomicIndex in DTMXPathDocumentWriter2.cs:204 NonAtomicIndex in DTMXPathDocumentWriter2.cs:224 WriteStartElement in DTMXPathDocumentWriter2.cs:572 WriteStartAttribute in DTMXPathDocumentWriter2.cs:626 get_Name in DTMXPathNavigator2.cs:158 ToString in LocationPathPattern.cs:149 Evaluate in XslAttribute.cs:132 System.Void Mono.Xml.Xsl.Operations.XslNumber/XslNumberFormatter::.ctor(System.String,System.String,System.String,System.Char,System.Int32) System.Void Mono.Xml.Xsl.Operations.XslText::.ctor(Mono.Xml.Xsl.Compiler,System.Boolean) System.Void Mono.Xml.Xsl.Operations.XslVariableInformation::.ctor(Mono.Xml.Xsl.Compiler) Evaluate in XslVariable.cs:114 System.Xml.Xsl.IStaticXsltContext.TryGetFunction in Compiler.cs:550 Compile in Compiler.cs:147 AssertAttribute in Compiler.cs:331 CompilePattern in Compiler.cs:349 CompileExpression in Compiler.cs:366 IsExtensionNamespace in Compiler.cs:459 GetNamespacesToCopy in Compiler.cs:496 LookupNamespace in Compiler.cs:578 CompileOutput in Compiler.cs:593 FromString in Compiler.cs:798 FromString in Compiler.cs:823 FromString in Compiler.cs:835 WriteStartElement in GenericOutputter.cs:245 WriteAttributeString in Outputter.cs:57 WriteStartDocument in XmlWriterEmitter.cs:60 Compile in XslStylesheet.cs:147 ProcessTopLevelElements in XslStylesheet.cs:522 GetDocument in XslFunctions.cs:273 GetDocument in XslFunctions.cs:295 Evaluate in XslFunctions.cs:609 get_XmlSpace in XmlNodeWriter.cs:112 get_EntityValue in DTDObjectModel.cs:1141 ReadDoctype in DTDValidatingReader2.cs:807 System.Void System.Xml.XmlAttribute::.ctor(System.String,System.String,System.String,System.Xml.XmlDocument,System.Boolean,System.Boolean) System.Void System.Xml.XmlDeclaration::.ctor(System.String,System.String,System.String,System.Xml.XmlDocument) get_Value in XmlDeclaration.cs:98 get_TextEncoding in XmlDocument.cs:244 CreateAttribute in XmlDocument.cs:296 ParseName in XmlDocument.cs:775 System.Void System.Xml.XmlDocumentType::.ctor(System.String,System.String,System.String,System.String,System.Xml.XmlDocument) LookupNamespace in XmlNamespaceManager.cs:292 GetAttribute in XmlNodeReaderImpl.cs:370 LookupNamespace in XmlNodeReaderImpl.cs:527 System.Void System.Xml.XmlParserContext::.ctor(System.Xml.XmlNameTable,System.Xml.XmlNamespaceManager,System.String,System.String,System.String,System.String,System.String,System.String,System.Xml.XmlSpace,System.Text.Encoding) System.Void System.Xml.XmlQualifiedName::.ctor(System.String,System.String) WriteAttributeString in XmlWriter.cs:222 WriteAttributeString in XmlWriter.cs:227 System.Void System.Xml.XPath.XPathException::.ctor() ToString in DefaultContext.cs:101 Evaluate in DefaultContext.cs:296 Evaluate in DefaultContext.cs:346 Evaluate in DefaultContext.cs:383 Evaluate in DefaultContext.cs:420 Evaluate in DefaultContext.cs:602 Evaluate in DefaultContext.cs:638 Evaluate in DefaultContext.cs:677 System.Void System.Xml.XPath.XPathSorter/XPathTextComparer::.ctor(System.Xml.XPath.XmlSortOrder,System.Xml.XPath.XmlCaseOrder,System.String) EvaluateString in Expression.cs:548 ToString in Expression.cs:1285 Match in Expression.cs:1624 GetInfo in Expression.cs:1657 Factory in Expression.cs:1989 ToString in Expression.cs:2025 ParseIdentifier in Tokenizer.cs:221 ReadAttributes in XmlSchema.cs:750 Read in XmlSchemaAll.cs:273 Read in XmlSchemaAnnotation.cs:124 Compile in XmlSchemaAny.cs:138 Read in XmlSchemaAny.cs:323 Compile in XmlSchemaAnyAttribute.cs:118 Read in XmlSchemaAnyAttribute.cs:191 Compile in XmlSchemaAttribute.cs:289 Read in XmlSchemaAttribute.cs:540 Read in XmlSchemaAttributeGroup.cs:236 Read in XmlSchemaAttributeGroupRef.cs:118 Read in XmlSchemaChoice.cs:318 Read in XmlSchemaComplexContent.cs:156 Read in XmlSchemaComplexContentExtension.cs:234 Read in XmlSchemaComplexContentRestriction.cs:225 get_AnyType in XmlSchemaComplexType.cs:68 Read in XmlSchemaComplexType.cs:1108 Normalize in XmlSchemaDatatype.cs:130 ValidateUniqueParticleAttribution in XmlSchemaElement.cs:910 Read in XmlSchemaElement.cs:1121 Read in XmlSchemaEnumerationFacet.cs:78 GetMessage in XmlSchemaException.cs:164 Read in XmlSchemaFractionDigitsFacet.cs:86 Read in XmlSchemaGroup.cs:187 Read in XmlSchemaGroupRef.cs:256 Read in XmlSchemaImport.cs:95 Read in XmlSchemaInclude.cs:82 CollectAttrTable in XmlSchemaInference.cs:309 Read in XmlSchemaKey.cs:90 Read in XmlSchemaKeyref.cs:137 Read in XmlSchemaLengthFacet.cs:86 Read in XmlSchemaMaxExclusiveFacet.cs:86 Read in XmlSchemaMaxInclusiveFacet.cs:86 Read in XmlSchemaMaxLengthFacet.cs:87 Read in XmlSchemaMinExclusiveFacet.cs:86 Read in XmlSchemaMinInclusiveFacet.cs:86 Read in XmlSchemaMinLengthFacet.cs:87 Read in XmlSchemaNotation.cs:146 Read in XmlSchemaPatternFacet.cs:78 Read in XmlSchemaRedefine.cs:111 GetSafeNs in XmlSchemaSet.cs:264 Read in XmlSchemaSequence.cs:335 WriteObject_XmlSchema in XmlSchemaSerializer.cs:57 WriteObject_XmlSchemaForm in XmlSchemaSerializer.cs:133 WriteObject_XmlSchemaDerivationMethod in XmlSchemaSerializer.cs:162 GetEnumValue_XmlSchemaDerivationMethod in XmlSchemaSerializer.cs:170 WriteObject_XmlSchemaInclude in XmlSchemaSerializer.cs:230 WriteObject_XmlSchemaImport in XmlSchemaSerializer.cs:268 WriteObject_XmlSchemaRedefine in XmlSchemaSerializer.cs:307 WriteObject_XmlSchemaElement in XmlSchemaSerializer.cs:365 WriteObject_XmlSchemaSimpleType in XmlSchemaSerializer.cs:452 WriteObject_XmlSchemaAttribute in XmlSchemaSerializer.cs:502 WriteObject_XmlSchemaAnnotation in XmlSchemaSerializer.cs:556 WriteObject_XmlSchemaAttributeGroup in XmlSchemaSerializer.cs:603 WriteObject_XmlSchemaGroup in XmlSchemaSerializer.cs:654 WriteObject_XmlSchemaComplexType in XmlSchemaSerializer.cs:701 WriteObject_XmlSchemaNotation in XmlSchemaSerializer.cs:782 WriteObject_XmlSchemaKeyref in XmlSchemaSerializer.cs:822 WriteObject_XmlSchemaKey in XmlSchemaSerializer.cs:867 WriteObject_XmlSchemaUnique in XmlSchemaSerializer.cs:911 WriteObject_XmlSchemaSimpleTypeUnion in XmlSchemaSerializer.cs:955 WriteObject_XmlSchemaSimpleTypeList in XmlSchemaSerializer.cs:1006 WriteObject_XmlSchemaSimpleTypeRestriction in XmlSchemaSerializer.cs:1045 WriteObject_XmlSchemaUse in XmlSchemaSerializer.cs:1109 WriteObject_XmlSchemaAppInfo in XmlSchemaSerializer.cs:1150 WriteObject_XmlSchemaDocumentation in XmlSchemaSerializer.cs:1186 WriteObject_XmlSchemaAttributeGroupRef in XmlSchemaSerializer.cs:1231 WriteObject_XmlSchemaAnyAttribute in XmlSchemaSerializer.cs:1269 WriteObject_XmlSchemaSequence in XmlSchemaSerializer.cs:1310 WriteObject_XmlSchemaChoice in XmlSchemaSerializer.cs:1370 WriteObject_XmlSchemaAll in XmlSchemaSerializer.cs:1430 WriteObject_XmlSchemaComplexContent in XmlSchemaSerializer.cs:1474 WriteObject_XmlSchemaSimpleContent in XmlSchemaSerializer.cs:1519 WriteObject_XmlSchemaGroupRef in XmlSchemaSerializer.cs:1561 WriteObject_XmlSchemaXPath in XmlSchemaSerializer.cs:1601 WriteObject_XmlSchemaMaxLengthFacet in XmlSchemaSerializer.cs:1641 WriteObject_XmlSchemaMinLengthFacet in XmlSchemaSerializer.cs:1682 WriteObject_XmlSchemaLengthFacet in XmlSchemaSerializer.cs:1723 WriteObject_XmlSchemaFractionDigitsFacet in XmlSchemaSerializer.cs:1764 WriteObject_XmlSchemaMaxInclusiveFacet in XmlSchemaSerializer.cs:1805 WriteObject_XmlSchemaMaxExclusiveFacet in XmlSchemaSerializer.cs:1846 WriteObject_XmlSchemaMinExclusiveFacet in XmlSchemaSerializer.cs:1887 WriteObject_XmlSchemaEnumerationFacet in XmlSchemaSerializer.cs:1928 WriteObject_XmlSchemaTotalDigitsFacet in XmlSchemaSerializer.cs:1969 WriteObject_XmlSchemaMinInclusiveFacet in XmlSchemaSerializer.cs:2010 WriteObject_XmlSchemaWhiteSpaceFacet in XmlSchemaSerializer.cs:2051 WriteObject_XmlSchemaPatternFacet in XmlSchemaSerializer.cs:2092 WriteObject_XmlSchemaContentProcessing in XmlSchemaSerializer.cs:2116 WriteObject_XmlSchemaAny in XmlSchemaSerializer.cs:2163 WriteObject_XmlSchemaComplexContentExtension in XmlSchemaSerializer.cs:2206 WriteObject_XmlSchemaComplexContentRestriction in XmlSchemaSerializer.cs:2269 WriteObject_XmlSchemaSimpleContentExtension in XmlSchemaSerializer.cs:2332 WriteObject_XmlSchemaSimpleContentRestriction in XmlSchemaSerializer.cs:2383 Read in XmlSchemaSimpleContent.cs:130 Read in XmlSchemaSimpleContentExtension.cs:211 Read in XmlSchemaSimpleContentRestriction.cs:244 Read in XmlSchemaSimpleType.cs:594 Read in XmlSchemaSimpleTypeList.cs:194 Read in XmlSchemaSimpleTypeRestriction.cs:841 Read in XmlSchemaSimpleTypeUnion.cs:230 Read in XmlSchemaTotalDigitsFacet.cs:86 Read in XmlSchemaUnique.cs:94 Read in XmlSchemaWhiteSpaceFacet.cs:86 Read in XmlSchemaXPath.cs:333 ReadUnhandledAttribute in XmlSchemaUtil.cs:286 ParseWsdlArrayType in XmlSchemaUtil.cs:299 ReadDerivationAttribute in XmlSchemaUtil.cs:344 ToQName in XmlSchemaUtil.cs:486 AttributeWildcardItemValid in XmlSchemaUtil.cs:669 MakeValid in CodeIdentifier.cs:64 ExportEnumCode in MapCodeGenerator.cs:501 AddComments in MapCodeGenerator.cs:581 RegisterClrType in ReflectionHelper.cs:56 GetRegisteredClrType in ReflectionHelper.cs:64 Generate in SerializationCodeGenerator.cs:95 GenerateSerializers in SerializationCodeGenerator.cs:170 GenerateContract in SerializationCodeGenerator.cs:311 GenerateWriteRoot in SerializationCodeGenerator.cs:526 GenerateGetXmlEnumValue in SerializationCodeGenerator.cs:615 GenerateWriteObject in SerializationCodeGenerator.cs:633 GenerateWriteObjectElement in SerializationCodeGenerator.cs:753 GenerateWriteMemberElement in SerializationCodeGenerator.cs:892 GenerateGetArrayType in SerializationCodeGenerator.cs:1065 GenerateWriteInitCallbacks in SerializationCodeGenerator.cs:1257 WriteWriteEnumCallback in SerializationCodeGenerator.cs:1277 WriteWriteObjectCallback in SerializationCodeGenerator.cs:1286 GenerateReadRoot in SerializationCodeGenerator.cs:1388 GenerateReadMessage in SerializationCodeGenerator.cs:1406 GenerateReadObject in SerializationCodeGenerator.cs:1515 GenerateReadClassInstance in SerializationCodeGenerator.cs:1533 GenerateReadAttributeMembers in SerializationCodeGenerator.cs:2008 GenerateReadListElement in SerializationCodeGenerator.cs:2211 GenerateFillerCallbacks in SerializationCodeGenerator.cs:2336 GenerateGetEnumValue in SerializationCodeGenerator.cs:2392 GenerateReadXmlSerializableElement in SerializationCodeGenerator.cs:2429 GenerateReadInitCallbacks in SerializationCodeGenerator.cs:2451 GenerateFixupCallbacks in SerializationCodeGenerator.cs:2470 WriteMultilineCode in SerializationCodeGenerator.cs:2814 Params in SerializationCodeGenerator.cs:2823 FindHook in SerializationCodeGeneratorConfiguration.cs:111 GenerateClass in SoapCodeExporter.cs:156 GenerateEnum in SoapCodeExporter.cs:189 CreateTypeMapping in SoapReflectionImporter.cs:189 GetTypeNamespace in SoapReflectionImporter.cs:297 CreateMapMember in SoapReflectionImporter.cs:445 ParseArrayType in TypeTranslator.cs:307 GenerateClass in XmlCodeExporter.cs:201 System.Void System.Xml.Serialization.XmlMemberMapping::.ctor(System.String,System.String,System.Xml.Serialization.XmlTypeMapMember,System.Boolean) System.Void System.Xml.Serialization.XmlMembersMapping::.ctor(System.Xml.Serialization.XmlMemberMapping[]) CreateTypeMapping in XmlReflectionImporter.cs:286 GetTypeNamespace in XmlReflectionImporter.cs:450 ImportListMapping in XmlReflectionImporter.cs:485 CreateMapMember in XmlReflectionImporter.cs:856 ImportAnyElementInfo in XmlReflectionImporter.cs:1034 ExportArraySchema in XmlSchemaExporter.cs:745 BuildEncodedArrayMap in XmlSchemaImporter.cs:843 ImportChoiceContent in XmlSchemaImporter.cs:1102 ImportXmlSerializableMapping in XmlSchemaImporter.cs:1551 CreateTypeMapping in XmlSchemaImporter.cs:1602 GetTypeData in XmlSchemaImporter.cs:1711 GetDocumentation in XmlSchemaImporter.cs:1885 get_Item in XmlSchemas.cs:74 OnInsert in XmlSchemas.cs:212 OnSet in XmlSchemas.cs:224 ParseWsdlArrayType in XmlSerializationReader.cs:376 ReadAttributeMembers in XmlSerializationReaderInterpreter.cs:273 Initialize in XmlSerializationWriter.cs:82 WriteArray in XmlSerializationWriter.cs:705 WriteObject in XmlSerializationWriterInterpreter.cs:113 WriteMemberElement in XmlSerializationWriterInterpreter.cs:307 WriteAnyElementContent in XmlSerializationWriterInterpreter.cs:462 System.Void System.Xml.Serialization.XmlTypeMapElementInfo::.ctor(System.Xml.Serialization.XmlTypeMapMember,System.Xml.Serialization.TypeData) System.Void System.Xml.Serialization.XmlTypeMapMemberAttribute::.ctor() Cause: An empty string literal was used. Rule Description: String literals are normally coalesced in the assemblies metadata, but when a string literal is used a string object must be created. If the literal is empty you can use the String.Empty member to avoid creating a new string. How to Fix Violations: Use String.Empty. C# Example: public class HelloWorld { private static void Hello() { Console.WriteLine("hello world"); Console.WriteLine(String.Empty); Console.WriteLine("goodbye"); } } 422-429. TypeName: MethodTooComplex CheckID: SM1000 Category: Maintainability Kind: Warning Location: yyparse in Parser.cs:348 yyparse in PatternParser.cs:349 ParseToken in PatternTokenizer.cs:280 ReadInternalSubset in XmlTextReader.cs:2517 WriteEscapedBuffer in XmlTextWriter2.cs:1380 ParseToken in Tokenizer.cs:279 Compile in XmlSchemaElement.cs:353 GenerateReadMembers in SerializationCodeGenerator.cs:1601 Cause: A method has too many code paths. Rule Description: As methods become larger and acquire more and more code paths they become progressively harder to understand. In general, large methods should be refactored to use private helper methods. How to Fix Violations: Refactor the code so that it uses private helper methods. 430-443. TypeName: NewLineLiteral CheckID: SI1000 Category: Interoperability Kind: Warning Location: GetScriptClass in ScriptCompilerInfo.cs:114 FormatErrorMessage in ScriptCompilerInfo.cs:132 get_SourceTemplate in ScriptCompilerInfo.cs:159 FormatSource in ScriptCompilerInfo.cs:185 get_SourceTemplate in ScriptCompilerInfo.cs:210 FormatSource in ScriptCompilerInfo.cs:237 get_SourceTemplate in ScriptCompilerInfo.cs:271 get_LocationMessage in XslTemplate.cs:357 CreateNode in XmlDocument.cs:455 EscapeString in XPathNavigator.cs:899 RaiseInvalidElementError in XmlSchemaReader.cs:62 AddComments in MapCodeGenerator.cs:583 WriteMultilineCode in SerializationCodeGenerator.cs:2814 GetDocumentation in XmlSchemaImporter.cs:1894 Cause: A string literal has an embedded new line character. Rule Description: Different operating systems use different characters to represent the end of a line. Unix uses "\n", Windows uses "\r\n", and Mac OS 9 used "\r". To work well on different OSs you should avoid hard-coding the end of line characters. How to Fix Violations: Use System.Environment.NewLine or a character literal. C# Example: public class Hello { public void Portable() { Console.WriteLine("hello" + Environment.NewLine + "world"); } public void Unix() { Console.WriteLine("hello" + '\n' + "world"); } } 444-445. TypeName: IDisposable CheckID: SU1006 Category: Usage Kind: Warning Location: Dispose in XmlSchemaEnumerator.cs:56 System.Void System.Xml.XPath.XPathNodeIterator/<>c__CompilerGenerated2::Dispose() Cause: A Dispose method does not call GC.SuppressFinalize. Rule Description: IDisposable allows you to support deterministic cleanup of resources via the using statement, but implementing it is a bit tricky. It's strongly recommended that you follow the pattern below. Note that the order in which destructors are called is undefined and any managed objects you have references to may have been garbage collected. Also destructors cannot throw or your app will terminate. And destructors are normally called from a worker thread. How to Fix Violations: The public Dispose method should call GC.SuppressFinalize. C# Example: public class MyResource : IDisposable { ~MyResource() { DoDispose(false); } public MyResource(IntPtr handle) { m_handle = handle; } public void Dispose() { DoDispose(true); // If we've been disposed our object can be garbage collected without // finalization. GC.SuppressFinalize(this); } private void DoDispose(bool disposing) { if (!m_disposed) { // If we've been called via Dispose we can, if (disposing) { // optionally dispose of managed resources here. } // If we've been called via the destructor any references we have to // managed objects may have been garbage collected so we have to be // very careful and only dispose of unmanaged resources. CloseHandle(m_handle); m_handle = IntPtr.Zero; m_disposed = true; } } [System.Runtime.InteropServices.DllImport("Kernel32")] private extern static bool CloseHandle(IntPtr handle); private IntPtr m_handle; private bool m_disposed = false; } 446. TypeName: DontDestroyStackTrace CheckID: SU1007 Category: Usage Kind: Warning Location: Evaluate in XslTemplate.cs:374 Cause: A catch handler is calling throw with the exception it caught. Rule Description: Stack traces are attached to exception objects when the object is thrown, not when it is created. So, if you throw the exception a second time the original stack trace will be lost. How to Fix Violations: Use throw without an object. C# Example: public class WhizBang { public void Run() { try { Console.WriteLine("cool stuff goes here"); } catch (ApplicationException e) { Console.Error.WriteLine(e.Message); throw; // preserves stack crawl of the original error } } public void Run2() { try { Console.WriteLine("more cool stuff"); } catch (ApplicationException e) { Console.Error.WriteLine(e.Message); throw new ApplicationException("cool is buggy", e); // retain original error } } } There were 10 errors and 436 warnings. Checked 10 rules in 41.073 seconds.