Skip to content

Commit

Permalink
Add analysis info to header for yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-work committed Sep 14, 2023
1 parent 941f06c commit a2434a7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 54 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Ignore .idea IDE files
.idea/
44 changes: 23 additions & 21 deletions src/PAModel/CanvasDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,29 @@
using Microsoft.PowerPlatform.Formulas.Tools.Utility;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Microsoft.PowerPlatform.Formulas.Tools
{
/// <summary>
/// Represents a PowerApps document. This can be save/loaded from a MsApp or Source representation.
/// This is a full in-memory representation of the msapp file.
/// Represents a PowerApps document. This can be save/loaded from a MsApp or Source representation.
/// This is a full in-memory representation of the msapp file.
/// </summary>
public class CanvasDocument
{
/// <summary>
/// Current source format version.
/// Current source format version.
/// </summary>
public static Version CurrentSourceVersion => SourceSerializer.CurrentSourceVersion;

// Rules for CanvasDocument
// - Save/Load must faithfully roundtrip an msapp exactly.
// - this is an in-memory representation - so it must parse/shard everything on load.
// - Save should not mutate any state.
// - Save/Load must faithfully roundtrip an msapp exactly.
// - this is an in-memory representation - so it must parse/shard everything on load.
// - Save should not mutate any state.

// Track all unknown "files". Ensures round-tripping isn't lossy.
// Track all unknown "files". Ensures round-tripping isn't lossy.
// Only contains files of FileKind.Unknown
internal Dictionary<FilePath, FileEntry> _unknownFiles = new Dictionary<FilePath, FileEntry>();

Expand All @@ -43,7 +44,7 @@ public class CanvasDocument
internal EditorStateStore _editorStateStore;
internal TemplateStore _templateStore;

// Various data sources
// Various data sources
// This is references\dataSources.json
// Also includes entries for DataSources made from a DataComponent
// Key is parent entity name (datasource name for non cds data sources)
Expand Down Expand Up @@ -77,15 +78,15 @@ public class CanvasDocument
internal IDictionary<string, LocalDatabaseReferenceJson> _dataSourceReferences;

// Extracted from _properties.LibraryDependencies
// Must preserve server ordering.
// Must preserve server ordering.
internal ComponentDependencyInfo[] _libraryReferences;

internal FileEntry _logoFile;

// Save for roundtripping.
internal Entropy _entropy = new Entropy();

// Checksum from existing msapp.
// Checksum from existing msapp.
internal ChecksumJson _checksum;

// Track all asset files, key is file name
Expand All @@ -103,7 +104,7 @@ public class CanvasDocument
#region Save/Load

/// <summary>
/// Load an .msapp file for a Canvas Document.
/// Load an .msapp file for a Canvas Document.
/// </summary>
/// <param name="fullPathToMsApp">path to an .msapp file</param>
/// <returns>A tuple of the document and errors and warnings. If there are errors, the document is null. </returns>
Expand Down Expand Up @@ -152,6 +153,7 @@ public ErrorContainer SaveToMsApp(string fullPathToMsApp)
Utilities.EnsurePathRooted(fullPathToMsApp);

var errors = new ErrorContainer();
Debugger.Launch();
Wrapper(() => MsAppSerializer.SaveAsMsApp(this, fullPathToMsApp, errors), errors);
return errors;
}
Expand Down Expand Up @@ -219,7 +221,7 @@ public static (CanvasDocument, ErrorContainer) MakeFromSources(string appName, s

#endregion

// Wrapper to ensure consistent invariants between loading a document, exception handling, and returning errors.
// Wrapper to ensure consistent invariants between loading a document, exception handling, and returning errors.
private static CanvasDocument Wrapper(Func<CanvasDocument> worker, ErrorContainer errors)
{
CanvasDocument document = null;
Expand Down Expand Up @@ -322,7 +324,7 @@ internal CanvasDocument(CanvasDocument other)
_localAssetInfoJson = other._localAssetInfoJson.JsonClone();
}

// iOrder is used to preserve ordering value for round-tripping.
// iOrder is used to preserve ordering value for round-tripping.
internal void AddDataSourceForLoad(DataSourceEntry ds, int? order = null)
{
// Key is parent entity name
Expand Down Expand Up @@ -379,7 +381,7 @@ internal void ApplyAfterMsAppLoadTransforms(ErrorContainer errors)
var componentInstanceTransform = new ComponentInstanceTransform(errors);
var componentDefTransform = new ComponentDefinitionTransform(errors, _templateStore, componentInstanceTransform);

// Transform component definitions and populate template set of component instances that need updates
// Transform component definitions and populate template set of component instances that need updates
foreach (var ctrl in _components)
{
AddComponentDefaults(ctrl.Value, templateDefaults);
Expand Down Expand Up @@ -436,7 +438,7 @@ internal void ApplyBeforeMsAppWriteTransforms(ErrorContainer errors)
var componentInstanceTransform = new ComponentInstanceTransform(errors);
var componentDefTransform = new ComponentDefinitionTransform(errors, _templateStore, componentInstanceTransform);

// Transform component definitions and populate template set of component instances that need updates
// Transform component definitions and populate template set of component instances that need updates
foreach (var ctrl in _components)
{
componentDefTransform.BeforeWrite(ctrl.Value);
Expand Down Expand Up @@ -469,10 +471,10 @@ private void AddComponentDefaults(BlockNode topParent, Dictionary<string, Contro
}


// Called after loading. This will check internal fields and fill in consistency data.
// Called after loading. This will check internal fields and fill in consistency data.
internal void OnLoadComplete(ErrorContainer errors)
{
// Do integrity checks.
// Do integrity checks.
if (_header == null)
{
errors.FormatNotSupported("Missing header file");
Expand Down Expand Up @@ -505,7 +507,7 @@ internal void OnLoadComplete(ErrorContainer errors)
}
}

// Get ComponentIds for components we've imported.
// Get ComponentIds for components we've imported.
internal HashSet<string> GetImportedComponents()
{
var set = new HashSet<string>();
Expand Down Expand Up @@ -684,10 +686,10 @@ private void RestoreAssetFilePaths(ErrorContainer errors)
}
}

// Helper for traversing and ensuring unique control names.
// Helper for traversing and ensuring unique control names.
internal class UniqueControlNameVistor
{
// Control names are case sensitive.
// Control names are case sensitive.
private readonly Dictionary<string, SourceLocation?> _names = new Dictionary<string, SourceLocation?>(StringComparer.Ordinal);
private readonly ErrorContainer _errors;

Expand All @@ -698,7 +700,7 @@ public UniqueControlNameVistor(ErrorContainer errors)

public void Visit(BlockNode node)
{
// Ignore test templates here.
// Ignore test templates here.
// Test templates have control-like syntax, but allowed to repeat names:
// Step4 As TestStep:
if (AppTestTransform.IsTestSuite(node.Name.Kind.TypeName))
Expand Down
33 changes: 0 additions & 33 deletions src/PAModel/Schemas/HeaderJson.cs

This file was deleted.

0 comments on commit a2434a7

Please sign in to comment.