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

Consider altChunk parts in Flat OPC transformation #659

Merged
merged 6 commits into from
Dec 22, 2019

Conversation

ThomasBarnekow
Copy link
Collaborator

This commit enhances the

XDocument OpenXmlPackage.ToFlatOpcDocument(XProcessingInstruction)

method to consider "altChunk parts" (AlternativeFormatInputParts),
which must have their content rendered in binary form even if it is XML
content (e.g., XML, XHTML).

Fixes #525.

@ThomasBarnekow
Copy link
Collaborator Author

@twsouthwick, how can I check why this failed? I don't have access to the Azure DevOps project.

All unit tests passed on my local machine, so I don't know what might have happened.

@ThomasBarnekow
Copy link
Collaborator Author

I might have found another "bug" in Directory.Build.props, which still lists net35.

<ProductTargetFrameworks>netstandard1.3;netstandard2.0;net35;net40;net46</ProductTargetFrameworks>

After setting ProjectLoadStyle to All, the build failed also on my machine. This was due to the fact that net35 does not provide the ISet<T> interface.

@ThomasBarnekow
Copy link
Collaborator Author

So I added a fix for net35 and the solution was built successfully and all unit tests passed. What goes wrong? I don't have access to the details.

rominator1983
rominator1983 previously approved these changes Dec 19, 2019
@ThomasBarnekow
Copy link
Collaborator Author

@rominator1983, do you have access to those details which might tell us why the check failed?

@twsouthwick
Copy link
Member

Good point about access. We're building it on the office dev ops instance so we can sign stuff... but we can't give access. I'll look into how we can expose that.

@twsouthwick
Copy link
Member

As for .NET 3.5, I do want to continue to support it, but it does limit some things. What I end up doing is adding stubs for the types to get things working. You can see under the System folder, a number of these, such as IReadOnlyLIst and others.

@twsouthwick
Copy link
Member

Thanks for taking a look at this. A few comments about some of the structure. I tend to avoid too much LINQ as recent profiling I've done has identified it as hot spots. I'm fine with starting off with it for getting correctness, but keeping them in separate methods will help during profiling to identify any specific queries that are problematic.

Also, I don't see any tests being added? Can you add some of those? Preferably more unit test style without needing a full file; just build up the components needed and the expected outcome.

@ThomasBarnekow
Copy link
Collaborator Author

@twsouthwick, thanks for your feedback.

Please have a look at the unit test in the OpenXmlPackageTests class in the DocumentFormat.OpenXml.Packaging.Tests project.

@twsouthwick
Copy link
Member

Must have missed the test - sorry about that. You can disregard that comment.

@ThomasBarnekow
Copy link
Collaborator Author

Made the changes requested by @twsouthwick. Rebased on master and fixed up some commits.

@ThomasBarnekow
Copy link
Collaborator Author

@twsouthwick, can you tell me what went wrong here? Setting ProjectLoadStyle to All, the solution is successfully built and all unit tests pass on my machine.

@twsouthwick
Copy link
Member

I have warnings as errors turned on. I recently added some FxCop rules to enforce StringComparer, so that's what's being raised:

src\DocumentFormat.OpenXml\Packaging\OpenXmlPackage.FlatOpc.cs(89,17): Error CA1307: The behavior of 'string.EndsWith(string)' could vary based on the current user's locale settings. Replace this call in 'DocumentFormat.OpenXml.Packaging.OpenXmlPackage.GetContentsAsXml(System.IO.Packaging.PackagePart, System.Collections.Generic.HashSet<System.Uri>)' with a call to 'string.EndsWith(string, System.StringComparison)'.

Not having access to the build is not good. I may create a separate devops instance for CI builds that I can make public. I'll look into that.

Copy link
Member

@twsouthwick twsouthwick left a comment

Choose a reason for hiding this comment

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

Looking much better. A couple more fixes and it should be good to merge in. Do you mind also updating the Changelog with an entry to this (referencing the PR)? I'm hoping to get a full release of 2.10 soon and would like this to be included

@ThomasBarnekow
Copy link
Collaborator Author

@twsouthwick, is it possible that you turned those FxCop rules on after my previous build? That would explain it because I did not change that line of code with the warning.

@twsouthwick
Copy link
Member

It was sometime yesterday (Pacific time) in the afternoon. Highly possible

@twsouthwick
Copy link
Member

I opened #666 as a tracking item for seeing build failures

This commit enhances the

  XDocument OpenXmlPackage.ToFlatOpcDocument(XProcessingInstruction)

method to consider "altChunk parts" (AlternativeFormatInputParts),
which must have their content rendered in binary form even if it is XML
content (e.g., XML, XHTML).

Fixes dotnet#525.
This commit firstly refactors the Flat OPC feature. Secondly, it
enhances the feature by supporting the round tripping of an OPC
document with altChunk parts via a Flat OPC document back to an OPC
document (as demonstrated by an additional unit test).
@ThomasBarnekow
Copy link
Collaborator Author

ThomasBarnekow commented Dec 20, 2019

@twsouthwick, unless you have further input, this would be it for now. I've updated CHANGELOG.md and also beautified the Flat OPC-related partial classes (where I also removed the redundant base type references).

Copy link
Member

@twsouthwick twsouthwick left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for responding to the feedback :)

@twsouthwick twsouthwick merged commit e7be7bb into dotnet:master Dec 22, 2019
@ThomasBarnekow ThomasBarnekow deleted the flat-opc-fix branch December 22, 2019 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants