From c6aea7ab584cb7c951cbb1ad1155d4ff8d94186f Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Fri, 17 Jul 2020 19:15:52 -0700 Subject: [PATCH] Remove unused locals and methods in System.Private.Xml --- .../System/Xml/Core/XsdValidatingReader.cs | 1 - .../Xml/Core/XsdValidatingReaderAsync.cs | 1 - .../src/System/Xml/Dom/XmlNode.cs | 3 +- .../src/System/Xml/Schema/ContentValidator.cs | 47 ---------- .../src/System/Xml/Schema/FacetChecker.cs | 1 - .../src/System/Xml/Schema/Inference/Infer.cs | 6 +- .../Xml/Schema/SchemaCollectionCompiler.cs | 92 ------------------- .../src/System/Xml/Serialization/Compiler.cs | 2 +- .../src/System/Xml/Serialization/Mappings.cs | 12 --- .../ReflectionXmlSerializationReader.cs | 1 - .../ReflectionXmlSerializationWriter.cs | 3 - .../Xml/Serialization/SchemaObjectWriter.cs | 5 - .../Serialization/XmlSerializationReader.cs | 7 +- .../Serialization/XmlSerializationWriter.cs | 12 +-- .../XmlSerializationWriterILGen.cs | 25 ++--- .../Xml/Xsl/Xslt/CompilerScopeManager.cs | 4 +- .../src/System/Xml/Xsl/Xslt/QilGenerator.cs | 1 - .../src/System/Xml/Xsl/Xslt/XsltLoader.cs | 11 +-- .../src/System/Xml/Xsl/XsltOld/CopyAction.cs | 1 - .../AppendTests.cs | 2 +- .../PrependTests.cs | 2 +- .../CreateCDataSectionTests.cs | 2 +- .../CreateXmlDeclarationTests.cs | 2 +- .../XmlDocumentTests/NameTableTests.cs | 2 +- .../XmlNodeTests/NormalizeTests.cs | 4 +- .../XmlNodeReaderConstructionTests.cs | 2 +- .../Constructor_AddSchema.cs | 2 - .../GetExpectedAttributes.cs | 1 - .../GetExpectedParticles.cs | 1 - .../Initialize_EndValidation.cs | 1 - .../XmlSchemaValidatorApi/PropertiesTests.cs | 2 - .../ValidateAttribute.cs | 5 - .../ValidateAttribute_String.cs | 1 - .../XmlSchemaValidatorApi/ValidateElement.cs | 2 - .../XmlSchemaValidatorApi/ValidateMisc.cs | 23 ++--- .../XmlSerializerTests.RuntimeOnly.cs | 6 +- .../tests/XmlSerializer/XmlSerializerTests.cs | 3 +- 37 files changed, 41 insertions(+), 257 deletions(-) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs index 10e2003ab8bc1..620603a27fe14 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs @@ -1511,7 +1511,6 @@ public override ReadState ReadState // Skips to the end tag of the current element. public override void Skip() { - int startDepth = Depth; switch (NodeType) { case XmlNodeType.Element: diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs index 2446621362175..c7ef1391024fe 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReaderAsync.cs @@ -346,7 +346,6 @@ public override Task ReadAsync() // Skips to the end tag of the current element. public override async Task SkipAsync() { - int startDepth = Depth; switch (NodeType) { case XmlNodeType.Element: diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlNode.cs b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlNode.cs index 8bd2cbe1855ad..f1ccbfc027322 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlNode.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlNode.cs @@ -474,7 +474,7 @@ public virtual XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild) { XmlNode? nextNode = oldChild.NextSibling; RemoveChild(oldChild); - XmlNode? node = InsertBefore(newChild, nextNode); + InsertBefore(newChild, nextNode); return oldChild; } @@ -846,7 +846,6 @@ public virtual bool IsReadOnly { get { - XmlDocument? doc = OwnerDocument; return HasReadOnlyParent(this); } } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs index e2ce468c6cfe9..2788b60a5b2ee 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs @@ -1261,7 +1261,6 @@ public ContentValidator Finish(bool useDFA) { if (ContentType == XmlSchemaContentType.Mixed) { - string ctype = IsOpen ? "Any" : "TextOnly"; return IsOpen ? ContentValidator.Any : ContentValidator.TextOnly; } else @@ -1281,7 +1280,6 @@ public ContentValidator Finish(bool useDFA) _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); @@ -1536,50 +1534,6 @@ private void CheckUniqueParticleAttribution(BitSet curpos) // now convert transition table to array return (int[][])transitionTable.ToArray(typeof(int[])); } - -#if DEBUG - private void Dump(StringBuilder bb, BitSet[] followpos, int[][] transitionTable) - { - // Temporary printout - bb.AppendLine("Positions"); - for (int i = 0; i < _positions!.Count; i++) - { - bb.AppendLine(i + " " + _positions[i].symbol.ToString(NumberFormatInfo.InvariantInfo) + " " + _symbols!.NameOf(_positions[i].symbol)); - } - - bb.AppendLine("Followpos"); - for (int i = 0; i < _positions.Count; i++) - { - for (int j = 0; j < _positions.Count; j++) - { - bb.Append(followpos[i][j] ? "X" : "O"); - } - bb.AppendLine(); - } - - if (transitionTable != null) - { - // Temporary printout - bb.AppendLine("Transitions"); - for (int i = 0; i < transitionTable.Length; i++) - { - for (int j = 0; j < _symbols!.Count; j++) - { - if (transitionTable[i][j] == -1) - { - bb.Append(" x "); - } - else - { - bb.AppendFormat(" {0:000} ", transitionTable[i][j]); - } - } - - bb.AppendLine(transitionTable[i][_symbols.Count] == 1 ? "+" : ""); - } - } - } -#endif } /// @@ -1880,7 +1834,6 @@ internal RangeContentValidator( public override void InitValidation(ValidationState context) { - int positionsCount = _positions.Count; List? runningPositions = context.RunningPositions; if (runningPositions != null) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs index 5f53c75bff95d..49a8beb01819a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs @@ -474,7 +474,6 @@ private void CheckValue(object value, XmlSchemaFacet facet) 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 && diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs index ad7d1cc67df35..58e9c0ddf9354 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs @@ -925,7 +925,7 @@ internal void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchem 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 @@ internal void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchem { 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 @@ internal void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchem 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) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs index 26f8fcb768846..a15c732ebcde8 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs @@ -2439,98 +2439,6 @@ private ContentValidator CompileComplexContent(XmlSchemaComplexType complexType) } } -#if DEBUG - private string DumpContentModel(XmlSchemaParticle particle) - { - StringBuilder sb = new StringBuilder(); - DumpContentModelTo(sb, particle); - return sb.ToString(); - } - - private void DumpContentModelTo(StringBuilder sb, XmlSchemaParticle particle) - { - if (particle is XmlSchemaElement) - { - sb.Append(((XmlSchemaElement)particle).QualifiedName); - } - else if (particle is XmlSchemaAny) - { - sb.Append('<'); - sb.Append(((XmlSchemaAny)particle!).NamespaceList!.ToString()); - sb.Append('>'); - } - else if (particle is XmlSchemaAll) - { - XmlSchemaAll all = (XmlSchemaAll)particle; - sb.Append('['); - bool first = true; - for (int i = 0; i < all.Items.Count; ++i) - { - XmlSchemaElement localElement = (XmlSchemaElement)all.Items[i]; - if (first) - { - first = false; - } - else - { - sb.Append(", "); - } - sb.Append(localElement.QualifiedName.Name); - if (localElement.MinOccurs == decimal.Zero) - { - sb.Append('?'); - } - } - sb.Append(']'); - } - else if (particle is XmlSchemaGroupBase) - { - XmlSchemaGroupBase gb = (XmlSchemaGroupBase)particle; - sb.Append('('); - string delimeter = (particle is XmlSchemaChoice) ? " | " : ", "; - bool first = true; - for (int i = 0; i < gb.Items.Count; ++i) - { - if (first) - { - first = false; - } - else - { - sb.Append(delimeter); - } - DumpContentModelTo(sb, (XmlSchemaParticle)gb.Items[i]); - } - sb.Append(')'); - } - else - { - Debug.Assert(particle == XmlSchemaParticle.Empty); - sb.Append("<>"); - } - if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One) - { - // nothing - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.One) - { - sb.Append('?'); - } - else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.MaxValue) - { - sb.Append('*'); - } - else if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.MaxValue) - { - sb.Append('+'); - } - else - { - sb.Append("{" + particle.MinOccurs.ToString(NumberFormatInfo.InvariantInfo) + ", " + particle.MaxOccurs.ToString(NumberFormatInfo.InvariantInfo) + "}"); - } - } -#endif - private void BuildParticleContentModel(ParticleContentValidator contentValidator, XmlSchemaParticle particle) { if (particle is XmlSchemaElement) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs index bbf1968fc9530..3892522ed51e4 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs @@ -78,7 +78,7 @@ internal void AddImport(Type? type, Hashtable types) { TypeForwardedFromAttribute? originalAssemblyInfo = typeForwardedFromAttribute[0] as TypeForwardedFromAttribute; Debug.Assert(originalAssemblyInfo != null); - Assembly originalAssembly = Assembly.Load(new AssemblyName(originalAssemblyInfo.AssemblyFullName)); + Assembly.Load(new AssemblyName(originalAssemblyInfo.AssemblyFullName)); } } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs index c5069e4fabb86..fb5e6054d95aa 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs @@ -998,18 +998,6 @@ internal int SequenceId set { _sequenceId = value; } } - private string GetNullableType(TypeDesc td) - { - // SOAP encoded arrays not mapped to Nullable 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); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs index 3de884102feae..0458a4e06712b 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs @@ -1730,7 +1730,6 @@ private XmlSerializationCollectionFixupCallback GetCreateCollectionOfObjectsCall } Member[] allMembers = allMembersList.ToArray(); - MemberMapping[] allMemberMappings = allMemberMappingList.ToArray(); UnknownNodeAction unknownNodeAction = (_) => UnknownNode(o); WriteAttributes(allMembers, anyAttribute, unknownNodeAction, ref o); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationWriter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationWriter.cs index 7ad693fdae576..705dfcb0a2673 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationWriter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationWriter.cs @@ -201,7 +201,6 @@ private void WriteElements(object? o, object? enumSource, ElementAccessor[] elem int anyCount = 0; var namedAnys = new List(); 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 @@ private void WriteElement(object? o, ElementAccessor element, bool writeAccessor } else if (element.IsUnbounded) { - TypeDesc arrayTypeDesc = mapping.TypeDesc!.CreateArrayTypeDesc(); var enumerable = (IEnumerable)o!; foreach (var e in enumerable) { @@ -1217,7 +1215,6 @@ private void GenerateMembersElement(object o, XmlMembersMapping xmlMembersMappin int xmlnsMember = FindXmlnsIndex(mapping.Members!); if (xmlnsMember >= 0) { - MemberMapping member = mapping.Members![xmlnsMember]; var source = (XmlSerializerNamespaces)p[xmlnsMember]; if (pLength > xmlnsMember) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SchemaObjectWriter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SchemaObjectWriter.cs index 09a5bfcbc6123..36bd95b2c4e15 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SchemaObjectWriter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SchemaObjectWriter.cs @@ -971,7 +971,6 @@ private void Write43_XmlSchemaAll(XmlSchemaAll o) 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 @@ private void Write46_XmlSchemaElement(XmlSchemaElement? o) 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 @@ private void Write49_XmlSchemaXPath(string name, string ns, XmlSchemaXPath? o) 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 @@ private void Write50_XmlSchemaKeyref(XmlSchemaKeyref? o) 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 @@ private void Write51_XmlSchemaUnique(XmlSchemaUnique? o) private void Write52_XmlSchemaChoice(XmlSchemaChoice? o) { if ((object?)o == null) return; - System.Type t = o.GetType(); WriteStartElement("choice"); WriteAttribute(@"id", @"", ((string?)o.@Id)); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs index 0935a40eb4861..b523a9fc33166 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs @@ -186,8 +186,8 @@ protected XmlDocument Document 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 @@ internal Member(XmlSerializationReaderCodeGen outerClass, string source, string? _arrayName = arrayName + "_" + i.ToString(CultureInfo.InvariantCulture); _choiceArrayName = "choice_" + _arrayName; _choiceSource = choiceSource; - ElementAccessor[]? elements = mapping.Elements; if (mapping.TypeDesc!.IsArrayLike) { @@ -3426,7 +3425,6 @@ private void WriteEncodedStructMethod(StructMapping structMapping) { if (structMapping.TypeDesc!.IsRoot) return; - bool useReflection = structMapping.TypeDesc.UseReflection; string methodName = (string)MethodNames[structMapping]!; Writer.WriteLine(); Writer.Write("object"); @@ -3566,7 +3564,6 @@ private void WriteFixupMethod(string? fixupMethodName, Member[] members, string 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) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs index ba8ad5e5a6b74..cd532800f897f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs @@ -1881,7 +1881,6 @@ internal string GetStringForMember(string obj, string memberName, TypeDesc typeD if (!typeDesc.UseReflection) return obj + ".@" + memberName; - TypeDesc saveTypeDesc = typeDesc; while (typeDesc != null) { string typeFullName = typeDesc.CSharpName; @@ -2574,7 +2573,6 @@ private string GenerateMembersElement(XmlMembersMapping xmlMembersMapping) 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 @@ private void WriteArray(string source, string? choiceSource, ElementAccessor[] e 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 @@ private void WriteElements(string source, string? enumSource, ElementAccessor[] string? enumFullName = null; - bool useReflection = element.Mapping!.TypeDesc!.UseReflection; if (choice != null) { bool enumUseReflection = choice.Mapping!.TypeDesc!.UseReflection; @@ -4073,12 +4069,6 @@ private void WriteElement(string source, ElementAccessor element, string arrayNa } 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); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs index 605656dfa7d1e..abf082b98b8ee 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs @@ -391,7 +391,6 @@ private string GenerateMembersElement(XmlMembersMapping xmlMembersMapping) 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 @@ private void WriteElements(SourceInfo source, string? enumSource, ElementAccesso 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 @@ private void WriteElements(SourceInfo source, string? enumSource, ElementAccesso 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 @@ private void WriteElements(SourceInfo source, string? enumSource, ElementAccesso } 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 @@ private void WriteElement(SourceInfo source, ElementAccessor element, string arr 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 @@ private void WriteElement(SourceInfo source, ElementAccessor element, string arr } 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 @@ internal void WriteReflectionInit(TypeScope scope) { foreach (Type type in scope.Types) { - TypeDesc typeDesc = scope.GetTypeDesc(type); + scope.GetTypeDesc(type); } } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs index b32692c26d062..bd737dfd3cdd7 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs @@ -274,8 +274,8 @@ public bool IsExNamespace(string nsUri) 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 diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilGenerator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilGenerator.cs index 410a8f75e4696..d7d3d3740534d 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilGenerator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilGenerator.cs @@ -2347,7 +2347,6 @@ private QilNode CompileXPathExpressionWithinAvt(string expr, ref int pos) Debug.Assert(expr != null); XPathScanner scanner; QilNode result; - int startPos = pos; SetEnvironmentFlags(/*allowVariables:*/true, /*allowCurrent:*/true, /*allowKey:*/true); try diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs index 0f26d97bc7fb2..da0d41962242e 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs @@ -469,7 +469,7 @@ private void LoadRealStylesheet() // 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 @@ private void LoadImport() // 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 @@ private void LoadPreserveSpace(NsDecl? stylesheetNsList) }; private void LoadOutput() { - ContextInfo ctxInfo = _input.GetAttributes(_outputAttributes); + _input.GetAttributes(_outputAttributes); Output output = _compiler.Output; XmlWriterSettings settings = output.Settings; @@ -844,7 +844,7 @@ private void LoadKey(NsDecl? stylesheetNsList) 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 @@ private VarPar XslVarPar() 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 @@ private XslNode XslSort(int sortNumber) 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"); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/CopyAction.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/CopyAction.cs index 8e838cdf29f0a..2a08aa6320f45 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/CopyAction.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/CopyAction.cs @@ -36,7 +36,6 @@ internal override void Compile(Compiler compiler) 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()); diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/AppendTests.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/AppendTests.cs index 0f4edce519a25..69bb09eebb399 100644 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/AppendTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/AppendTests.cs @@ -46,7 +46,7 @@ public void AppendRemovesExistingAttribute() 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); diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/PrependTests.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/PrependTests.cs index 0805d6feedb2a..545e3923ad464 100644 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/PrependTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/PrependTests.cs @@ -50,7 +50,7 @@ public void PrependRemovesExistingAttribute() 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]); diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateCDataSectionTests.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateCDataSectionTests.cs index 74185f496f3eb..b43bccbda9091 100644 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateCDataSectionTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateCDataSectionTests.cs @@ -37,7 +37,7 @@ public static void CreateCDataTest3() var xmlDocument = new XmlDocument(); var cdata = xmlDocument.CreateCDataSection("]]>"); - AssertExtensions.Throws(null, () => { var test = cdata.OuterXml; }); + AssertExtensions.Throws(null, () => { _ = cdata.OuterXml; }); Assert.Equal(string.Empty, cdata.InnerXml); Assert.Equal("]]>", cdata.InnerText); Assert.Equal(XmlNodeType.CDATA, cdata.NodeType); diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateXmlDeclarationTests.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateXmlDeclarationTests.cs index 8a21872ca68db..37f4c1f24f1e9 100644 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateXmlDeclarationTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/CreateXmlDeclarationTests.cs @@ -57,7 +57,7 @@ public static void WrongXmlVersion() public static void InvalidEncoding() { var xmlDocument = new XmlDocument(); - var decl = xmlDocument.CreateXmlDeclaration("1.0", "wrong", "yes"); + xmlDocument.CreateXmlDeclaration("1.0", "wrong", "yes"); } [Fact] diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/NameTableTests.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/NameTableTests.cs index 67a8b6423fa9c..00fc911c10645 100644 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/NameTableTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlDocumentTests/NameTableTests.cs @@ -31,7 +31,7 @@ public static void RespectManuallyAddedReference() public static void RespectTypesDerivedFromNameTable() { var customNameTable = new CustomNameTable(); - var xmlDocument = new XmlDocument(customNameTable); + _ = new XmlDocument(customNameTable); Assert.True(customNameTable.NumberOfCallsToAddStringMethod > 0); } diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlNodeTests/NormalizeTests.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlNodeTests/NormalizeTests.cs index 18cbca2c2b6f5..c54ee161a2bf9 100644 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/XmlNodeTests/NormalizeTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlDocument/XmlNodeTests/NormalizeTests.cs @@ -71,8 +71,8 @@ public static void DocumentFragment() 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); diff --git a/src/libraries/System.Private.Xml/tests/XmlNodeReader/System.Xml.XmlNodeReader.Tests/XmlNodeReaderConstructionTests.cs b/src/libraries/System.Private.Xml/tests/XmlNodeReader/System.Xml.XmlNodeReader.Tests/XmlNodeReaderConstructionTests.cs index 21b9566511950..7b0008dd7d882 100644 --- a/src/libraries/System.Private.Xml/tests/XmlNodeReader/System.Xml.XmlNodeReader.Tests/XmlNodeReaderConstructionTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlNodeReader/System.Xml.XmlNodeReader.Tests/XmlNodeReaderConstructionTests.cs @@ -22,7 +22,7 @@ public void NodeReaderConstructionWithNull() { Assert.Throws(() => { - var nodeReader = new XmlNodeReader(null); + new XmlNodeReader(null); }); } } diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Constructor_AddSchema.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Constructor_AddSchema.cs index d50e1791bee41..c77779df86383 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Constructor_AddSchema.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Constructor_AddSchema.cs @@ -116,7 +116,6 @@ public void SetSchemaSetTo_Empty_NotCompiled_Compiled(string schemaSetStatus) public void SetSchemaSetWithInvalidContent_TypeCollision() { XmlSchemaValidator val; - XmlSchemaInfo info = new XmlSchemaInfo(); XmlSchemaSet sch = new XmlSchemaSet(); @@ -277,7 +276,6 @@ public void AddSameXmlSchemaWithTargetNamespaceTwice() public void AddSchemasWithTypeCollision() { XmlSchemaValidator val = CreateValidator(new XmlSchemaSet()); - XmlSchemaInfo info = new XmlSchemaInfo(); val.AddSchema(XmlSchema.Read(XmlReader.Create(new StringReader("\n" + "\n" + diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedAttributes.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedAttributes.cs index 3ffc3445d5c5c..d273c64915de2 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedAttributes.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedAttributes.cs @@ -25,7 +25,6 @@ public TCGetExpectedAttributes(ITestOutputHelper output): base(output) public void CallAtRootLevel_Without_With_PartialValidationSet(bool partialValidation) { XmlSchemaValidator val; - XmlSchemaInfo info = new XmlSchemaInfo(); XmlSchemaSet schemas = CreateSchemaSet("", "\n" + "\n" + " \n" + diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedParticles.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedParticles.cs index fabc69ec3df76..d19209a0e6a81 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedParticles.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/GetExpectedParticles.cs @@ -576,7 +576,6 @@ public void CallForElementWithoutTypeDefined() { XmlSchemaValidator val; XmlSchemaInfo info = new XmlSchemaInfo(); - XmlSchemaSet schemas = new XmlSchemaSet(); XmlSchemaParticle[] result; val = CreateValidator(XSDFILE_GET_EXPECTED_PARTICLES); diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs index dfdd5bfafa8ff..2481f02be0fbb 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs @@ -480,7 +480,6 @@ public void Pass_XmlSchemaAnnotation_XmlSchemaGroup_XmlSchemaAny_Invalid(string 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)); diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs index 24c753ccbd9f0..b6b3d724e8c7c 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs @@ -123,7 +123,6 @@ public void SetResolverToCustomValidateSomethignChangeResolverThenVerify() 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 @@ public void SetResolverToCustomValidateSomethingSetResolverToNullThenVerify() 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, diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs index 3880743a0d34c..760108694f7dc 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs @@ -68,7 +68,6 @@ public void PassNullValueGetter__Invalid() public void PassNullXmlSchemaInfo__Valid() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE); - XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("OneAttributeElement", "", null); @@ -202,17 +201,14 @@ public void ValidateSameAttributeTwice() 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 @@ public void CallWithoutValidationOfDefaultAttributesGetUnspecifiedDefault_Called public void CallWithoutValidationOfRequiredAttribute() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE); - ArrayList atts = new ArrayList(); val.Initialize(); val.ValidateElement("RequiredAttributeElement", "", null); diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs index 94b207e0a387e..bf8ee8caa847e 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs @@ -68,7 +68,6 @@ public void PassNullValueGetter__Invalid() public void PassNullXmlSchemaInfo__Valid() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE); - XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("OneAttributeElement", "", null); diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs index 959c52e224eb6..c7bb329dc466d 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs @@ -290,7 +290,6 @@ public void CallWithXsiNilTrue() public void ProvideValidXsiType() { XmlSchemaValidator val; - XmlSchemaInfo info = new XmlSchemaInfo(); XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable()); XmlSchemaSet schemas = new XmlSchemaSet(); @@ -308,7 +307,6 @@ public void ProvideValidXsiType() public void ProvideInvalidXsiType() { XmlSchemaValidator val; - XmlSchemaInfo info = new XmlSchemaInfo(); XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable()); XmlSchemaSet schemas = new XmlSchemaSet(); diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs index 2cf937a5c6d87..ae30ed823485e 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs @@ -43,7 +43,7 @@ public void v1(string testDir, string testFile, int expCount, int expCountGT, in 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 @@ public void v1(string testDir, string testFile, int expCount, int expCountGT, in 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 @@ public void v2(string testDir, string testFile, int expCount, int expCountGT, in 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 @@ public void v1(string testDir, string testFile, int expCount, int expCountGT, in 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 @@ public void v2(string testDir, string testFile, int expCount, int expCountGT, in 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 @@ public void v2(string testDir, string testFile, int expCount, int expCountGT, in 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 @@ public void AddValid_Import_Include_Redefine(string testDir, string testFile, in 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 @@ public void AddEditInvalidImport(string testDir, string testFile, int expCountGT 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 @@ public void XmlSchemaSetCompileAfterRemovingLastSchemaInTheSetIsNotClearingCache } } - XmlSchema removedSchema = ss.Remove(schema); + ss.Remove(schema); Assert.Equal(0, ss.Count); ss.Compile(); Assert.Equal(0, ss.Count); @@ -721,7 +719,7 @@ public void XmlSchemaSetCompileAfterRemovingLastSchemaInTheSetIsNotClearingCache 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 @@ public void SchemaPatternFacetHandlesRegularExpressionsWrong() { Initialize(); - Regex regex = new Regex(@"^\w+$"); string schemaContent = @" diff --git a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs index b80d7ce40346a..182fb0a3d717d 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs @@ -1917,7 +1917,6 @@ public static void XmlSchemaExporter_ExportMembersMapping_NotSupportedDefaultVal 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(() => exporter.ExportMembersMapping(mappings)); @@ -1959,7 +1958,7 @@ public static void IXmlTextParserTest() string xmlFileContent = @"2003-01-08T15:00:00-00:00"; Stream sm = GenerateStreamFromString(xmlFileContent); XmlTextReader reader = new XmlTextReader(sm); - MyXmlTextParser text = new MyXmlTextParser(reader); + new MyXmlTextParser(reader); } [Fact] @@ -2186,9 +2185,6 @@ public static void XmlMembersMapping_TypeHavingIntArray() public static void XmlMembersMapping_TypeWithXmlAttributes() { string memberName = "data"; - string ns = s_defaultNs; - XmlReflectionMember member = GetReflectionMember(memberName, ns); - var members = new XmlReflectionMember[] { member }; TypeWithXmlAttributes value = new TypeWithXmlAttributes { MyName = "fooname", Today = DateTime.Now }; var actual = RoundTripWithXmlMembersMapping(value, diff --git a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs index 495481038b7e2..a535361ba50bf 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs @@ -741,7 +741,7 @@ public static void Xml_DeserializeOutOfRangeByteProperty() writer.Flush(); stream.Position = 0; Assert.Throws(() => { - var deserializedObj = (TypeWithByteProperty)serializer.Deserialize(stream); + _ = (TypeWithByteProperty)serializer.Deserialize(stream); }); } } @@ -817,7 +817,6 @@ public static void Xml_TypeWithByteArrayAsXmlText() [Fact] public static void Xml_SimpleType() { - var serializer = new XmlSerializer(typeof(SimpleType)); var obj = new SimpleType { P1 = "foo", P2 = 1 }; var deserializedObj = SerializeAndDeserialize(obj, @"