-
Notifications
You must be signed in to change notification settings - Fork 261
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
!DataSerializationHelper.SerializerSettings.SerializeReadOnlyTypes #1535
Comments
Untested (no pun intended, rly I have not managed to build using VS2022 yet) code change and test case below for your convenience, https://github.com/aliquid/testfx/tree/SerializeReadOnlyTypes |
By the way, similar to #1067 but different - allowing serializing of read-only data types seems like a trivial improvement with no side-effects. |
Hi @aliquid, Thanks for the bug report and thank you for the fix :) Can you please open the PR so we can move forward with the fix? I will sync with the team to see if we should cherry-pick that for a
I will update the contributing doc to be a little more precise and suggest not to create PR before approval for new features. The goal is to avoid wasting people's time if that's something we don't plan to do or plan to do differently. I think bug fixes are different.
Would you mind describing the errors you are facing with trying to build locally on your machine? I'd like to understand if that's "just" some doc that needs to be improved to help other contributes or if we have some more "complex" build issue. |
Hi @Evangelink, Opened PR, and unfortunately tests show this idea is a dud. https://github.com/microsoft/testfx/pull/1543/checks?check_run_id=10493375704 While data indeed is serialized, it is not being deserialized by When upgrading from v2.1.1 to v3.0.2 we need to put
Suggest we reject the PR and close this bug without further action. Maybe if somebody reports a similar bug saying "Dynamic test data gets corrupt when it has readonly structs" a solution less cludgy than putting
On VS2022 v17.4.3 I installed
|
I will have a deeper look after but we already have a couple of issues related to serialization of data during discovery (see #1462). So far the best option I see would be to use |
Keep up the good work! Let me know if I should do anything wrt this bug and the PR, feels abrupt closing from my end. For any passersby, we came up with the following workaround simplifying what does not survive se-de-serialization. I guess this shows why we can't have good things. 😄 public static IEnumerable<object[]> TESTDATA_COMPLEX()
{
yield return new object[]
{
"NAME OF TESTCASE",
DATA1, DATA2, DATAn
}, ...
}
public static IEnumerable<object[]> TESTDATA_SIMPLIFIED() => TESTDATA_COMPLEX().Select(x => new[] { x[0] });
[DataTestMethod]
[DynamicData(nameof(TESTDATA_SIMPLIFIED), DynamicDataSourceType.Method)]
public async Task TestWithComplexTestDataAsync(string testName /*PULLING OTHER DATA TO VARIABLES BELOW*/)
{
var data = TESTDATA_COMPLEX().Single(x => (string)x[0] == testName);
var DATA1 = (TYPEOFDATA1)data[1];
var DATA2 = (TYPEOFDATA2)data[2];
var DATAn = (TYPEOFDATAn)data[n];
} |
Thanks for the contribution and detailed explanations @aliquid. I will make sure to come back to you asap. |
Closing this one, please follow #1462 to get notification about the fix. |
Describe the bug
Read-only data cannot be used as dynamic data, because the serializer ignores read-only types. Use-case for read-only data is when the application subject for testing has that kind of data.
Steps To Reproduce
Conceptually in C# Interactive window, showing example of read-only data not being serialized unless
SerializeReadOnlyTypes=true
;For
DataSerializationHelperTests
instead, though I have not managed to build under VS2022 yet;Expected behavior
Dynamic test data with read-only types should not go lost.
Actual behavior
Read-only types in dynamic test data lose their values.
Additional context
Providing PR for your convenience.
The text was updated successfully, but these errors were encountered: