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

New APIs to facillitate getting started #1548

Open
twsouthwick opened this issue Nov 1, 2023 · 1 comment
Open

New APIs to facillitate getting started #1548

twsouthwick opened this issue Nov 1, 2023 · 1 comment

Comments

@twsouthwick
Copy link
Member

twsouthwick commented Nov 1, 2023

This is a placeholder issue as we revamp some of the docs to identify APIs we should add to better handle common cases that are exposed by nullability analysis. There appears to be a lot of boilerplate to build up a document that requires null checking and then adding parts, etc that we could probably add some helper methods to simplify things.

For example:

Sheets? sheets = workbookPart.Workbook.GetFirstChild<Sheets>();

this could be null, so defensively, we would want something like:

Sheets sheets = workbookPart.Workbook.GetFirstChild<Sheets>() ?? workbookPart.Workbook.AppendChild(new Sheets());

This becomes cumbersome, when we could add something similar to:

Sheets sheets = workbookPart.Workbook.GetFirstChildOrAdd<Sheets>();

Addtional APIs may be helpful here, and so I'm creating this issue to track some of these quality of life related APIs. I think we should also consider identifying patterns for analyzers to catch to move people to these better patterns as well

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

3 participants