Hello, I'm new in DSL tools, as a consequence I'm following this tutorial to know more about it.
Visualization and Modeling SDK (DSL Tools) - Intro Lab made by Alan Cameron Wills. (https://code.msdn.microsoft.com/Visualization-and-Modeling-313535db#content)
I'm using Visual Studio Enterprise 2015
I have a problem with lab 3 (part 3) of this tutorial page 6 and 7.
When execute the experimental instance of VS with ValidateAttributeNameAsValidIdentifier method only or ValidateFinalStateHasNoOutGoingTransitions I don't have any problem. I mean just one of them.
But when I have both methods, as you can see on the code below, when I try to re-open a model I have the following message from visual studio , and I can't open the model I made.
Thank you in advance.
Message
Microsoft Visual Studio
Cannot load '...\Visual Studio 2015\Projects\LanguajeSM\Debugging\Sample.sm'; Unable to cast object of type 'System.Reflection.RuntimeMethodInfo' to type 'System.Reflection.ConstructorInfo'.
namespace Company.LanguajeSM
{
[ValidationState(ValidationState.Enabled)]
public partial class State
{
///// <summary>
///// CSharp code provider to verify identifiers.
///// </summary>
private static CSharpCodeProvider csharp = new CSharpCodeProvider();
///// <summary>
///// Warning method to ensure that the Name of a state is :
///// - not empty
///// - a valid identifier
///// </summary>
[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
private void ValidateAttributeNameAsValidIdentifier(ValidationContext context)
{
// Name is tot empty
if (string.IsNullOrEmpty(this.Name.Trim()))
{
context.LogError(CustomCode.Validation.ValidationResources.EmptyStateNameError,"StateMachine – State - 01", this); // Name is a valid C# identifier
}
else if (!csharp.IsValidIdentifier(Name))
{
string error = string.Format(System.Globalization.CultureInfo.CurrentUICulture, CustomCode.Validation.ValidationResources.InvalidStateIdentifierError, Name);
context.LogError(error, "StateMachines – State - 02", this);
}
}
///// <summary>
///// Validation method to ensure that a final state has no outgoing transitions
///// </summary>
[ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
private void ValidateFinalStateHasNoOutgoingTransitions(ValidationContext context)
{
if ((Kind == StateKind.Final) && (Successors.Count > 0))
{
string error = string.Format(System.Globalization.CultureInfo.CurrentUICulture, CustomCode.Validation.ValidationResources.FinalStateShouldNotHaveOutgoingTransitions, Name);
context.LogError(error, "StateMachines – State - 03", this);
}
}
}
}<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000} </style>