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

Remove OpenXmlPackage.Close and references #1372

Closed
wants to merge 1 commit into from
Closed

Remove OpenXmlPackage.Close and references #1372

wants to merge 1 commit into from

Conversation

tomjebo
Copy link
Collaborator

@tomjebo tomjebo commented Mar 29, 2023

No description provided.

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.

A few comments about refactoring things so we never call dispose directly

SpreadsheetDocument? sd = ExampleUtilities.CreateSpreadsheetWorkbook(filePath, sheetName);

if (sd != null)
using (SpreadsheetDocument? sd = ExampleUtilities.CreateSpreadsheetWorkbook(filePath, sheetName))
Copy link
Member

Choose a reason for hiding this comment

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

use using SpreadsheetDocument? sd = ....; instead without indenting the files

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

@@ -20,7 +20,7 @@ public void CanCreatePresentationFromTemplate()
var part = packageDocument.PresentationPart;
var root = part.Presentation;

packageDocument.SaveAs(Path.GetTempFileName()).Close();
packageDocument.SaveAs(Path.GetTempFileName()).Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

Can you refactor these usages to be within a using block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, of course

@@ -33,7 +33,7 @@ public void CanCloneDocument()
{
var body = clone.MainDocumentPart.Document.Body;
body.InsertBefore(new Paragraph(new Run(new Text("Hello World"))), body.FirstChild);
clone.SaveAs(file.Path).Close();
clone.SaveAs(file.Path).Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

Please refactor things such that we never call dispose directly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yup

@tomjebo
Copy link
Collaborator Author

tomjebo commented Mar 30, 2023

replaced this PR with #1373

@tomjebo tomjebo closed this Mar 30, 2023
@tomjebo tomjebo deleted the remove_close branch March 30, 2023 00:22
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.

2 participants