Remove unused locals and methods in System.Private.Xml (#39592)
authorMatt Kotsenas <mattkot@microsoft.com>
Thu, 17 Sep 2020 12:28:25 +0000 (05:28 -0700)
committerGitHub <noreply@github.com>
Thu, 17 Sep 2020 12:28:25 +0000 (14:28 +0200)
* Remove unused locals and methods in System.Private.Xml

* Remove unneeded discards and simplify expressions

* Restore #if DEBUG code

36 files changed:
src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlNode.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/SchemaObjectWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilGenerator.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/CopyAction.cs
src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/AppendTests.cs
src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/PrependTests.cs
src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateCDataSectionTests.cs
src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateXmlDeclarationTests.cs
src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/NameTableTests.cs
src/libraries/System.Private.Xml/tests/XmlDocument/XmlNodeTests/NormalizeTests.cs
src/libraries/System.Private.Xml/tests/XmlNodeReader/System.Xml.XmlNodeReader.Tests/XmlNodeReaderConstructionTests.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Constructor_AddSchema.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedAttributes.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedParticles.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs
src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs
src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs

index 10e2003..620603a 100644 (file)
@@ -1511,7 +1511,6 @@ namespace System.Xml
         // Skips to the end tag of the current element.
         public override void Skip()
         {
-            int startDepth = Depth;
             switch (NodeType)
             {
                 case XmlNodeType.Element:
index 2446621..c7ef139 100644 (file)
@@ -346,7 +346,6 @@ namespace System.Xml
         // Skips to the end tag of the current element.
         public override async Task SkipAsync()
         {
-            int startDepth = Depth;
             switch (NodeType)
             {
                 case XmlNodeType.Element:
index 8bd2cbe..f1ccbfc 100644 (file)
@@ -474,7 +474,7 @@ namespace System.Xml
         {
             XmlNode? nextNode = oldChild.NextSibling;
             RemoveChild(oldChild);
-            XmlNode? node = InsertBefore(newChild, nextNode);
+            InsertBefore(newChild, nextNode);
             return oldChild;
         }
 
@@ -846,7 +846,6 @@ namespace System.Xml
         {
             get
             {
-                XmlDocument? doc = OwnerDocument;
                 return HasReadOnlyParent(this);
             }
         }
index e2ce468..5b3f63a 100644 (file)
@@ -1261,7 +1261,6 @@ namespace System.Xml.Schema
             {
                 if (ContentType == XmlSchemaContentType.Mixed)
                 {
-                    string ctype = IsOpen ? "Any" : "TextOnly";
                     return IsOpen ? ContentValidator.Any : ContentValidator.TextOnly;
                 }
                 else
@@ -1281,7 +1280,6 @@ namespace System.Xml.Schema
             _contentNode.ExpandTree(contentRoot, _symbols, _positions);
 
             // calculate followpos
-            int symbolsCount = _symbols.Count;
             int positionsCount = _positions.Count;
             BitSet firstpos = new BitSet(positionsCount);
             BitSet lastpos = new BitSet(positionsCount);
@@ -1880,7 +1878,6 @@ namespace System.Xml.Schema
 
         public override void InitValidation(ValidationState context)
         {
-            int positionsCount = _positions.Count;
             List<RangePositionInfo>? runningPositions = context.RunningPositions;
             if (runningPositions != null)
             {
index 5f53c75..49a8beb 100644 (file)
@@ -474,7 +474,6 @@ namespace System.Xml.Schema
 
             internal void CompileFacetCombinations()
             {
-                RestrictionFacets baseRestriction = _datatype.Restriction!;
                 //They are not allowed on the same type but allowed on derived types.
                 if (
                     (_derivedRestriction.Flags & RestrictionFlags.MaxInclusive) != 0 &&
index ad7d1cc..58e9c0d 100644 (file)
@@ -925,7 +925,7 @@ namespace System.Xml.Schema
                             throw new XmlSchemaInferenceException(SR.SchInf_particle, 0, 0);
                         ct.Particle = new XmlSchemaSequence();
                         bCreatingNewSequence = true;
-                        XmlSchemaElement subelement = AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
+                        AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
                         lastUsedSeqItem = 0;
                         if (!bCreatingNewType)
                             ct.Particle.MinOccurs = 0;    //previously this was simple type so subelements did not exist
@@ -934,7 +934,7 @@ namespace System.Xml.Schema
                     {
                         ct.Particle = new XmlSchemaSequence();
                         bCreatingNewSequence = true;
-                        XmlSchemaElement subelement = AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
+                        AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
                         if (!bCreatingNewType)
                         {
                             ((XmlSchemaSequence)ct.Particle).MinOccurs = decimal.Zero;
@@ -946,7 +946,7 @@ namespace System.Xml.Schema
                     else
                     {
                         bool bParticleChanged = false;
-                        XmlSchemaElement subelement = FindMatchingElement(bCreatingNewType || bCreatingNewSequence, _xtr, ct, ref lastUsedSeqItem, ref bParticleChanged, parentSchema, Maxoccursflag);
+                        FindMatchingElement(bCreatingNewType || bCreatingNewSequence, _xtr, ct, ref lastUsedSeqItem, ref bParticleChanged, parentSchema, Maxoccursflag);
                     }
                 }
                 else if (_xtr.NodeType == XmlNodeType.Text)
index bbf1968..3892522 100644 (file)
@@ -78,7 +78,7 @@ namespace System.Xml.Serialization
             {
                 TypeForwardedFromAttribute? originalAssemblyInfo = typeForwardedFromAttribute[0] as TypeForwardedFromAttribute;
                 Debug.Assert(originalAssemblyInfo != null);
-                Assembly originalAssembly = Assembly.Load(new AssemblyName(originalAssemblyInfo.AssemblyFullName));
+                Assembly.Load(new AssemblyName(originalAssemblyInfo.AssemblyFullName));
             }
         }
 
index c5069e4..fb5e605 100644 (file)
@@ -998,18 +998,6 @@ namespace System.Xml.Serialization
             set { _sequenceId = value; }
         }
 
-        private string GetNullableType(TypeDesc td)
-        {
-            // SOAP encoded arrays not mapped to Nullable<T> since they always derive from soapenc:Array
-            if (td.IsMappedType || (!td.IsValueType && (Elements![0].IsSoap || td.ArrayElementTypeDesc == null)))
-                return td.FullName;
-            if (td.ArrayElementTypeDesc != null)
-            {
-                return GetNullableType(td.ArrayElementTypeDesc) + "[]";
-            }
-            return "System.Nullable`1[" + td.FullName + "]";
-        }
-
         internal MemberMapping Clone()
         {
             return new MemberMapping(this);
index 3de8841..0458a4e 100644 (file)
@@ -1730,7 +1730,6 @@ namespace System.Xml.Serialization
                 }
 
                 Member[] allMembers = allMembersList.ToArray();
-                MemberMapping[] allMemberMappings = allMemberMappingList.ToArray();
 
                 UnknownNodeAction unknownNodeAction = (_) => UnknownNode(o);
                 WriteAttributes(allMembers, anyAttribute, unknownNodeAction, ref o);
index 7ad693f..705dfcb 100644 (file)
@@ -201,7 +201,6 @@ namespace System.Xml.Serialization
                 int anyCount = 0;
                 var namedAnys = new List<ElementAccessor>();
                 ElementAccessor? unnamedAny = null; // can only have one
-                string? enumTypeName = (choice != null) ? choice.Mapping!.TypeDesc!.FullName : null;
 
                 for (int i = 0; i < elements.Length; i++)
                 {
@@ -357,7 +356,6 @@ namespace System.Xml.Serialization
                 }
                 else if (element.IsUnbounded)
                 {
-                    TypeDesc arrayTypeDesc = mapping.TypeDesc!.CreateArrayTypeDesc();
                     var enumerable = (IEnumerable)o!;
                     foreach (var e in enumerable)
                     {
@@ -1217,7 +1215,6 @@ namespace System.Xml.Serialization
                 int xmlnsMember = FindXmlnsIndex(mapping.Members!);
                 if (xmlnsMember >= 0)
                 {
-                    MemberMapping member = mapping.Members![xmlnsMember];
                     var source = (XmlSerializerNamespaces)p[xmlnsMember];
 
                     if (pLength > xmlnsMember)
index 09a5bfc..36bd95b 100644 (file)
@@ -971,7 +971,6 @@ namespace System.Xml.Serialization
         private void Write46_XmlSchemaElement(XmlSchemaElement? o)
         {
             if ((object?)o == null) return;
-            System.Type t = o.GetType();
             WriteStartElement("element");
             WriteAttribute(@"id", @"", o.Id);
             WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
@@ -1033,7 +1032,6 @@ namespace System.Xml.Serialization
         private void Write47_XmlSchemaKey(XmlSchemaKey? o)
         {
             if ((object?)o == null) return;
-            System.Type t = o.GetType();
             WriteStartElement("key");
             WriteAttribute(@"id", @"", ((string?)o.@Id));
             WriteAttribute(@"name", @"", ((string?)o.@Name));
@@ -1088,7 +1086,6 @@ namespace System.Xml.Serialization
         private void Write50_XmlSchemaKeyref(XmlSchemaKeyref? o)
         {
             if ((object?)o == null) return;
-            System.Type t = o.GetType();
             WriteStartElement("keyref");
 
             WriteAttribute(@"id", @"", ((string?)o.@Id));
@@ -1114,7 +1111,6 @@ namespace System.Xml.Serialization
         private void Write51_XmlSchemaUnique(XmlSchemaUnique? o)
         {
             if ((object?)o == null) return;
-            System.Type t = o.GetType();
             WriteStartElement("unique");
 
             WriteAttribute(@"id", @"", ((string?)o.@Id));
@@ -1136,7 +1132,6 @@ namespace System.Xml.Serialization
         private void Write52_XmlSchemaChoice(XmlSchemaChoice? o)
         {
             if ((object?)o == null) return;
-            System.Type t = o.GetType();
             WriteStartElement("choice");
 
             WriteAttribute(@"id", @"", ((string?)o.@Id));
index 0935a40..fa90a9a 100644 (file)
@@ -186,8 +186,8 @@ namespace System.Xml.Serialization
         private void InitPrimitiveIDs()
         {
             if (_tokenID != null) return;
-            object ns = _r.NameTable.Add(XmlSchema.Namespace);
-            object ns2 = _r.NameTable.Add(UrtTypes.Namespace);
+            _r.NameTable.Add(XmlSchema.Namespace);
+            _r.NameTable.Add(UrtTypes.Namespace);
 
             _stringID = _r.NameTable.Add("string");
             _intID = _r.NameTable.Add("int");
@@ -2116,7 +2116,6 @@ namespace System.Xml.Serialization
                 _arrayName = arrayName + "_" + i.ToString(CultureInfo.InvariantCulture);
                 _choiceArrayName = "choice_" + _arrayName;
                 _choiceSource = choiceSource;
-                ElementAccessor[]? elements = mapping.Elements;
 
                 if (mapping.TypeDesc!.IsArrayLike)
                 {
@@ -3426,7 +3425,6 @@ namespace System.Xml.Serialization
         {
             if (structMapping.TypeDesc!.IsRoot)
                 return;
-            bool useReflection = structMapping.TypeDesc.UseReflection;
             string methodName = (string)MethodNames[structMapping]!;
             Writer.WriteLine();
             Writer.Write("object");
@@ -3566,7 +3564,6 @@ namespace System.Xml.Serialization
         private void WriteAddCollectionFixup(TypeDesc typeDesc, bool readOnly, string memberSource, string targetSource)
         {
             Writer.WriteLine("// get array of the collection items");
-            bool useReflection = typeDesc.UseReflection;
             CreateCollectionInfo? create = (CreateCollectionInfo?)_createMethods[typeDesc];
             if (create == null)
             {
index ba8ad5e..cd53280 100644 (file)
@@ -1881,7 +1881,6 @@ namespace System.Xml.Serialization
             if (!typeDesc.UseReflection)
                 return obj + ".@" + memberName;
 
-            TypeDesc saveTypeDesc = typeDesc;
             while (typeDesc != null)
             {
                 string typeFullName = typeDesc.CSharpName;
@@ -2574,7 +2573,6 @@ namespace System.Xml.Serialization
                 int xmlnsMember = FindXmlnsIndex(mapping.Members!);
                 if (xmlnsMember >= 0)
                 {
-                    MemberMapping member = mapping.Members![xmlnsMember];
                     string source = "((" + typeof(System.Xml.Serialization.XmlSerializerNamespaces).FullName + ")p[" + xmlnsMember.ToString(CultureInfo.InvariantCulture) + "])";
 
                     Writer.Write("if (pLength > ");
@@ -3444,8 +3442,7 @@ namespace System.Xml.Serialization
 
             if (choice != null)
             {
-                bool choiceUseReflection = choice.Mapping!.TypeDesc!.UseReflection;
-                string choiceFullName = choice.Mapping.TypeDesc.CSharpName;
+                string choiceFullName = choice.Mapping!.TypeDesc!.CSharpName;
                 WriteArrayLocalDecl(choiceFullName + "[]", "c", choiceSource, choice.Mapping.TypeDesc);
                 // write check for the choice identifier array
                 Writer.WriteLine("if (c == null || c.Length < a.Length) {");
@@ -3691,7 +3688,6 @@ namespace System.Xml.Serialization
 
                         string? enumFullName = null;
 
-                        bool useReflection = element.Mapping!.TypeDesc!.UseReflection;
                         if (choice != null)
                         {
                             bool enumUseReflection = choice.Mapping!.TypeDesc!.UseReflection;
@@ -4073,12 +4069,6 @@ namespace System.Xml.Serialization
             }
             else if (element.Mapping is SpecialMapping)
             {
-                SpecialMapping mapping = (SpecialMapping)element.Mapping;
-                bool useReflection = mapping.TypeDesc!.UseReflection;
-                TypeDesc td = mapping.TypeDesc;
-                string fullTypeName = td.CSharpName;
-
-
                 if (element.Mapping is SerializableMapping)
                 {
                     WriteElementCall("WriteSerializable", typeof(IXmlSerializable), source, name, ns, element.IsNullable, !element.Any);
index 605656d..abf082b 100644 (file)
@@ -391,7 +391,6 @@ namespace System.Xml.Serialization
                 int xmlnsMember = FindXmlnsIndex(mapping.Members!);
                 if (xmlnsMember >= 0)
                 {
-                    MemberMapping member = mapping.Members![xmlnsMember];
                     string source = "((" + typeof(XmlSerializerNamespaces).FullName + ")p[" + xmlnsMember.ToString(CultureInfo.InvariantCulture) + "])";
 
                     ilg.Ldloc(pLengthLoc);
@@ -1619,21 +1618,18 @@ namespace System.Xml.Serialization
 
                         WriteChoiceTypeCheck(source, fullTypeName, choice!, enumFullName, element.Mapping.TypeDesc);
 
-                        SourceInfo castedSource = source;
-                        castedSource = source.CastTo(element.Mapping.TypeDesc);
+                        SourceInfo castedSource = source.CastTo(element.Mapping.TypeDesc);
                         WriteElement(element.Any ? source : castedSource, element, arrayName, writeAccessors);
                     }
                     else
                     {
                         TypeDesc td = element.IsUnbounded ? element.Mapping!.TypeDesc!.CreateArrayTypeDesc() : element.Mapping!.TypeDesc!;
-                        string fullTypeName = td.CSharpName;
                         if (wroteFirstIf) ilg.InitElseIf();
                         else { wroteFirstIf = true; ilg.InitIf(); }
                         WriteInstanceOf(source, td.Type!);
                         // WriteInstanceOf leave bool on the stack
                         ilg.AndIf();
-                        SourceInfo castedSource = source;
-                        castedSource = source.CastTo(td);
+                        SourceInfo castedSource = source.CastTo(td);
                         WriteElement(element.Any ? source : castedSource, element, arrayName, writeAccessors);
                     }
                 }
@@ -1653,8 +1649,6 @@ namespace System.Xml.Serialization
                     if (elements.Length - anyCount > 0) ilg.InitElseIf();
                     else ilg.InitIf();
 
-                    string fullTypeName = typeof(XmlElement).FullName!;
-
                     source.Load(typeof(object));
                     ilg.IsInst(typeof(XmlElement));
                     ilg.Load(null);
@@ -1795,18 +1789,17 @@ namespace System.Xml.Serialization
                 }
                 if (text != null)
                 {
-                    string fullTypeName = text.Mapping!.TypeDesc!.CSharpName;
                     if (elements.Length > 0)
                     {
                         ilg.InitElseIf();
-                        WriteInstanceOf(source, text.Mapping.TypeDesc.Type!);
+                        WriteInstanceOf(source, text.Mapping!.TypeDesc!.Type!);
                         ilg.AndIf();
                         SourceInfo castedSource = source.CastTo(text.Mapping.TypeDesc);
                         WriteText(castedSource, text);
                     }
                     else
                     {
-                        SourceInfo castedSource = source.CastTo(text.Mapping.TypeDesc);
+                        SourceInfo castedSource = source.CastTo(text.Mapping!.TypeDesc!);
                         WriteText(castedSource, text);
                     }
                 }
@@ -1913,8 +1906,7 @@ namespace System.Xml.Serialization
                     ilg.Cne();
                 }
                 ilg.If();
-                string fullTypeName = element.Mapping.TypeDesc.BaseTypeDesc!.CSharpName;
-                SourceInfo castedSource = source.CastTo(element.Mapping.TypeDesc.BaseTypeDesc);
+                SourceInfo castedSource = source.CastTo(element.Mapping.TypeDesc.BaseTypeDesc!);
                 ElementAccessor e = element.Clone();
                 e.Mapping = ((NullableMapping)element.Mapping).BaseMapping;
                 WriteElement(e.Any ? source : castedSource, e, arrayName, writeAccessor);
@@ -2017,11 +2009,6 @@ namespace System.Xml.Serialization
             }
             else if (element.Mapping is SpecialMapping)
             {
-                SpecialMapping mapping = (SpecialMapping)element.Mapping;
-                TypeDesc td = mapping.TypeDesc!;
-                string fullTypeName = td.CSharpName;
-
-
                 if (element.Mapping is SerializableMapping)
                 {
                     WriteElementCall("WriteSerializable", typeof(IXmlSerializable), source, name, ns, element.IsNullable, !element.Any);
@@ -2314,7 +2301,7 @@ namespace System.Xml.Serialization
         {
             foreach (Type type in scope.Types)
             {
-                TypeDesc typeDesc = scope.GetTypeDesc(type);
+                scope.GetTypeDesc(type);
             }
         }
 
index b32692c..744793a 100644 (file)
@@ -274,8 +274,8 @@ namespace System.Xml.Xsl.Xslt
                     bool undefined = false;
                     for (int prev = record + 1; prev < exAll; prev++)
                     {
-                        string? prevPrefix, prevNsUri;
-                        ScopeFlags prevFlags = GetName(ref _records[prev], out prevPrefix, out prevNsUri);
+                        string? prevPrefix;
+                        GetName(ref _records[prev], out prevPrefix, out _);
                         if (
                             (flags & ScopeFlags.NsDecl) != 0 &&
                             prevPrefix == recPrefix
index 410a8f7..d7d3d37 100644 (file)
@@ -2347,7 +2347,6 @@ namespace System.Xml.Xsl.Xslt
             Debug.Assert(expr != null);
             XPathScanner scanner;
             QilNode result;
-            int startPos = pos;
 
             SetEnvironmentFlags(/*allowVariables:*/true, /*allowCurrent:*/true, /*allowKey:*/true);
             try
index 0f26d97..da0c17a 100644 (file)
@@ -469,7 +469,7 @@ namespace System.Xml.Xsl.Xslt
         // It's OK to suppress the SxS warning.
         private void LoadImport()
         {
-            ContextInfo ctxInfo = _input.GetAttributes(_importIncludeAttributes);
+            _input.GetAttributes(_importIncludeAttributes);
 
             if (_input.MoveToXsltAttribute(0, "href"))
             {
@@ -498,7 +498,7 @@ namespace System.Xml.Xsl.Xslt
         // It's OK to suppress the SxS warning.
         private void LoadInclude()
         {
-            ContextInfo ctxInfo = _input.GetAttributes(_importIncludeAttributes);
+            _input.GetAttributes(_importIncludeAttributes);
 
             if (_input.MoveToXsltAttribute(0, "href"))
             {
@@ -568,7 +568,7 @@ namespace System.Xml.Xsl.Xslt
         };
         private void LoadOutput()
         {
-            ContextInfo ctxInfo = _input.GetAttributes(_outputAttributes);
+            _input.GetAttributes(_outputAttributes);
 
             Output output = _compiler.Output;
             XmlWriterSettings settings = output.Settings;
@@ -844,7 +844,7 @@ namespace System.Xml.Xsl.Xslt
             QilName keyName = ParseQNameAttribute(0)!;
             string? match = ParseStringAttribute(1, "match");
             string? use = ParseStringAttribute(2, "use");
-            string? collation = ParseCollationAttribute(3);
+            ParseCollationAttribute(3);
 
             _input.MoveToElement();
 
@@ -1931,7 +1931,6 @@ namespace System.Xml.Xsl.Xslt
                 XslNodeType.Unknown
             );
             Debug.Assert(nodeType != XslNodeType.Unknown);
-            bool isParam = Ref.Equal(localName, _atoms.Param);
             ContextInfo ctxInfo = _input.GetAttributes(
                 nodeType == XslNodeType.Variable ? _variableAttributes :
                 nodeType == XslNodeType.Param ? _paramAttributes :
@@ -2138,7 +2137,7 @@ namespace System.Xml.Xsl.Xslt
             string? select = ParseStringAttribute(0, "select");
             string? lang = ParseStringAttribute(1, "lang");
             string? order = ParseStringAttribute(2, "order");
-            string? collation = ParseCollationAttribute(3);
+            ParseCollationAttribute(3);
             TriState stable = ParseYesNoAttribute(4, "stable");
             string? caseOrder = ParseStringAttribute(5, "case-order");
             string? dataType = ParseStringAttribute(6, "data-type");
index 8e838cd..2a08aa6 100644 (file)
@@ -36,7 +36,6 @@ namespace System.Xml.Xsl.XsltOld
         internal override bool CompileAttribute(Compiler compiler)
         {
             string name = compiler.Input.LocalName;
-            string value = compiler.Input.Value;
             if (Ref.Equal(name, compiler.Atoms.UseAttributeSets))
             {
                 AddAction(compiler.CreateUseAttributeSetsAction());
index 0f4edce..69bb09e 100644 (file)
@@ -46,7 +46,7 @@ namespace System.Xml.Tests
             const string attributeUri = "existingUri";
             XmlDocument doc = CreateDocumentWithElement();
             XmlElement element = doc.DocumentElement;
-            XmlAttribute existingAttr = element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri));
+            element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri));
             XmlAttribute anotherAttr = element.Attributes.Append(doc.CreateAttribute("anotherAttribute"));
 
             var newAttr = doc.CreateAttribute(attributeName, attributeUri);
index 0805d6f..545e392 100644 (file)
@@ -50,7 +50,7 @@ namespace System.Xml.Tests
             XmlDocument doc = CreateDocumentWithElement();
             XmlElement element = doc.DocumentElement;
             XmlAttribute anotherAttr = element.Attributes.Append(doc.CreateAttribute("anotherAttribute"));
-            XmlAttribute existingAttr = element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri));
+            element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri));
             // assert on implicitly set preconditions
             Assert.Same(anotherAttr, element.Attributes[0]);
 
index 74185f4..d9933da 100644 (file)
@@ -37,7 +37,7 @@ namespace System.Xml.Tests
             var xmlDocument = new XmlDocument();
             var cdata = xmlDocument.CreateCDataSection("]]>");
 
-            AssertExtensions.Throws<ArgumentException>(null, () => { var test = cdata.OuterXml; });
+            AssertExtensions.Throws<ArgumentException>(null, () => cdata.OuterXml);
             Assert.Equal(string.Empty, cdata.InnerXml);
             Assert.Equal("]]>", cdata.InnerText);
             Assert.Equal(XmlNodeType.CDATA, cdata.NodeType);
index 8a21872..37f4c1f 100644 (file)
@@ -57,7 +57,7 @@ namespace System.Xml.Tests
         public static void InvalidEncoding()
         {
             var xmlDocument = new XmlDocument();
-            var decl = xmlDocument.CreateXmlDeclaration("1.0", "wrong", "yes");
+            xmlDocument.CreateXmlDeclaration("1.0", "wrong", "yes");
         }
 
         [Fact]
index 67a8b64..387c570 100644 (file)
@@ -31,7 +31,7 @@ namespace System.Xml.Tests
         public static void RespectTypesDerivedFromNameTable()
         {
             var customNameTable = new CustomNameTable();
-            var xmlDocument = new XmlDocument(customNameTable);
+            new XmlDocument(customNameTable);
             Assert.True(customNameTable.NumberOfCallsToAddStringMethod > 0);
         }
 
index 18cbca2..c54ee16 100644 (file)
@@ -71,8 +71,8 @@ namespace System.Xml.Tests
             var xmlDocument = new XmlDocument();
             var fragment = xmlDocument.CreateDocumentFragment();
 
-            var text1 = xmlDocument.CreateTextNode("test_test1");
-            var text2 = xmlDocument.CreateTextNode("test_test2");
+            xmlDocument.CreateTextNode("test_test1");
+            xmlDocument.CreateTextNode("test_test2");
 
             fragment.Normalize();
             Assert.Equal(string.Empty, fragment.OuterXml);
index 21b9566..75aad9b 100644 (file)
@@ -20,10 +20,7 @@ namespace System.Xml.Tests
         [Fact]
         public void NodeReaderConstructionWithNull()
         {
-            Assert.Throws<ArgumentNullException>(() =>
-            {
-                var nodeReader = new XmlNodeReader(null);
-            });
+            Assert.Throws<ArgumentNullException>(() => new XmlNodeReader(null));
         }
     }
 }
index d50e179..c77779d 100644 (file)
@@ -116,7 +116,6 @@ namespace System.Xml.Tests
         public void SetSchemaSetWithInvalidContent_TypeCollision()
         {
             XmlSchemaValidator val;
-            XmlSchemaInfo info = new XmlSchemaInfo();
 
             XmlSchemaSet sch = new XmlSchemaSet();
 
@@ -277,7 +276,6 @@ namespace System.Xml.Tests
         public void AddSchemasWithTypeCollision()
         {
             XmlSchemaValidator val = CreateValidator(new XmlSchemaSet());
-            XmlSchemaInfo info = new XmlSchemaInfo();
 
             val.AddSchema(XmlSchema.Read(XmlReader.Create(new StringReader("<?xml version=\"1.0\" ?>\n" +
                                                                            "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
index 3ffc344..d273c64 100644 (file)
@@ -25,7 +25,6 @@ namespace System.Xml.Tests
         public void CallAtRootLevel_Without_With_PartialValidationSet(bool partialValidation)
         {
             XmlSchemaValidator val;
-            XmlSchemaInfo info = new XmlSchemaInfo();
             XmlSchemaSet schemas = CreateSchemaSet("", "<?xml version=\"1.0\"?>\n" +
                                                        "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
                                                        "    <xs:attribute name=\"attr1\" />\n" +
index fabc69e..d19209a 100644 (file)
@@ -576,7 +576,6 @@ namespace System.Xml.Tests
         {
             XmlSchemaValidator val;
             XmlSchemaInfo info = new XmlSchemaInfo();
-            XmlSchemaSet schemas = new XmlSchemaSet();
             XmlSchemaParticle[] result;
 
             val = CreateValidator(XSDFILE_GET_EXPECTED_PARTICLES);
index dfdd5bf..2481f02 100644 (file)
@@ -480,7 +480,6 @@ namespace System.Xml.Tests
         public void SetPartiaValidationAndCallValidate_Text_WhiteSpace_Valid(string typeToValidate)
         {
             XmlSchemaValidator val;
-            XmlSchemaInfo info = new XmlSchemaInfo();
             XmlSchemaSet schemas = new XmlSchemaSet();
 
             schemas.Add("", Path.Combine(TestData, XSDFILE_PARTIAL_VALIDATION));
index 24c753c..b6b3d72 100644 (file)
@@ -123,7 +123,6 @@ namespace System.Xml.Tests
             res.CalledGetEntity += new XmlTestResolverEventHandler(holder.CallBackGetEntity);
 
             XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
-            XmlSchemaInfo info = new XmlSchemaInfo();
             XmlSchemaValidator val = new XmlSchemaValidator(new NameTable(),
                                                             new XmlSchemaSet(),
                                                             manager,
@@ -159,7 +158,6 @@ namespace System.Xml.Tests
             res.CalledGetEntity += new XmlTestResolverEventHandler(holder.CallBackGetEntity);
 
             XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
-            XmlSchemaInfo info = new XmlSchemaInfo();
             XmlSchemaValidator val = new XmlSchemaValidator(new NameTable(),
                                                             new XmlSchemaSet(),
                                                             manager,
index 3880743..7601086 100644 (file)
@@ -68,7 +68,6 @@ namespace System.Xml.Tests
         public void PassNullXmlSchemaInfo__Valid()
         {
             XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE);
-            XmlSchemaInfo info = new XmlSchemaInfo();
 
             val.Initialize();
             val.ValidateElement("OneAttributeElement", "", null);
@@ -202,17 +201,14 @@ namespace System.Xml.Tests
 
     public class TCGetUnspecifiedDefaultAttributes : CXmlSchemaValidatorTestCase
     {
-        private ITestOutputHelper _output;
         public TCGetUnspecifiedDefaultAttributes(ITestOutputHelper output) : base(output)
         {
-            _output = output;
         }
 
         [Fact]
         public void PassNull__Invalid()
         {
             XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE);
-            XmlSchemaInfo info = new XmlSchemaInfo();
 
             val.Initialize();
             val.ValidateElement("OneAttributeElement", "", null);
@@ -439,7 +435,6 @@ namespace System.Xml.Tests
         public void CallWithoutValidationOfRequiredAttribute()
         {
             XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE);
-            ArrayList atts = new ArrayList();
 
             val.Initialize();
             val.ValidateElement("RequiredAttributeElement", "", null);
index 94b207e..bf8ee8c 100644 (file)
@@ -68,7 +68,6 @@ namespace System.Xml.Tests
         public void PassNullXmlSchemaInfo__Valid()
         {
             XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE);
-            XmlSchemaInfo info = new XmlSchemaInfo();
 
             val.Initialize();
             val.ValidateElement("OneAttributeElement", "", null);
index 959c52e..c7bb329 100644 (file)
@@ -290,7 +290,6 @@ namespace System.Xml.Tests
         public void ProvideValidXsiType()
         {
             XmlSchemaValidator val;
-            XmlSchemaInfo info = new XmlSchemaInfo();
             XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable());
             XmlSchemaSet schemas = new XmlSchemaSet();
 
@@ -308,7 +307,6 @@ namespace System.Xml.Tests
         public void ProvideInvalidXsiType()
         {
             XmlSchemaValidator val;
-            XmlSchemaInfo info = new XmlSchemaInfo();
             XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable());
             XmlSchemaSet schemas = new XmlSchemaSet();
 
index 2cf937a..ae30ed8 100644 (file)
@@ -43,7 +43,7 @@ namespace System.Xml.Tests
             XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback);
             ss.XmlResolver = new XmlUrlResolver();
 
-            XmlSchema Schema1 = ss.Add(Schema);
+            ss.Add(Schema);
             ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add");
             ValidateWithSchemaInfo(ss);
 
@@ -51,9 +51,8 @@ namespace System.Xml.Tests
             ValidateSchemaSet(ss, expCount, true, expCountGT, expCountGE, expCountGA, "Validation after add/comp");
             ValidateWithSchemaInfo(ss);
 
-            XmlSchema Schema2 = null;
             foreach (XmlSchema schema in ss.Schemas())
-                Schema2 = ss.Reprocess(schema);
+                ss.Reprocess(schema);
 
             ValidateSchemaSet(ss, expCount, false, 1, 0, 0, "Validation after repr");
             ValidateWithSchemaInfo(ss);
@@ -98,7 +97,7 @@ namespace System.Xml.Tests
             XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback);
             ss.XmlResolver = new XmlUrlResolver();
 
-            XmlSchema Schema1 = ss.Add(Schema);
+            ss.Add(Schema);
             ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add");
             ValidateWithXmlReader(ss, xml, xsd);
 
@@ -162,7 +161,7 @@ namespace System.Xml.Tests
             XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback);
             ss.XmlResolver = new XmlUrlResolver();
 
-            XmlSchema Schema1 = ss.Add(Schema);
+            ss.Add(Schema);
             ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add");
             ValidateWithSchemaInfo(ss);
 
@@ -227,7 +226,7 @@ namespace System.Xml.Tests
             XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), ValidationCallback);
             ss.XmlResolver = new XmlUrlResolver();
 
-            XmlSchema Schema1 = ss.Add(Schema);
+            ss.Add(Schema);
             ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add");
             ValidateWithXmlReader(ss, xml, xsd);
 
@@ -243,10 +242,9 @@ namespace System.Xml.Tests
             ValidateSchemaSet(ss, expCount - 1, true, expCountGERC, expCountGER, 0, "Validation after add");
             ValidateWithXmlReader(ss, xml, xsd);
 
-            XmlSchema Schema2 = null;
             try
             {
-                Schema2 = ss.Reprocess(Schema);
+                ss.Reprocess(Schema);
                 Assert.True(false);
             }
             catch (ArgumentException e)
@@ -429,7 +427,7 @@ namespace System.Xml.Tests
             XmlSchemaSet ss = new XmlSchemaSet();
             ss.XmlResolver = new XmlUrlResolver();
             XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), null);
-            XmlSchema Schema1 = ss.Add(Schema);
+            ss.Add(Schema);
             ValidateSchemaSet(ss, expCount, false, 0, 0, 0, "Validation after add");
 
             ss.Compile();
@@ -455,7 +453,7 @@ namespace System.Xml.Tests
 
             XmlSchemaSet ss = new XmlSchemaSet();
             XmlSchema Schema = XmlSchema.Read(XmlReader.Create(xsd), null);
-            XmlSchema Schema1 = ss.Add(Schema);
+            ss.Add(Schema);
             ValidateSchemaSet(ss, 1, false, 0, 0, 0, "Validation after add");
 
             ss.Compile();
@@ -679,7 +677,7 @@ namespace System.Xml.Tests
                 }
             }
 
-            XmlSchema removedSchema = ss.Remove(schema);
+            ss.Remove(schema);
             Assert.Equal(0, ss.Count);
             ss.Compile();
             Assert.Equal(0, ss.Count);
@@ -721,7 +719,7 @@ namespace System.Xml.Tests
                 while (xmlReader.Read()) ;
             }
 
-            XmlSchema removedSchema = ss.Remove(schema);
+            ss.Remove(schema);
             Assert.Equal(0, ss.Count);
             ss.Compile();
             Assert.Equal(0, ss.Count);
@@ -1092,7 +1090,6 @@ namespace System.Xml.Tests
         {
             Initialize();
 
-            Regex regex = new Regex(@"^\w+$");
             string schemaContent = @"<xs:schema elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
 <xs:element name='validationTest'>
 <xs:simpleType>
index b80d7ce..182fb0a 100644 (file)
@@ -1917,7 +1917,6 @@ public static partial class XmlSerializerTests
         XmlReflectionMember member = members[0] = new XmlReflectionMember();
         member.MemberType = typeof(TypeWithQNameArrayAsXmlAttributeInvalidDefaultValue);
         XmlMembersMapping mappings = importer.ImportMembersMapping("root", "", members, true);
-        XmlMemberMapping xmp = mappings[0];
         XmlSchemas schema = new XmlSchemas();
         XmlSchemaExporter exporter = new XmlSchemaExporter(schema);
         AssertExtensions.Throws<XmlException,Exception>(() => exporter.ExportMembersMapping(mappings));
@@ -1959,7 +1958,7 @@ public static partial class XmlSerializerTests
         string xmlFileContent = @"<root><date>2003-01-08T15:00:00-00:00</date></root>";
         Stream sm = GenerateStreamFromString(xmlFileContent);
         XmlTextReader reader = new XmlTextReader(sm);
-        MyXmlTextParser text = new MyXmlTextParser(reader);
+        new MyXmlTextParser(reader);
     }
 
     [Fact]
@@ -2186,9 +2185,6 @@ public static partial class XmlSerializerTests
     public static void XmlMembersMapping_TypeWithXmlAttributes()
     {
         string memberName = "data";
-        string ns = s_defaultNs;
-        XmlReflectionMember member = GetReflectionMember<TypeWithXmlAttributes>(memberName, ns);
-        var members = new XmlReflectionMember[] { member };
 
         TypeWithXmlAttributes value = new TypeWithXmlAttributes { MyName = "fooname", Today = DateTime.Now };
         var actual = RoundTripWithXmlMembersMapping<TypeWithXmlAttributes>(value,
index 4954810..364c4f8 100644 (file)
@@ -740,9 +740,7 @@ string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
 </TypeWithByteProperty>");
             writer.Flush();
             stream.Position = 0;
-            Assert.Throws<InvalidOperationException>(() => {
-                var deserializedObj = (TypeWithByteProperty)serializer.Deserialize(stream);
-            });
+            Assert.Throws<InvalidOperationException>(() => (TypeWithByteProperty)serializer.Deserialize(stream));
         }
     }
 
@@ -817,7 +815,6 @@ string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
     [Fact]
     public static void Xml_SimpleType()
     {
-        var serializer = new XmlSerializer(typeof(SimpleType));
         var obj = new SimpleType { P1 = "foo", P2 = 1 };
         var deserializedObj = SerializeAndDeserialize(obj,
 @"<?xml version=""1.0"" encoding=""utf-16""?>