Skip to content
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

Fix data part references #934

Merged
merged 3 commits into from
Jun 16, 2021
Merged

Conversation

lklein53
Copy link
Contributor

No description provided.

@lklein53 lklein53 marked this pull request as ready for review May 14, 2021 16:32
@lklein53 lklein53 changed the title Fix data part references Fix data part references #931 May 14, 2021
@lklein53 lklein53 changed the title Fix data part references #931 Fix data part references May 14, 2021
@twsouthwick
Copy link
Member

/azp run

@twsouthwick
Copy link
Member

@lklein53 Thanks for this! I'll take a look early next week to see if this covers all of it. For now, looks like there are some style issues. We have warnings as errors, so ensure you have no local warnings. Also, you may want to build with the environment variable ProjectLoadStyle=All so that you build all targets (by default, you just build .net standard 2.0)

@twsouthwick
Copy link
Member

/azp run

@lklein53
Copy link
Contributor Author

Hm I fixed all local warnings in code that i touched. Is there some way for me to see what has failed ?

@twsouthwick
Copy link
Member

Not sure why sometimes the AzDo integration shows helpful info, and sometimes not.

Here's the test failure that is occuring:

icrosoft (R) Test Execution Command Line Tool Version 16.8.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Test run for /home/vsts/work/1/s/bin/Debug/DocumentFormat.OpenXml.Packaging.Tests/netcoreapp2.1/DocumentFormat.OpenXml.Packaging.Tests.dll (.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 16.8.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:03.45]     DocumentFormat.OpenXml.Packaging.Tests.OpenXmlPackageTests.TestDataReferenceRelationshipsAreClonedCorrectly [FAIL]
  Failed DocumentFormat.OpenXml.Packaging.Tests.OpenXmlPackageTests.TestDataReferenceRelationshipsAreClonedCorrectly [216 ms]
  Error Message:
   System.InvalidOperationException : Collection was modified; enumeration operation may not execute.
  Stack Trace:
     at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddSubPartFromOtherPackage(OpenXmlPart part, IDictionary`2 partDictionary, IDictionary`2 dataPartsDictionary, Boolean keepIdAndUri, String rId) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPartContainer.cs:line 1701
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddSubPartFromOtherPackage(OpenXmlPart part, IDictionary`2 partDictionary, IDictionary`2 dataPartsDictionary, Boolean keepIdAndUri, String rId) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPartContainer.cs:line 1677
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddSubPartFromOtherPackage(OpenXmlPart part, Boolean keepIdAndUri, String rId) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPartContainer.cs:line 1612
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddSubPart(OpenXmlPart part, String rId) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPartContainer.cs:line 1600
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.SetSubPart(OpenXmlPart part, String rId) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPartContainer.cs:line 1572
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddPartFrom(OpenXmlPart subPart, String rId) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPartContainer.cs:line 1544
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddPart[T](T part, String id) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPartContainer.cs:line 697
   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Clone(Stream stream, Boolean isEditable, OpenSettings openSettings) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPackage.cs:line 1138
   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Clone(Stream stream) in /_/src/DocumentFormat.OpenXml/Packaging/OpenXmlPackage.cs:line 1076
   at DocumentFormat.OpenXml.Packaging.Tests.OpenXmlPackageTests.TestDataReferenceRelationshipsAreClonedCorrectly() in /home/vsts/work/1/s/test/DocumentFormat.OpenXml.Packaging.Tests/OpenXmlPackageTests.cs:line 249
Results File: /home/vsts/work/_temp/_fv-az109-147_2021-05-15_18_41_52.trx

Failed!  - Failed:     1, Passed:   376, Skipped:     0, Total:   377, Duration: 10 s - /home/vsts/work/1/s/bin/Debug/DocumentFormat.OpenXml.Packaging.Tests/netcoreapp2.1/DocumentFormat.OpenXml.Packaging.Tests.dll (netcoreapp2.1)
Results File: /home/vsts/work/_temp/_fv-az109-147_2021-05-15_18_41_52[1].trx

@lklein53
Copy link
Contributor Author

Thanks. This looks like the code should have already failed before my change. The added test case is just showing the problem.
I think the current code should only work with net5 (https://stackoverflow.com/questions/66939923/what-changed-in-net-5-that-makes-it-not-throw-when-changing-dictionary-values-i). I added a commit that should work with all versions, but is a bit suboptimal for net 5. Would you prefer to have different versions of the code depending on the net version ?

Lars Klein added 2 commits May 20, 2021 08:39
This issue was uncovered by adding a new test case
@lklein53
Copy link
Contributor Author

lklein53 commented Jun 1, 2021

any update if this is a desired change ?

@twsouthwick
Copy link
Member

/azp run

@lklein53
Copy link
Contributor Author

lklein53 commented Jun 9, 2021

Thanks for running the pipeline again. And sorry that it failed again. I again can't see what failed. Locally everything seems fine

@lindalu-MSFT lindalu-MSFT merged commit 0952534 into dotnet:main Jun 16, 2021
@twsouthwick twsouthwick added this to the v2.13.1 milestone Jun 24, 2021
@twsouthwick
Copy link
Member

@lklein53 I just saw the comment about the enumeration only working on .NET 5. Feel free to add an optimized version with the #if NET50_OR_LATER precompiler directive (we'll probably add a target at some point for a later version depending on needed features)

@lklein53 lklein53 deleted the fix-data-part-references branch July 23, 2021 17:00
@lklein53
Copy link
Contributor Author

@twsouthwick i have created two implementations one optimized for NET50_OR_LATER and one for earlier versions.
The pr is in #996

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.

4 participants