Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public static class DataModelWriterExtensions
{
public static class AttributeStrings
{
public const string ObsoleteClassWarn = "[Obsolete(\"Unused class, will be removed in a future version.\", false)]";
public const string ObsoletePropertyWarn = "[Obsolete(\"Unused property, will be removed in a future version.\", false)]";
public const string ObsoletePropertyError = "[Obsolete(\"Unused property, will be removed in a future version.\", true)]";
public const string ObsoleteAttributeWarn = "[Obsolete(\"Unused attribute, will be removed in a future version.\", false)]";
public const string ObsoleteAttributeError = "[Obsolete(\"Unused attribute, will be removed in a future version.\", true)]";
public const string ObsoleteChildWarn = "[Obsolete(\"Obsolete child element, will be removed in a future version.\", false)]";
public const string EditorBrowsableAlways = "[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)] ";
public const string EditorBrowsableAdvanced = "[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] ";
public const string EditorBrowsableNever = "[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] ";
Expand All @@ -30,6 +32,18 @@ public static class AttributeStrings
AttributeStrings.EditorBrowsableNever,
];

private static readonly List<string> ObsoleteClassErrorList =
[
AttributeStrings.ObsoleteClassWarn,
AttributeStrings.EditorBrowsableNever,
];

private static readonly List<string> ObsoleteChildWarnList =
[
AttributeStrings.ObsoleteChildWarn,
AttributeStrings.EditorBrowsableNever,
];

// Use this dictionary to add attributes like ObsoleteAttribute or other directives to classes, child elements or attributes.
private static readonly Dictionary<TypedQName, Dictionary<TypedQName, List<string>>> _attributeData =
new Dictionary<TypedQName, Dictionary<TypedQName, List<string>>>()
Expand Down Expand Up @@ -117,6 +131,36 @@ public static class AttributeStrings
},
}
},
{
"xlpda:CT_PivotCacheDynamicArray/xlpda:pivotCacheDynamicArray",
new Dictionary<TypedQName, List<string>>()
{
{
"xlpda:CT_PivotCacheDynamicArray/xlpda:pivotCacheDynamicArray",
ObsoleteClassErrorList
},
}
},
{
"xprd:CT_PivotCacheRichInfo/xprd:richInfo",
new Dictionary<TypedQName, List<string>>()
{
{
"xprd:CT_PivotCacheRichInfo/xprd:richInfo",
ObsoleteClassErrorList
},
}
},
{
"x:CT_PivotCacheDefinitionExtension/x:ext",
new Dictionary<TypedQName, List<string>>()
{
{
"xprd:CT_PivotCacheRichInfo/xprd:richInfo",
ObsoleteChildWarnList
},
}
},
};

public static bool GetDataModelSyntax(this IndentedTextWriter writer, OpenXmlGeneratorServices services, SchemaNamespace model)
Expand Down Expand Up @@ -362,11 +406,22 @@ private static void WriteMetadata(this IndentedTextWriter writer, OpenXmlGenerat
{
var className = services.FindClassName(child);

if (className == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray" || className == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo")
{
writer.WriteLine("#pragma warning disable CS0618");
}

writer.Write("builder.AddChild(");

writer.Write(className);
writer.Write(".ElementType, static () => new ");
writer.Write(className);
writer.WriteLine("());");

if (className == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray" || className == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo")
{
writer.WriteLine("#pragma warning restore CS0618");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,23 @@ private static void WriteItemNode(this IndentedTextWriter writer, OpenXmlGenerat
if (particle.Kind == ParticleType.Element)
{
var info = services.FindClassName(particle.Name);

if (info == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray" || info == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo")
{
writer.WriteLine("#pragma warning disable CS0618");
}

writer.WriteObject("ElementParticle", particle, w =>
{
w.Write(info);
w.Write(".ElementType");
});

if (info == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray" || info == "DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo")
{
writer.WriteLine();
writer.WriteLine("#pragma warning restore CS0618");
}
}
else if (particle.Kind == ParticleType.Any)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData
/// <para>This class is available in Microsoft365 and above.</para>
/// <para>When the object is serialized out as xml, it's qualified name is xprd:richInfo.</para>
/// </summary>
[Obsolete("Unused class, will be removed in a future version.", false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public partial class PivotCacheRichInfo : OpenXmlLeafElement
{
#pragma warning disable CS0109
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays
/// <para>This class is available in Microsoft365 and above.</para>
/// <para>When the object is serialized out as xml, it's qualified name is xlpda:pivotCacheDynamicArray.</para>
/// </summary>
[Obsolete("Unused class, will be removed in a future version.", false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public partial class PivotCacheDynamicArray : OpenXmlLeafElement
{
#pragma warning disable CS0109
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47714,8 +47714,12 @@ internal override void ConfigureMetadata(ElementMetadata.Builder builder)
builder.AddChild(DocumentFormat.OpenXml.Office2013.Excel.PivotCacheDecoupled.ElementType, static () => new DocumentFormat.OpenXml.Office2013.Excel.PivotCacheDecoupled());
builder.AddChild(DocumentFormat.OpenXml.Office2013.Excel.PivotCacheIdVersion.ElementType, static () => new DocumentFormat.OpenXml.Office2013.Excel.PivotCacheIdVersion());
builder.AddChild(DocumentFormat.OpenXml.Office2013.Excel.TimelinePivotCacheDefinition.ElementType, static () => new DocumentFormat.OpenXml.Office2013.Excel.TimelinePivotCacheDefinition());
#pragma warning disable CS0618
builder.AddChild(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray.ElementType, static () => new DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray());
#pragma warning restore CS0618
#pragma warning disable CS0618
builder.AddChild(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo.ElementType, static () => new DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo());
#pragma warning restore CS0618
builder.AddChild(DocumentFormat.OpenXml.Office2021.Excel.Pivot.Xsdboolean.ElementType, static () => new DocumentFormat.OpenXml.Office2021.Excel.Pivot.Xsdboolean());
builder.AddChild(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotAutoRefresh.Xsdboolean.ElementType, static () => new DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotAutoRefresh.Xsdboolean());
builder.AddChild(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotVersionInfo.CacheVersionInfo.ElementType, static () => new DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotVersionInfo.CacheVersionInfo());
Expand All @@ -47732,10 +47736,16 @@ internal override void ConfigureMetadata(ElementMetadata.Builder builder)
new ElementParticle(DocumentFormat.OpenXml.Office2013.Excel.TimelinePivotCacheDefinition.ElementType, 1, 1, version: FileFormatVersions.Office2013),
new ElementParticle(DocumentFormat.OpenXml.Office2013.Excel.PivotCacheIdVersion.ElementType, 1, 1, version: FileFormatVersions.Office2013),
new ElementParticle(DocumentFormat.OpenXml.Office2021.Excel.Pivot.Xsdboolean.ElementType, 1, 1, version: FileFormatVersions.Office2021),
new ElementParticle(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo.ElementType, 1, 1, version: FileFormatVersions.Microsoft365),
#pragma warning disable CS0618
new ElementParticle(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotRichData.PivotCacheRichInfo.ElementType, 1, 1, version: FileFormatVersions.Microsoft365)
#pragma warning restore CS0618
,
new ElementParticle(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2022.PivotVersionInfo.CacheVersionInfo.ElementType, 1, 1, version: FileFormatVersions.Microsoft365),
new ElementParticle(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotAutoRefresh.Xsdboolean.ElementType, 1, 1, version: FileFormatVersions.Microsoft365),
new ElementParticle(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray.ElementType, 1, 1, version: FileFormatVersions.Microsoft365),
#pragma warning disable CS0618
new ElementParticle(DocumentFormat.OpenXml.Office.SpreadSheetML.Y2024.PivotDynamicArrays.PivotCacheDynamicArray.ElementType, 1, 1, version: FileFormatVersions.Microsoft365)
#pragma warning restore CS0618
,
new AnyParticle(0, 1)
};
}
Expand Down
Loading