Fix concurrency issues by removing file access#1
Conversation
|
|
||
| namespace System.Security.Cryptography.Xml.Tests | ||
| { | ||
| public class TempFile : IDisposable |
There was a problem hiding this comment.
This already exists in the common test code:
|
Nice one, @anthonylangsworth. I wrote a quick-and-dirty https://github.com/tintoy/corefx/blob/feature/xml-crypto/test-files-base-class/src/System.Security.Cryptography.Xml/tests/TestHelpers.cs#L62-L83 |
|
@tintoy I like what you have but I think a solution that bypasses file IO is preferred here. It is late so hit me with the clue bat if I have it wrong. |
|
What I linked to above was basically the same solution you had (custom |
|
(ignore the other contents of that file - it was just a handy commit to point to) |
|
@tintoy Sorry. I must have misread the code. |
| /// <exception cref="XmlException"> | ||
| /// <paramref name="inputXml"/> is not valid XML. | ||
| /// </exception> | ||
| public static string ExecuteTransform(string inputXml, Transform transform, Encoding encoding = null, XmlResolver resolver = null) |
There was a problem hiding this comment.
Yeah, it's test code, but it's shared test code ;-)
There was a problem hiding this comment.
Since this code is probably going to be shared across multiple test classes, I wanted to document it properly, including exceptions, so Intellisense will give the correct values.
| } | ||
|
|
||
| [Fact(Skip = "TODO: fix me")] | ||
| [Fact()] |
|
Thanks @anthonylangsworth! Looks good - only comment about |
Remove dead code from System.ComonentModel.TypeConverter for issue #1…
The following code throws an exception, caused by incorrect logic in BufferedStream.ReadByteSlow():
byte[] input = new byte[] { 1, 2 };
using (var reader = new BufferedStream(new MemoryStream(input), 2))
{
reader.ReadByte();
reader.ReadByte();
reader.ReadByte();
byte[] mybuffer = new byte[10];
reader.Read(mybuffer, 0, 1); // throws System.ArgumentOutOfRangeException: 'Non-negative number required.'
}
When the input data is exhausted through a sequence of ReadByte() calls, ReadByteSlow() does not reset _readPos to zero.
This causes a break in the contract specified in Read() - because because _readLen - _readPos is negative.
Then the block copy fails because the count to copy is negative.
Fix is to reset _readPos to zero before returning -1.
dotnet#26744) * Added tests for Microsoft.VisualBasic.CompilerServices.Conversions #14344 * added tests for ToBoolean fro Object
* NamedPipe: CurrentUserOnly, quick fixes for Unix * The path for the directory of when using current user only was wrong and not using the intended folder. * Added getpeerid validation on the server side. * Clean some dirty changes used for quick validation. * PR feedback round #1
* Fix ServiceController name population perf * Split tests * Remove dead field * Remove new use of DangerousGetHandle * SafeHandle all the things! * VSB #1 * VSB #2 * Fix GLE * Initialize machineName in ctor * Test for empty name ex * Null names * Inadvertent edit * Unix build * Move interop into class * Reverse SafeHandle for HAllocGlobal * Fix tests * Disable test for NETFX * CR feedback * Pattern matching on VSB * Direct call * typo
* Json prototype (#1) Basic API for Json writable DOM with scenarios including collection initialization, accessing and modifying Json nodes. * Json prototype - transformation API (#2) * transformation API added * assertions to existing scenarios added * Json prototype (#1) Basic API for Json writable DOM with scenarios including collection initialization, accessing and modifying Json nodes. * Json prototype - transformation API (#2) * transformation API added * assertions to existing scenarios added * JsonNumber implementation and tests (#3) * IEquatables added * JsonNumber implementation and unit tests added * pragmas deleted * review comments included, more tests added * decimal support added to JsonNumber * decimal support added to JsonArray and JsonObject * all unimplemented classes and methods with accompanying tests removed * First part of documentation added * documentation completed * missing exceptions added * JsonElement changes removed * part of the review comments included * work on review comments * code refactor * more decimal tests added using MemberData * more decimal tests added using MemberData * more test cases added * equals summary adjusted, equals tests added * more Equals tests added, GetHashCode tests added, minor changes * scientifing notation support added, rational numbers tests fixes * rational overflow tests added * ulong maxvalue tests added to rational types * presision problems fixes * exception strings fixed * CI failing fixes (hopefully), review comments included * missing == tests added to achieve 100% branch coverage * review comments included * trailing whitespaces fixes * equals comments added * equals object refactored to call quals json number * merge fix
I have replaced all
XmlUrlResolveruses that reference files, usually using @tintoy 's create temp file methods, withXmlPreloadedResolvermapping the specified file(s) to the desired substitutions. This has many advantages:XmlPreloadedResolverthrows an exception when a reference is unresolved whereasXmlUrlResolverreturns an empty string. This is better behavior for tests.I have cleaned up a few more tests while I was there. Most of the Transform tests appear to be copies of each other so there is scope to combine or parameterize these in the future.
CC: @krwq @tintoy @peterwurzinger