Skip to content

SerializationException in low trust floating point equality test #2526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ggeurts opened this issue Nov 1, 2017 · 5 comments
Closed

SerializationException in low trust floating point equality test #2526

ggeurts opened this issue Nov 1, 2017 · 5 comments

Comments

@ggeurts
Copy link
Contributor

ggeurts commented Nov 1, 2017

The following test throws when run in low trust appdomain:

var quantity = Quantity.Create(10.5, "mg/l");
Assert.That(quantity, Is.Not.Null);
Assert.That(quantity.UnitSymbol, Is.EqualTo("mg/l"));
Assert.That(quantity.Magnitude, Is.EqualTo(10.5)); // throws SerializationException

System.Runtime.Serialization.SerializationException : Type 'NUnit.Framework.Constraints.Tolerance' in Assembly 'nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' is not marked as serializable.

ggeurts added a commit to ggeurts/nunit that referenced this issue Nov 1, 2017
@CharliePoole
Copy link
Member

Explain what you mean about a low-trust AppDomain. Is it one you create yourself or the test domain created by NUnit?

@CharliePoole
Copy link
Member

Ah, never mind, I see your test.

As you know, Tolerance is never passed across a remoting boundary by NUNit. I see no harm in making it serializable, but if many more things like that should pop up I think we might want to rethink the strategy.

ggeurts added a commit to ggeurts/nunit that referenced this issue Nov 1, 2017
@ChrisMaddock
Copy link
Member

I'm a bit confused why Tolerance needs to be marked as Serializable, and nothing else. Does someone mind explaining what's going on here?

My thinking is I want to understand this to catch in future code reviews, but I'm not sure a) What's required to be marked as Serializable, and b) What NUnit supports running in low-trust.

@CharliePoole
Copy link
Member

Actually @ggeurts pretty much added all this functionality, which I didn't know we had! I'm guessing that it's a matter of passing back the Constraint Result and it's contents.

@ggeurts
Copy link
Contributor Author

ggeurts commented Nov 2, 2017

I added the functionality (and the LowTrustFixture) to get some NUnit 2 tests running again that verify that code was able to run within partial trust environments. This was done by running the code to be tested and the assertions in a separate appdomain with a reduced permission set. In NUnit 3 some constraint outcomes could indeed not be serialized across AppDomain boundaries, causing tests to fail.

rprouse added a commit that referenced this issue Nov 7, 2017
Issue #2526 - Fix Tolerance SerializationException in low-trust tests
@rprouse rprouse closed this as completed Nov 7, 2017
@rprouse rprouse added this to the 3.9 milestone Nov 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants