Skip to content

Conversation

@anthonylangsworth
Copy link

I have replaced all XmlUrlResolver uses that reference files, usually using @tintoy 's create temp file methods, with XmlPreloadedResolver mapping the specified file(s) to the desired substitutions. This has many advantages:

  1. There is no file access, hopefully resolving the concurrency issues.
  2. This leaves the examples unchanged from the specs.
  3. XmlPreloadedResolver throws an exception when a reference is unresolved whereas XmlUrlResolver returns 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


namespace System.Security.Cryptography.Xml.Tests
{
public class TempFile : IDisposable
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tintoy
Copy link

tintoy commented Mar 4, 2017

@anthonylangsworth
Copy link
Author

@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.

@tintoy
Copy link

tintoy commented Mar 4, 2017

What I linked to above was basically the same solution you had (custom XmlResolver, all in-memory, no file I/O), but ignoring the path component of the URI. It's all good - what we have now works, so I'm happy :)

@tintoy
Copy link

tintoy commented Mar 4, 2017

(ignore the other contents of that file - it was just a handy commit to point to)

@anthonylangsworth
Copy link
Author

@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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, this xml doc is long

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's test code, but it's shared test code ;-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Fact()

@krwq
Copy link
Owner

krwq commented Mar 4, 2017

Thanks @anthonylangsworth! Looks good - only comment about Fact() - we can fix it separately though - let's test this on corefx CI

@krwq krwq merged commit e5b43ed into krwq:signed-xml-fixing-tests-1 Mar 4, 2017
krwq pushed a commit that referenced this pull request Mar 6, 2017
krwq pushed a commit that referenced this pull request Jun 2, 2017
Remove dead code from System.ComonentModel.TypeConverter for issue #1
krwq pushed a commit that referenced this pull request Jul 11, 2017
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.
krwq pushed a commit that referenced this pull request Mar 1, 2018
dotnet#26744)

* Added tests for Microsoft.VisualBasic.CompilerServices.Conversions #14344

* added tests for ToBoolean fro Object
krwq pushed a commit that referenced this pull request Mar 1, 2018
* 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
krwq pushed a commit that referenced this pull request Oct 25, 2018
* 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
krwq pushed a commit that referenced this pull request Aug 12, 2019
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants