Skip to content

Commit e069c61

Browse files
authored
Root element for generated parts should be nullable (#1922)
Changes root elements for generated parts to be nullable. Fixes #959 and #995
1 parent b127a66 commit e069c61

File tree

153 files changed

+361
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+361
-171
lines changed

gen/DocumentFormat.OpenXml.Generator.Models/Generators/Parts/PartWriter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static class PartWriter
2222
"DocumentFormat.OpenXml.Framework",
2323
"System",
2424
"System.Collections.Generic",
25+
"System.Diagnostics.CodeAnalysis",
2526
};
2627

2728
private static readonly BlockOptions _options = new()
@@ -410,7 +411,7 @@ private static IEnumerable<Item> GetSchemaTypedParts(OpenXmlGeneratorServices se
410411
writer.WriteDocumentationComment("Gets or sets the root element of this part.");
411412
writer.Write("public ");
412413
writer.Write(apiName);
413-
writer.Write(" ");
414+
writer.Write("? ");
414415
writer.WriteLine(api.Class);
415416

416417
using (writer.AddBlock(_options))

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_AlternativeFormatImportPart.g.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_CalculationChainPart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -32,7 +33,7 @@ internal CalculationChainPart()
3233
/// <summary>
3334
/// Gets or sets the root element of this part.
3435
/// </summary>
35-
public DocumentFormat.OpenXml.Spreadsheet.CalculationChain CalculationChain
36+
public DocumentFormat.OpenXml.Spreadsheet.CalculationChain? CalculationChain
3637
{
3738
get
3839
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_CellMetadataPart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -48,7 +49,7 @@ private protected override OpenXmlPartRootElement? InternalRootElement
4849
/// <summary>
4950
/// Gets or sets the root element of this part.
5051
/// </summary>
51-
public DocumentFormat.OpenXml.Spreadsheet.Metadata Metadata
52+
public DocumentFormat.OpenXml.Spreadsheet.Metadata? Metadata
5253
{
5354
get
5455
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_ChartColorStylePart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -32,7 +33,7 @@ internal ChartColorStylePart()
3233
/// <summary>
3334
/// Gets or sets the root element of this part.
3435
/// </summary>
35-
public DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.ColorStyle ColorStyle
36+
public DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.ColorStyle? ColorStyle
3637
{
3738
get
3839
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_ChartDrawingPart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -69,7 +70,7 @@ private protected override OpenXmlPartRootElement? InternalRootElement
6970
/// <summary>
7071
/// Gets or sets the root element of this part.
7172
/// </summary>
72-
public DocumentFormat.OpenXml.Drawing.Charts.UserShapes UserShapes
73+
public DocumentFormat.OpenXml.Drawing.Charts.UserShapes? UserShapes
7374
{
7475
get
7576
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_ChartPart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -44,7 +45,7 @@ internal ChartPart()
4445
/// <summary>
4546
/// Gets or sets the root element of this part.
4647
/// </summary>
47-
public DocumentFormat.OpenXml.Drawing.Charts.ChartSpace ChartSpace
48+
public DocumentFormat.OpenXml.Drawing.Charts.ChartSpace? ChartSpace
4849
{
4950
get
5051
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_ChartStylePart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -32,7 +33,7 @@ internal ChartStylePart()
3233
/// <summary>
3334
/// Gets or sets the root element of this part.
3435
/// </summary>
35-
public DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.ChartStyle ChartStyle
36+
public DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.ChartStyle? ChartStyle
3637
{
3738
get
3839
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_ChartsheetPart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -33,7 +34,7 @@ internal ChartsheetPart()
3334
/// <summary>
3435
/// Gets or sets the root element of this part.
3536
/// </summary>
36-
public DocumentFormat.OpenXml.Spreadsheet.Chartsheet Chartsheet
37+
public DocumentFormat.OpenXml.Spreadsheet.Chartsheet? Chartsheet
3738
{
3839
get
3940
{

generated/DocumentFormat.OpenXml/DocumentFormat.OpenXml.Generator/DocumentFormat.OpenXml.Generator.OpenXmlGenerator/Part_CommentAuthorsPart.g.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using DocumentFormat.OpenXml.Framework;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Diagnostics.CodeAnalysis;
1213

1314
namespace DocumentFormat.OpenXml.Packaging
1415
{
@@ -32,7 +33,7 @@ internal CommentAuthorsPart()
3233
/// <summary>
3334
/// Gets or sets the root element of this part.
3435
/// </summary>
35-
public DocumentFormat.OpenXml.Presentation.CommentAuthorList CommentAuthorList
36+
public DocumentFormat.OpenXml.Presentation.CommentAuthorList? CommentAuthorList
3637
{
3738
get
3839
{

0 commit comments

Comments
 (0)