Skip to content

Commit

Permalink
Add ability to view complete source code for an object
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Blanchard committed Nov 17, 2021
1 parent 9c718d4 commit c5ba7af
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Metadata/AOTBrowser/AOTBrowser/AxForm/ARBAOTBrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,12 @@ public class ARBAOTBrowser extends FormRun
ARBAOTObjectProperties.insert();
}
if (showCode && Arbela.Dynamics.Ax.Xpp.MetadataSupport::CanGetSourceText(object))
{
CodeViewer.parmHtml(Arbela.Dynamics.AX.Xpp.Support.HtmlFormatHelper::Format(Arbela.Dynamics.Ax.Xpp.MetadataSupport::GetXppSourceText(object)));
CodeViewerGroup.visible(true);
}
System.Type t = object.GetType();
var props = t.GetProperties();
Expand All @@ -464,7 +470,7 @@ public class ARBAOTBrowser extends FormRun
&& prop.Name != ARBAOTBrowserConstants::Design
&& prop.Name != ARBAOTBrowserConstants::FormControl)
{
if (showCode && (prop.Name == ARBAOTBrowserConstants::Source || prop.Name == ARBAOTBrowserConstants::ClassDeclaration || prop.Name == ARBAOTBrowserConstants::Declaration))
if (showCode && prop.Name == ARBAOTBrowserConstants::Source)
{
CodeViewer.parmHtml(Arbela.Dynamics.AX.Xpp.Support.HtmlFormatHelper::Format(this.getPropertyValue(prop, object)));
CodeViewerGroup.visible(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
<HintPath Condition="Exists('K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.dll')">K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Dynamics.AX.Metadata.Core">
<HintPath Condition="Exists('C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Core.dll')">C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Core.dll</HintPath>
<HintPath Condition="Exists('K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Core.dll')">K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Dynamics.AX.Metadata.Extensions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath Condition="Exists('C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Extensions.dll')">C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Extensions.dll</HintPath>
<HintPath Condition="Exists('K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Extensions.dll')">K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Dynamics.AX.Metadata.Storage">
<HintPath Condition="Exists('C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Storage.dll')">C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Storage.dll</HintPath>
<HintPath Condition="Exists('K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Storage.dll')">K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Metadata.Storage.dll</HintPath>
Expand All @@ -54,6 +63,10 @@
<HintPath Condition="Exists('C:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Xpp.Support.dll')">C:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Xpp.Support.dll</HintPath>
<HintPath Condition="Exists('K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Xpp.Support.dll')">K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Xpp.Support.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Dynamics.Framework.Tools.Core">
<HintPath Condition="Exists('C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.Framework.Tools.Core.dll')">C:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.Framework.Tools.Core.dll</HintPath>
<HintPath Condition="Exists('K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.Framework.Tools.Core.dll')">K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.Framework.Tools.Core.dll</HintPath>
</Reference>
<Reference Include="PygmentSharp.Core, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\PygmentSharp.Core.0.3.0\lib\netstandard2.0\PygmentSharp.Core.dll</HintPath>
</Reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
using Microsoft.Dynamics.AX.Metadata.MetaModel;
using System.Collections.Specialized;
using Microsoft.Dynamics.AX.Metadata.Storage;
using Microsoft.Dynamics.AX.Metadata.Core.MetaModel;
using Microsoft.Dynamics.AX.Metadata.Extensions;
using Microsoft.Dynamics.AX.Metadata;
using Microsoft.Dynamics.Framework.Tools.Core;

namespace Arbela.Dynamics.Ax.Xpp
{
Expand Down Expand Up @@ -198,5 +202,73 @@ public static IEnumerator<string> ServiceGroupNames()
{
return Accessor.GetServiceGroupNames().GetEnumerator();
}

public static string GetXppSourceText(INamedObject axElement)
{
return MetadataSupport.GetXppSourceText(axElement, null, true);
}

public static string GetXppSourceText(INamedObject axElement, IElementCodePositionCollector codePositionCollector, bool handleMetadataCorruptedException = true)
{
string result = string.Empty;
try
{
if (axElement is AxClass)
{
result = ((AxClass)axElement).GetCompleteSource(codePositionCollector);
}
else if (axElement is AxDataEntity)
{
result = ((AxDataEntity)axElement).GetCompleteSource(codePositionCollector);
}
else if (axElement is AxForm)
{
result = ((AxForm)axElement).GetCompleteSource(codePositionCollector);
}
else if (axElement is AxQuery)
{
result = ((AxQuery)axElement).GetCompleteSource(codePositionCollector);
}
else if (axElement is AxMacroDictionary)
{
result = ((AxMacroDictionary)axElement).GetCompleteSource(null);
}
else if (axElement is AxFormDataSourceRoot)
{
result = ((AxFormDataSourceRoot)axElement).GetCompleteSource(true, null);
}
else if (axElement is AxFormDataSourceField)
{
result = ((AxFormDataSourceField)axElement).GetCompleteSource(true, null);
}
else if (axElement is AxFormControl)
{
result = ((AxFormControl)axElement).GetCompleteSource(true, null);
}
}
catch (MetadataCorruptedException ex) when (handleMetadataCorruptedException)
{
AxLogHandler.DisplayError(ex.Message);
return string.Empty;
}
return result;
}

public static bool CanGetSourceText(Object checkObject)
{
if (checkObject is AxClass
|| checkObject is AxDataEntity
|| checkObject is AxForm
|| checkObject is AxQuery
|| checkObject is AxMacroDictionary
|| checkObject is AxFormDataSourceRoot
|| checkObject is AxFormDataSourceField
|| checkObject is AxFormControl)
{
return true;
}

return false;
}
}
}

0 comments on commit c5ba7af

Please sign in to comment.