Do not remove resource messages in Xml tests (#81463)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Wed, 1 Feb 2023 21:28:09 +0000 (06:28 +0900)
committerGitHub <noreply@github.com>
Wed, 1 Feb 2023 21:28:09 +0000 (06:28 +0900)
Addresses first bullet of #81455.

Addresses 211 test failures to the tune of:

```
[FAIL] System.Xml.XmlSchemaValidatorApiTests.TCValidateWhitespace_String.WhitespaceInsideElement
System.Xml.Tests.VerifyException : GetManifestResourceStream() failed
   at System.Xml.Tests.ExceptionVerifier..ctor(String assemblyName, ExceptionVerificationFlags flags, ITestOutputHelper output) + 0x4c9
   at System.Xml.XmlSchemaValidatorApiTests.TCValidateWhitespace_String..ctor(ITestOutputHelper output) + 0x48
```

src/libraries/System.Private.Xml/tests/System.Private.Xml.Tests.csproj
src/libraries/System.Private.Xml/tests/default.rd.xml [new file with mode: 0644]

index 2b7df48..f076563 100644 (file)
@@ -7,6 +7,10 @@
     <IlcTrimMetadata>false</IlcTrimMetadata>
   </PropertyGroup>
 
+  <ItemGroup>
+    <RdXmlFile Include="default.rd.xml" />
+  </ItemGroup>
+
   <PropertyGroup Condition="'$(TargetOS)' == 'browser'">
     <!-- This doesn't run on V8 shell because https://bugs.chromium.org/p/v8/issues/detail?id=12541 -->
     <Scenario>WasmTestOnBrowser</Scenario>
diff --git a/src/libraries/System.Private.Xml/tests/default.rd.xml b/src/libraries/System.Private.Xml/tests/default.rd.xml
new file mode 100644 (file)
index 0000000..8177c40
--- /dev/null
@@ -0,0 +1,16 @@
+<Directives>
+  <Application>
+    <Assembly Name="System.Private.Xml">
+      <Type Name="System.SR">
+
+        <!--
+          This method is not actually reflected on by the tests, but its presence
+          tells the compiler not to optimize away the manifest resource that contains
+          resource strings. The tests do reflect on that one in the ExceptionVerifier class.   
+        -->
+        <Method Name="GetResourceString" Dynamic="Required All" />
+
+      </Type>
+    </Assembly>
+  </Application>
+</Directives>