Skip to content
This repository has been archived by the owner on Oct 3, 2021. It is now read-only.

Commit

Permalink
New component Child Structure #10
Browse files Browse the repository at this point in the history
Add Line Number For Serialization Errors #11
  • Loading branch information
daryllabar committed Dec 13, 2019
1 parent a8b263a commit bc265f9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CanvasAppPackager/CanvasAppPackager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>1.0.0.8</AssemblyVersion>
<FileVersion>1.0.0.6</FileVersion>
<AssemblyVersion>1.0.0.9</AssemblyVersion>
<FileVersion>1.0.0.9</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
37 changes: 37 additions & 0 deletions CanvasAppPackager/Poco/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ public class Template
{
public string Id { get; set; }
public string Version { get; set; }
public string LastModifiedTimestamp { get; set; }
public string Name { get; set; }
public bool? FirstParty { get; set; }
public bool IsCustomGroupControlTemplate { get; set; }
public string CustomGroupControlTemplateName { get; set; }
public string CustomControlDefinitionJson { get; set; }
public string DynamicControlDefinitionJson { get; set; }
public bool IsComponentDefinition { get; set; }
public List<CustomProperty> CustomProperties { get; set; }
public Component ComponentDefinitionInfo { get; set; }
public OverridableProperties OverridableProperties { get; set; }
}

Expand Down Expand Up @@ -92,6 +96,7 @@ public class Child : IControl
{
public string Type { get; set; }
public string Name { get; set; }
public string LastModifiedTimestamp { get; set; }
public Template Template { get; set; }
public double Index { get; set; }
public int? PublishOrderIndex { get; set; }
Expand All @@ -111,6 +116,7 @@ public class Child : IControl
public bool IsLocked { get; set; }
public string ControlUniqueId { get; set; }
public ControlThisItemType ControlThisItemType { get; set; }
public Metadata Metadata { get; set; }
public List<Child> Children { get; set; }
public List<ChildOrder> ChildrenOrder { get; set; }

Expand All @@ -128,6 +134,37 @@ public class ChildOrder
public string Name { get; set; }
}

public class Component
{
public string Name { get; set; }
public string LastModifiedTimestamp { get; set; }
public List<Rule> Rules { get; set; }
public List<ControlPropertyState> ControlPropertyState { get; set; }
public List<Child> Children { get; set; }

public Component()
{
Children = new List<Child>();
}
}

public class CustomProperty
{
public string Name { get; set; }
public int Category { get; set; }
public string Type { get; set; }
public string PropertyDataTypeKey { get; set; }
public bool Hidden { get; set; }
public bool? IsResettable { get; set; }
public string DisplayName { get; set; }
public string Tooltip { get; set; }
}

public class Metadata
{
public string Description { get; set; }
}

public class TopParent : IControl
{
public string Type { get; set; }
Expand Down
17 changes: 16 additions & 1 deletion CanvasAppPackager/UnpackLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,23 @@ private static void VerifySerialization(CanvasAppScreen screen, string json, str
var shortest = json.Length > newJson.Length
? newJson
: json;
var errorScope = Environment.NewLine + Environment.NewLine;
var lineNumber = 0;
var linePosition = 0;

var firstDifferentChar = shortest.Length;
for (var i = 0; i < shortest.Length; i++)
{
if(json[i] == '\n')
{
lineNumber++;
linePosition = 0;
}
else
{
linePosition++;
}

if (json[i] == newJson[i])
{
continue;
Expand All @@ -180,7 +193,9 @@ private static void VerifySerialization(CanvasAppScreen screen, string json, str
}

throw new
Exception($"Unable to re-serialize json to match source! Character at position {firstDifferentChar} is not correct. To prevent potential app defects, extracting file {file} has stopped.{Environment.NewLine}See '{jsonFile}' for extracted version vs output version '{newJsonFile}'.");
Exception($"Unable to re-serialize json to match source! Character at position: {firstDifferentChar} on line: {lineNumber} at {linePosition} is not correct. To prevent potential app defects, extracting file {file} has stopped.{Environment.NewLine}See '{jsonFile}' for extracted version vs output version '{newJsonFile}'.{(string.IsNullOrWhiteSpace(errorScope) ? string.Empty : errorScope)}");


}
}

Expand Down

0 comments on commit bc265f9

Please sign in to comment.