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

Commit

Permalink
Testing:
Browse files Browse the repository at this point in the history
   - Fix to detecting correct EF version with anything with "Latest" in it is configured (see #266)
   - Fix to generate correct initial value code for decimal properties (see #268)
   - Fix for constructor code generation in 1-N unidirectional associations (see #263)
  • Loading branch information
msawczyn committed Feb 11, 2021
1 parent fb15145 commit 18e6a00
Show file tree
Hide file tree
Showing 370 changed files with 23,663 additions and 5,337 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
3.0.4
- Added context menu choice to visually align node elements on diagrams.
- Fix to detecting correct EF version with anything with "Latest" in it is configured (see https://github.com/msawczyn/EFDesigner/issues/266)
- Fix to generate correct initial value code for decimal properties (see https://github.com/msawczyn/EFDesigner/issues/268)
- Fix for constructor code generation in 1-N unidirectional associations (see https://github.com/msawczyn/EFDesigner/issues/263)

3.0.3
- Added VS UML icon for model file in solution explorer (thanks to https://github.com/dcastenholz for the change)
Expand Down
Binary file modified dist/Sawczyn.EFDesigner.EFModel.DslPackage.vsix
Binary file not shown.
23 changes: 13 additions & 10 deletions src/Dsl/CustomCode/Partials/Association.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ internal bool AllCardinalitiesAreValid(out string errorMessage)
}

[ValidationMethod(ValidationCategories.Save | ValidationCategories.Menu)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
// ReSharper disable once UnusedMember.Local
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void ValidateMultiplicity(ValidationContext context)
{
if (!AllCardinalitiesAreValid(out string errorMessage))
context.LogError(errorMessage, "AEUnsupportedMultiplicity", this);
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
// ReSharper disable once UnusedMember.Local
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void SummaryDescriptionIsEmpty(ValidationContext context)
{
if (Source?.ModelRoot == null) return;
Expand All @@ -268,8 +268,8 @@ private void SummaryDescriptionIsEmpty(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
// ReSharper disable once UnusedMember.Local
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void TPCEndpointsOnlyOnLeafNodes(ValidationContext context)
{
if (Source?.ModelRoot == null) return;
Expand All @@ -282,7 +282,7 @@ private void TPCEndpointsOnlyOnLeafNodes(ValidationContext context)

[ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void MustDetermineEndpointRoles(ValidationContext context)
{
if (Source?.ModelRoot == null)
Expand All @@ -298,7 +298,7 @@ private void MustDetermineEndpointRoles(ValidationContext context)

[ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void FKPropertiesCannotBeStoreGeneratedIdentifiers(ValidationContext context)
{

Expand Down Expand Up @@ -338,6 +338,7 @@ string GetShadowPropertyName(string nameBase)
if (SourceRole == EndpointRole.Dependent)
return $"{nameBase}{identityAttribute.Name}";

// ReSharper disable once ConvertIfStatementToReturnStatement
if (this is BidirectionalAssociation)
return $"{nameBase}{identityAttribute.Name}";

Expand All @@ -362,7 +363,8 @@ string GetShadowPropertyNameBase()
}

[ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void FKPropertiesInvalidWithoutDependentEnd(ValidationContext context)
{
if (string.IsNullOrWhiteSpace(FKPropertyName))
Expand All @@ -377,7 +379,8 @@ private void FKPropertiesInvalidWithoutDependentEnd(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Save | ValidationCategories.Load | ValidationCategories.Menu)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void FKPropertiesMatchIdentityProperties(ValidationContext context)
{
if (string.IsNullOrWhiteSpace(FKPropertyName) || Principal == null)
Expand Down
5 changes: 3 additions & 2 deletions src/Dsl/CustomCode/Partials/BidirectionalAssociation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.VisualStudio.Modeling;
using Microsoft.VisualStudio.Modeling.Validation;

using Sawczyn.EFDesigner.EFModel.Annotations;
using Sawczyn.EFDesigner.EFModel.Extensions;

namespace Sawczyn.EFDesigner.EFModel
Expand All @@ -19,8 +20,8 @@ private string GetSourcePropertyNameDisplayValue()
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
// ReSharper disable once UnusedMember.Local
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validatioin")]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void SummaryDescriptionIsEmpty(ValidationContext context)
{
if (Source?.ModelRoot == null) return;
Expand Down
46 changes: 22 additions & 24 deletions src/Dsl/CustomCode/Partials/ModelAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using Microsoft.VisualStudio.Modeling;
Expand All @@ -13,7 +12,7 @@
namespace Sawczyn.EFDesigner.EFModel
{
[ValidationState(ValidationState.Enabled)]
[SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
public partial class ModelAttribute : IModelElementInCompartment, IDisplaysWarning, IHasStore
{
internal const int MAXLENGTH_MAX = -1;
Expand Down Expand Up @@ -116,8 +115,6 @@ public bool SupportsInitialValue
/// <param name="typeName">Name of type to test. If typeName is null, Type property will be used. If initialValue is null, InitialValue property will be used</param>
/// <param name="initialValue">Initial value to test</param>
/// <returns>true if InitialValue is a valid value for the type, or if initialValue is null or empty</returns>
#pragma warning disable 168
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
public bool IsValidInitialValue(string typeName = null, string initialValue = null)
{
typeName = typeName ?? Type;
Expand Down Expand Up @@ -154,9 +151,9 @@ public bool IsValidInitialValue(string typeName = null, string initialValue = nu
case "Polygon":
return false; //string.IsNullOrEmpty(initialValue);
case "Boolean":
return bool.TryParse(initialValue, out bool _bool);
return bool.TryParse(initialValue, out _);
case "Byte":
return byte.TryParse(initialValue, out byte _byte);
return byte.TryParse(initialValue, out _);
case "DateTime":
switch (initialValue?.Trim())
{
Expand All @@ -166,41 +163,40 @@ public bool IsValidInitialValue(string typeName = null, string initialValue = nu
case "DateTime.MaxValue":
return true;
default:
return DateTime.TryParse(initialValue, out DateTime _dateTime);
return DateTime.TryParse(initialValue, out _);
}
case "DateTimeOffset":
return DateTimeOffset.TryParse(initialValue, out DateTimeOffset _dateTimeOffset);
return DateTimeOffset.TryParse(initialValue, out _);
case "Decimal":
return Decimal.TryParse(initialValue, out Decimal _decimal);
return Decimal.TryParse(initialValue, out _);
case "Double":
return Double.TryParse(initialValue, out Double _double);
return Double.TryParse(initialValue, out _);
case "Guid":
return Guid.TryParse(initialValue, out Guid _guid);
return Guid.TryParse(initialValue, out _);
case "Int16":
return Int16.TryParse(initialValue, out Int16 _int16);
return Int16.TryParse(initialValue, out _);
case "UInt16":
return UInt16.TryParse(initialValue, out UInt16 _uint16);
return UInt16.TryParse(initialValue, out _);
case "Int32":
return Int32.TryParse(initialValue, out Int32 _int32);
return Int32.TryParse(initialValue, out _);
case "UInt32":
return UInt32.TryParse(initialValue, out UInt32 _uint32);
return UInt32.TryParse(initialValue, out _);
case "Int64":
return Int64.TryParse(initialValue, out Int64 _int64);
return Int64.TryParse(initialValue, out _);
case "UInt64":
return UInt64.TryParse(initialValue, out UInt64 _uint64);
return UInt64.TryParse(initialValue, out _);
case "SByte":
return SByte.TryParse(initialValue, out SByte _sbyte);
return SByte.TryParse(initialValue, out _);
case "Single":
return Single.TryParse(initialValue, out Single _single);
return Single.TryParse(initialValue, out _);
case "String":
return true;
case "Time":
return DateTime.TryParseExact(initialValue,
new[] { "HH:mm:ss", "H:mm:ss", "HH:mm", "H:mm", "HH:mm:ss tt", "H:mm:ss tt", "HH:mm tt", "H:mm tt" },
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out DateTime _time);
// ReSharper restore UnusedVariable
out _);
default:
if (initialValue.Contains("."))
{
Expand All @@ -214,7 +210,6 @@ public bool IsValidInitialValue(string typeName = null, string initialValue = nu

return false;
}
#pragma warning restore 168

/// <summary>
/// From internal class System.Data.Metadata.Edm.PrimitiveType in System.Data.Entity. Converts the attribute's CLR type to a C# primitive type.
Expand Down Expand Up @@ -935,6 +930,7 @@ internal static (string ef6Version, string efCoreVersion)[] GeometryTypes = {

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void GeographyTypeDoesNotMatchEFVersion(ValidationContext context)
{
if (ModelClass?.ModelRoot == null) return;
Expand Down Expand Up @@ -966,7 +962,8 @@ private void GeographyTypeDoesNotMatchEFVersion(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
// ReSharper disable once UnusedMember.Local
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void StringsShouldHaveLength(ValidationContext context)
{
if (ModelClass?.ModelRoot == null) return;
Expand All @@ -980,7 +977,8 @@ private void StringsShouldHaveLength(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
// ReSharper disable once UnusedMember.Local
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void SummaryDescriptionIsEmpty(ValidationContext context)
{
if (ModelClass?.ModelRoot == null) return;
Expand Down
21 changes: 21 additions & 0 deletions src/Dsl/CustomCode/Partials/ModelClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.VisualStudio.Modeling;
using Microsoft.VisualStudio.Modeling.Validation;

using Sawczyn.EFDesigner.EFModel.Annotations;
using Sawczyn.EFDesigner.EFModel.Extensions;

// ReSharper disable UnusedMember.Global
Expand Down Expand Up @@ -493,6 +494,8 @@ internal void MoveAttribute(ModelAttribute attribute, ModelClass destination)
#region Validations

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void ClassShouldHaveAttributes(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -506,6 +509,8 @@ private void ClassShouldHaveAttributes(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void OwnedTypeCannotHaveABaseClass(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -514,6 +519,8 @@ private void OwnedTypeCannotHaveABaseClass(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void OwnedTypeCannotHaveASubclass(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -522,6 +529,8 @@ private void OwnedTypeCannotHaveASubclass(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void OwnedTypeCannotBeAbstract(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -530,6 +539,8 @@ private void OwnedTypeCannotBeAbstract(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void OwnedTypeCannotBePrincipal(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -544,6 +555,8 @@ private void OwnedTypeCannotBePrincipal(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void OwnedTypeCannotBeInBidirectionalAssociation(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -553,6 +566,8 @@ private void OwnedTypeCannotBeInBidirectionalAssociation(ValidationContext conte
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void AttributesCannotBeNamedSameAsEnclosingClass(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -562,6 +577,8 @@ private void AttributesCannotBeNamedSameAsEnclosingClass(ValidationContext conte
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void PersistentClassesMustHaveIdentity(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -571,6 +588,8 @@ private void PersistentClassesMustHaveIdentity(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void DerivedClassesShouldNotHaveIdentity(ValidationContext context)
{
if (ModelRoot == null) return;
Expand All @@ -594,6 +613,8 @@ private void DerivedClassesShouldNotHaveIdentity(ValidationContext context)
}

[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
[UsedImplicitly]
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Called by validation")]
private void SummaryDescriptionIsEmpty(ValidationContext context)
{
if (ModelRoot == null) return;
Expand Down
Loading

0 comments on commit 18e6a00

Please sign in to comment.