Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Updated assembly parser
Browse files Browse the repository at this point in the history
  • Loading branch information
msawczyn committed Nov 15, 2019
1 parent 832ed77 commit 12c4238
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 56 deletions.
9 changes: 7 additions & 2 deletions src/Dsl/CustomCode/Domain Types/Namespaces.cs
@@ -1,13 +1,18 @@
using Microsoft.VisualStudio.Modeling;
using System.ComponentModel;

using Microsoft.VisualStudio.Modeling;
using Microsoft.VisualStudio.Modeling.Design;

namespace Sawczyn.EFDesigner.EFModel
{

public class Namespaces
public class Namespaces: IHasStore
{
private readonly ModelRoot modelRoot;

[Browsable(false)]
public Store Store => modelRoot?.Store;

public Namespaces(ModelRoot modelRoot)
{
this.modelRoot = modelRoot;
Expand Down
3 changes: 2 additions & 1 deletion src/Dsl/CustomCode/Domain Types/OutputLocations.cs
Expand Up @@ -15,7 +15,8 @@ public OutputLocations(ModelRoot modelRoot)
this.modelRoot = modelRoot;
}

public Store Store => modelRoot.Store;
[Browsable(false)]
public Store Store => modelRoot?.Store;

// ReSharper disable once UnusedMember.Global
[TypeConverter(typeof(ProjectDirectoryTypeConverter))]
Expand Down
12 changes: 6 additions & 6 deletions src/Dsl/CustomCode/Partials/ModelClass.cs
Expand Up @@ -27,13 +27,13 @@ public string EffectiveNamespace
if (!string.IsNullOrWhiteSpace(namespaceStorage))
return namespaceStorage;

if (IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot.StructNamespace))
if (IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot?.StructNamespace))
return ModelRoot.StructNamespace;

if (!IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot.EntityNamespace))
if (!IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot?.EntityNamespace))
return ModelRoot.EntityNamespace;

return ModelRoot.Namespace;
return ModelRoot?.Namespace;
}
}

Expand All @@ -48,13 +48,13 @@ public string EffectiveOutputDirectory
if (!string.IsNullOrWhiteSpace(outputDirectoryStorage))
return outputDirectoryStorage;

if (IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot.StructOutputDirectory))
if (IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot?.StructOutputDirectory))
return ModelRoot.StructOutputDirectory;

if (!IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot.EntityOutputDirectory))
if (!IsDependentType && !string.IsNullOrWhiteSpace(ModelRoot?.EntityOutputDirectory))
return ModelRoot.EntityOutputDirectory;

return ModelRoot.ContextOutputDirectory;
return ModelRoot?.ContextOutputDirectory;
}
}

Expand Down
29 changes: 5 additions & 24 deletions src/Dsl/CustomCode/Partials/ModelEnum.cs
Expand Up @@ -51,37 +51,18 @@ public string EffectiveNamespace
return namespaceStorage;

// ReSharper disable once ConvertIfStatementToReturnStatement
if (!string.IsNullOrWhiteSpace(ModelRoot.EnumNamespace))
if (!string.IsNullOrWhiteSpace(ModelRoot?.EnumNamespace))
return ModelRoot.EnumNamespace;

return ModelRoot.Namespace;
}
}

/// <summary>
/// Output directory for generated code. Takes overrides into account.
/// </summary>
[Browsable(false)]
public string EffectiveOutputDirectory
{
get
{
if (!string.IsNullOrWhiteSpace(outputDirectoryStorage))
return outputDirectoryStorage;

// ReSharper disable once ConvertIfStatementToReturnStatement
if (!string.IsNullOrWhiteSpace(ModelRoot.EnumOutputDirectory))
return ModelRoot.EnumOutputDirectory;

return ModelRoot.ContextOutputDirectory;
return ModelRoot?.Namespace;
}
}

/// <summary>
/// Output location for generated code. Takes overrides into account.
/// </summary>
[Browsable(false)]
public string EffectiveOutputLocation
public string EffectiveOutputDirectory
{
get
{
Expand Down Expand Up @@ -287,7 +268,7 @@ private string GetOutputDirectoryValue()
{
try
{
return EffectiveOutputLocation;
return EffectiveOutputDirectory;
}
catch (NullReferenceException)
{
Expand All @@ -307,7 +288,7 @@ private string GetOutputDirectoryValue()

private void SetOutputDirectoryValue(string value)
{
outputDirectoryStorage = string.IsNullOrWhiteSpace(value) || value == EffectiveOutputLocation
outputDirectoryStorage = string.IsNullOrWhiteSpace(value) || value == EffectiveOutputDirectory
? null
: value;

Expand Down
1 change: 1 addition & 0 deletions src/Dsl/CustomCode/Utilities/Import/FileDropHelper.cs
Expand Up @@ -129,6 +129,7 @@ private static void Process(Store store, string filename, AssemblyProcessor asse
finally
{
Cursor.Current = Cursors.Default;
StatusDisplay.Show("");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dsl/DslDefinition.dsl
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Dsl xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="9987f227-3d05-49b7-b151-857879f5dfb8" Description="Entity Framework visual editor for EF6, EFCore and beyond." Name="EFModel" DisplayName="Entity Framework Visual Editor" Namespace="Sawczyn.EFDesigner.EFModel" MinorVersion="3" Revision="11" ProductName="EFDesigner" CompanyName="Michael Sawczyn" PackageGuid="56bbe1ba-aaee-4883-848f-e3c8656f8db2" PackageNamespace="Sawczyn.EFDesigner.EFModel" xmlns="http://schemas.microsoft.com/VisualStudio/2005/DslTools/DslDefinitionModel">
<Dsl xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="9987f227-3d05-49b7-b151-857879f5dfb8" Description="Entity Framework visual editor for EF6, EFCore and beyond." Name="EFModel" DisplayName="Entity Framework Visual Editor" Namespace="Sawczyn.EFDesigner.EFModel" MinorVersion="3" Revision="12" ProductName="EFDesigner" CompanyName="Michael Sawczyn" PackageGuid="56bbe1ba-aaee-4883-848f-e3c8656f8db2" PackageNamespace="Sawczyn.EFDesigner.EFModel" xmlns="http://schemas.microsoft.com/VisualStudio/2005/DslTools/DslDefinitionModel">
<Classes>
<DomainClass Id="95532cb8-3452-4b09-a654-aeb2e2d0b3ad" Description="" Name="ModelRoot" DisplayName="Entity Model" Namespace="Sawczyn.EFDesigner.EFModel">
<CustomTypeDescriptor>
Expand Down
15 changes: 15 additions & 0 deletions src/Dsl/GeneratedCode/PropertiesGrid.cs
Expand Up @@ -67,6 +67,9 @@ public partial class ModelRootTypeDescriptor : DslDesign::ElementTypeDescriptor
{
}

/// <summary>
/// Returns a collection of property descriptors
/// </summary>
public override global::System.ComponentModel.PropertyDescriptorCollection GetProperties(global::System.Attribute[] attributes)
{
// The following method needs to be added in a partial class
Expand Down Expand Up @@ -157,6 +160,9 @@ public partial class ModelClassTypeDescriptor : DslDesign::ElementTypeDescriptor
{
}

/// <summary>
/// Returns a collection of property descriptors
/// </summary>
public override global::System.ComponentModel.PropertyDescriptorCollection GetProperties(global::System.Attribute[] attributes)
{
// The following method needs to be added in a partial class
Expand Down Expand Up @@ -247,6 +253,9 @@ public partial class ModelAttributeTypeDescriptor : DslDesign::ElementTypeDescri
{
}

/// <summary>
/// Returns a collection of property descriptors
/// </summary>
public override global::System.ComponentModel.PropertyDescriptorCollection GetProperties(global::System.Attribute[] attributes)
{
// The following method needs to be added in a partial class
Expand Down Expand Up @@ -337,6 +346,9 @@ public partial class ModelEnumTypeDescriptor : DslDesign::ElementTypeDescriptor
{
}

/// <summary>
/// Returns a collection of property descriptors
/// </summary>
public override global::System.ComponentModel.PropertyDescriptorCollection GetProperties(global::System.Attribute[] attributes)
{
// The following method needs to be added in a partial class
Expand Down Expand Up @@ -427,6 +439,9 @@ public partial class AssociationTypeDescriptor : DslDesign::ElementTypeDescripto
{
}

/// <summary>
/// Returns a collection of property descriptors
/// </summary>
public override global::System.ComponentModel.PropertyDescriptorCollection GetProperties(global::System.Attribute[] attributes)
{
// The following method needs to be added in a partial class
Expand Down
10 changes: 5 additions & 5 deletions src/Dsl/GeneratedCode/SerializationHelper.cs
Expand Up @@ -244,7 +244,7 @@ internal virtual string ReadElementContentAsString(DslModeling::SerializationCon
/// <param name="isDiagram">Indicates whether a diagram or model file is currently being serialized.</param>
internal virtual global::System.Xml.XmlReaderSettings CreateXmlReaderSettings(DslModeling::SerializationContext serializationContext, bool isDiagram)
{
return new global::System.Xml.XmlReaderSettings();
return new global::System.Xml.XmlReaderSettings() { DtdProcessing = System.Xml.DtdProcessing.Prohibit };
}

/// <summary>
Expand Down Expand Up @@ -445,7 +445,7 @@ public virtual ModelRoot LoadModel(DslModeling::SerializationResult serializatio
this.InitializeSerializationContext(partition, serializationContext, true);
DslModeling::TransactionContext transactionContext = new DslModeling::TransactionContext();
transactionContext.Add(DslModeling::SerializationContext.TransactionContextKey, serializationContext);
using (DslModeling::Transaction t = partition.Store.TransactionManager.BeginTransaction("Load Model from " + location??"stream", true, transactionContext))
using (DslModeling::Transaction t = partition.Store.TransactionManager.BeginTransaction("Load Model from " + location ?? "stream", true, transactionContext))
{
// Ensure there is some content in the file. Blank (or almost blank, to account for encoding header bytes, etc.)
// files will cause a new root element to be created and returned.
Expand Down Expand Up @@ -506,7 +506,7 @@ public virtual ModelRoot LoadModel(DslModeling::SerializationResult serializatio
///// <param name="partition">Partition in which the new ModelRoot instance will be created.</param>
///// <param name="fileName">Name of the file from which the ModelRoot instance will be deserialized.</param>
///// <param name="modelRoot">The root of the file that was loaded.</param>
// private void OnPostLoadModel(DslModeling::SerializationResult serializationResult, DslModeling::Partition partition, string location, ModelRoot modelRoot )
// private void OnPostLoadModel(DslModeling::SerializationResult serializationResult, DslModeling::Partition partition, string fileName, ModelRoot modelRoot )

this.OnPostLoadModel(serializationResult, partition, location, modelRoot);
if (serializationResult.Failed)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ public virtual void WriteRootElement(DslModeling::SerializationContext serializa
// Only model has schema, diagram has no schema.
rootElementSettings.SchemaTargetNamespace = "http://schemas.microsoft.com/dsltools/EFModel";
}
rootElementSettings.Version = new global::System.Version("1.3.0.11");
rootElementSettings.Version = new global::System.Version("1.3.0.12");

// Carry out the normal serialization.
rootSerializer.Write(serializationContext, rootElement, writer, rootElementSettings);
Expand All @@ -1190,7 +1190,7 @@ protected virtual void CheckVersion(DslModeling::SerializationContext serializat
throw new global::System.ArgumentNullException("reader");
#endregion

global::System.Version expectedVersion = new global::System.Version("1.3.0.11");
global::System.Version expectedVersion = new global::System.Version("1.3.0.12");
string dslVersionStr = reader.GetAttribute("dslVersion");
if (dslVersionStr != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DslPackage/GeneratedCode/Constants.cs
Expand Up @@ -18,7 +18,7 @@ internal static partial class Constants
[global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public const string CompanyName = @"Michael Sawczyn";
[global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
public const string ProductVersion = "1.3.0.11";
public const string ProductVersion = "1.3.0.12";

// Menu definitions
public static readonly global::System.ComponentModel.Design.CommandID EFModelDiagramMenu = new global::System.ComponentModel.Design.CommandID(new global::System.Guid(EFModelCommandSetId), 0x10000);
Expand Down
31 changes: 16 additions & 15 deletions src/DslPackage/GeneratedCode/Package.cs
Expand Up @@ -174,19 +174,20 @@ protected override object GetToolboxItemData(string itemId, DataFormats.Format f
}

}
//
// Package attributes which may need to change are placed on the partial class below, rather than in the main include file.
//
namespace Sawczyn.EFDesigner.EFModel
{
/// <summary>
/// Double-derived class to allow easier code customization.
/// </summary>
[VSShell::ProvideMenuResource("1000.ctmenu", version: 25)]
[VSShell::ProvideToolboxItems(1)]
[global::Microsoft.VisualStudio.TextTemplating.VSHost.ProvideDirectiveProcessor(typeof(global::Sawczyn.EFDesigner.EFModel.EFModelDirectiveProcessor), global::Sawczyn.EFDesigner.EFModel.EFModelDirectiveProcessor.EFModelDirectiveProcessorName, "A directive processor that provides access to EFModel files")]
[global::System.Runtime.InteropServices.Guid(Constants.EFModelPackageId)]
internal sealed partial class EFModelPackage : EFModelPackageBase
{
}

//
// Package attributes which may need to change are placed on the partial class below, rather than in the main include file.
//
namespace Sawczyn.EFDesigner.EFModel
{
/// <summary>
/// Double-derived class to allow easier code customization.
/// </summary>
[VSShell::ProvideMenuResource("1000.ctmenu", version: 25)]
[VSShell::ProvideToolboxItems(1)]
[global::Microsoft.VisualStudio.TextTemplating.VSHost.ProvideDirectiveProcessor(typeof(global::Sawczyn.EFDesigner.EFModel.EFModelDirectiveProcessor), global::Sawczyn.EFDesigner.EFModel.EFModelDirectiveProcessor.EFModelDirectiveProcessorName, "A directive processor that provides access to EFModel files")]
[global::System.Runtime.InteropServices.Guid(Constants.EFModelPackageId)]
internal sealed partial class EFModelPackage : EFModelPackageBase
{
}
}
2 changes: 1 addition & 1 deletion src/DslPackage/source.extension.vsixmanifest
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="56bbe1ba-aaee-4883-848f-e3c8656f8db2" Version="1.3.0.11" Language="en-US" Publisher="Michael Sawczyn" />
<Identity Id="56bbe1ba-aaee-4883-848f-e3c8656f8db2" Version="1.3.0.12" Language="en-US" Publisher="Michael Sawczyn" />
<DisplayName>Entity Framework Visual Editor</DisplayName>
<Description>Entity Framework visual editor for EF6, EFCore and beyond.</Description>
<Icon>Logo.ico</Icon>
Expand Down

0 comments on commit 12c4238

Please sign in to comment.