Skip to content

Commit

Permalink
Version Bump to 0.3.2-alpha
Browse files Browse the repository at this point in the history
Bumping the version up to 0.3.2-alpha in the project file in preparation of the next (hopefully the last) alpha release.
Clean up/refactor some of the code generation in OpenXmlPackageExtensions to get rid of VS.NET warnings. Should not impact code behavior.
  • Loading branch information
rmboggs committed Jul 30, 2020
1 parent b7fc9a1 commit dbe1a19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
50 changes: 24 additions & 26 deletions src/Serialize.OpenXml.CodeGen/OpenXmlPackageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ DEALINGS IN THE SOFTWARE.
*/

using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Vml.Office;
using Serialize.OpenXml.CodeGen.Extentions;
using System;
using System.CodeDom;
Expand Down Expand Up @@ -87,33 +86,32 @@ public static CodeCompileUnit GenerateSourceCode(this OpenXmlPackage pkg, Namesp
CodeTypeDeclaration mainClass;
CodeTryCatchFinallyStatement tryAndCatch;
CodeFieldReferenceExpression docTypeVarRef = null;
Type docTypeEnum = null;
string docTypeEnumVal = null;
Type docTypeEnum;
string docTypeEnumVal;
KeyValuePair<string, Type> rootVarType;

// Add all initial namespace names first
namespaces.Add("System");

// The OpenXmlDocument derived parts all contain a property called "DocumentType"
// but the property types differ depending on the derived part. Need to get both
// the enum name of selected value to use as a parameter for the Create statement
if (pkg is PresentationDocument)
// the enum name of selected value to use as a parameter for the Create statement.
switch (pkg)
{
var docType = ((PresentationDocument)pkg).DocumentType;
docTypeEnumVal = docType.ToString();
docTypeEnum = docType.GetType();
}
else if (pkg is SpreadsheetDocument)
{
var docType = ((SpreadsheetDocument)pkg).DocumentType;
docTypeEnumVal = docType.ToString();
docTypeEnum = docType.GetType();
}
else if (pkg is WordprocessingDocument)
{
var docType = ((WordprocessingDocument)pkg).DocumentType;
docTypeEnumVal = docType.ToString();
docTypeEnum = docType.GetType();
case PresentationDocument p:
docTypeEnum = p.DocumentType.GetType();
docTypeEnumVal = p.DocumentType.ToString();
break;
case SpreadsheetDocument s:
docTypeEnum = s.DocumentType.GetType();
docTypeEnumVal = s.DocumentType.ToString();
break;
case WordprocessingDocument w:
docTypeEnum = w.DocumentType.GetType();
docTypeEnumVal = w.DocumentType.ToString();
break;
default:
throw new ArgumentException("object is not a recognized OpenXmlPackage type.", nameof(pkg));
}

// Create the entry method
Expand Down Expand Up @@ -201,14 +199,14 @@ public static CodeCompileUnit GenerateSourceCode(this OpenXmlPackage pkg, Namesp
if (pkg.Parts != null)
{
var customNewPartTypes = new Type[] { typeof(PresentationPart), typeof(WorkbookPart), typeof(MainDocumentPart) };
OpenXmlPartBluePrint bpTemp = null;
CodeMethodReferenceExpression referenceExpression = null;
CodeMethodInvokeExpression invokeExpression = null;
CodeMethodReferenceExpression methodReference = null;
Type currentPartType = null;
OpenXmlPartBluePrint bpTemp;
CodeMethodReferenceExpression referenceExpression;
CodeMethodInvokeExpression invokeExpression;
CodeMethodReferenceExpression methodReference;
Type currentPartType;
string varName = null;
string initMethodName = null;
string mainPartTypeName = null;
string mainPartTypeName;

foreach (var pair in pkg.Parts)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.3.1-alpha</Version>
<Version>0.3.2-alpha</Version>
<Authors>Ryan Boggs</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/rmboggs/Serialize.OpenXml.CodeGen</PackageProjectUrl>
Expand Down

0 comments on commit dbe1a19

Please sign in to comment.