Skip to content

Commit b0d278c

Browse files
committed
Addressing remaining PR Feedback
1 parent db245e8 commit b0d278c

File tree

11 files changed

+147
-428
lines changed

11 files changed

+147
-428
lines changed

src/libraries/System.Data.Common/System.Data.Common.sln

Lines changed: 85 additions & 92 deletions
Large diffs are not rendered by default.

src/libraries/System.Private.Xml/src/ILLink/ILLink.Suppressions.xml

Lines changed: 0 additions & 317 deletions
This file was deleted.

src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchema.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,41 +89,39 @@ public XmlSchema() { }
8989
return parser.XmlSchema;
9090
}
9191

92-
[RequiresUnreferencedCode(XmlSerializer.TrimSerializationWarning)]
9392
public void Write(Stream stream)
9493
{
9594
Write(stream, null);
9695
}
9796

98-
[RequiresUnreferencedCode(XmlSerializer.TrimSerializationWarning)]
9997
public void Write(Stream stream, XmlNamespaceManager? namespaceManager)
10098
{
10199
XmlTextWriter xmlWriter = new XmlTextWriter(stream, null);
102100
xmlWriter.Formatting = Formatting.Indented;
103101
Write(xmlWriter, namespaceManager);
104102
}
105103

106-
[RequiresUnreferencedCode(XmlSerializer.TrimSerializationWarning)]
107104
public void Write(TextWriter writer)
108105
{
109106
Write(writer, null);
110107
}
111108

112-
[RequiresUnreferencedCode(XmlSerializer.TrimSerializationWarning)]
113109
public void Write(TextWriter writer, XmlNamespaceManager? namespaceManager)
114110
{
115111
XmlTextWriter xmlWriter = new XmlTextWriter(writer);
116112
xmlWriter.Formatting = Formatting.Indented;
117113
Write(xmlWriter, namespaceManager);
118114
}
119115

120-
[RequiresUnreferencedCode(XmlSerializer.TrimSerializationWarning)]
121116
public void Write(XmlWriter writer)
122117
{
123118
Write(writer, null);
124119
}
125120

126-
[RequiresUnreferencedCode(XmlSerializer.TrimSerializationWarning)]
121+
[DynamicDependency(TrimmerConstants.PublicMembers, typeof(XmlSchema))]
122+
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
123+
Justification = "Supressing warning since the right members of XmlSchema will be preserved by the " +
124+
"DynamicDependency attribute.")]
127125
public void Write(XmlWriter writer, XmlNamespaceManager? namespaceManager)
128126
{
129127
XmlSerializer serializer = new XmlSerializer(typeof(XmlSchema));

src/libraries/System.Private.Xml/src/System/Xml/Serialization/TypeExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ internal static class TypeExtensions
1212
private const string ImplicitCastOperatorName = "op_Implicit";
1313

1414
public static bool TryConvertTo(
15-
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods
16-
| DynamicallyAccessedMemberTypes.NonPublicMethods)] this Type targetType, object? data, out object? returnValue)
15+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]
16+
this Type targetType,
17+
object? data, out object? returnValue)
1718
{
1819
if (targetType == null)
1920
{

src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAttributes.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Reflection;
55
using System.ComponentModel;
6-
using System.Diagnostics.CodeAnalysis;
76

87
namespace System.Xml.Serialization
98
{

src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriterILGen.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,8 +1400,9 @@ private void WriteAttribute(SourceInfo source, AttributeAccessor attribute, stri
14001400
}
14011401

14021402
private static object? GetConvertedDefaultValue(
1403-
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods
1404-
| DynamicallyAccessedMemberTypes.NonPublicMethods)] Type? targetType, object? rawDefaultValue)
1403+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]
1404+
Type? targetType,
1405+
object? rawDefaultValue)
14051406
{
14061407
if (targetType == null)
14071408
{

src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private static XmlSerializerNamespaces DefaultNamespaces
150150
}
151151
}
152152

153-
// Linker warning messages
153+
// Trimmer warning messages
154154
internal const string TrimSerializationWarning = "Members from serialized types may be trimmed if not referenced directly";
155155
private const string s_trimDeserializationWarning = "Members from deserialized types may be trimmed if not referenced directly";
156156

src/libraries/System.Private.Xml/tests/TrimmingTests/System.Private.Xml.TrimmingTests.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<ItemGroup>
55
<TestConsoleAppSourceFiles Include="XslCompiledTransformTests.cs" />
6+
<TestConsoleAppSourceFiles Include="XmlSchema.Write.cs" />
67
</ItemGroup>
78

89
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.IO;
3+
using System.Xml;
4+
using System.Xml.Schema;
5+
6+
class XMLSchemaExamples
7+
{
8+
public static int Main()
9+
{
10+
11+
XmlSchema schema = new XmlSchema();
12+
13+
// <xs:element name="cat" type="xs:string"/>
14+
XmlSchemaElement elementCat = new XmlSchemaElement();
15+
schema.Items.Add(elementCat);
16+
elementCat.Name = "cat";
17+
elementCat.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
18+
19+
// <xs:element name="dog" type="xs:string"/>
20+
XmlSchemaElement elementDog = new XmlSchemaElement();
21+
schema.Items.Add(elementDog);
22+
elementDog.Name = "dog";
23+
elementDog.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
24+
25+
// <xs:element name="redDog" substitutionGroup="dog" />
26+
XmlSchemaElement elementRedDog = new XmlSchemaElement();
27+
schema.Items.Add(elementRedDog);
28+
elementRedDog.Name = "redDog";
29+
elementRedDog.SubstitutionGroup = new XmlQualifiedName("dog");
30+
31+
// <xs:element name="brownDog" substitutionGroup ="dog" />
32+
XmlSchemaElement elementBrownDog = new XmlSchemaElement();
33+
schema.Items.Add(elementBrownDog);
34+
elementBrownDog.Name = "brownDog";
35+
elementBrownDog.SubstitutionGroup = new XmlQualifiedName("dog");
36+
37+
// <xs:element name="pets">
38+
XmlSchemaElement elementPets = new XmlSchemaElement();
39+
schema.Items.Add(elementPets);
40+
elementPets.Name = "pets";
41+
42+
using (var stream = new MemoryStream())
43+
using (var writer = XmlWriter.Create(stream))
44+
{
45+
schema.Write(writer, null);
46+
}
47+
48+
return 100;
49+
}
50+
}

src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,17 +1479,11 @@ public void Compile(System.Xml.Schema.ValidationEventHandler? validationEventHan
14791479
public static System.Xml.Schema.XmlSchema? Read(System.IO.Stream stream, System.Xml.Schema.ValidationEventHandler? validationEventHandler) { throw null; }
14801480
public static System.Xml.Schema.XmlSchema? Read(System.IO.TextReader reader, System.Xml.Schema.ValidationEventHandler? validationEventHandler) { throw null; }
14811481
public static System.Xml.Schema.XmlSchema? Read(System.Xml.XmlReader reader, System.Xml.Schema.ValidationEventHandler? validationEventHandler) { throw null; }
1482-
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly")]
14831482
public void Write(System.IO.Stream stream) { }
1484-
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly")]
14851483
public void Write(System.IO.Stream stream, System.Xml.XmlNamespaceManager? namespaceManager) { }
1486-
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly")]
14871484
public void Write(System.IO.TextWriter writer) { }
1488-
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly")]
14891485
public void Write(System.IO.TextWriter writer, System.Xml.XmlNamespaceManager? namespaceManager) { }
1490-
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly")]
14911486
public void Write(System.Xml.XmlWriter writer) { }
1492-
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly")]
14931487
public void Write(System.Xml.XmlWriter writer, System.Xml.XmlNamespaceManager? namespaceManager) { }
14941488
}
14951489
public partial class XmlSchemaAll : System.Xml.Schema.XmlSchemaGroupBase

0 commit comments

Comments
 (0)