Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error generating DTO #14

Open
msawczyn opened this issue Jan 9, 2018 · 2 comments
Open

Error generating DTO #14

msawczyn opened this issue Jan 9, 2018 · 2 comments

Comments

@msawczyn
Copy link

msawczyn commented Jan 9, 2018

An error message popped up while generating a DTO, giving me this site address and asking for details. So here ya go.

Message box said:

---------------------------
Microsoft Visual Studio
---------------------------
An exception has occurred. Please c/p stack trace to project website (https://github.com/yohney/dto-generator), with brief description of the problem.

Source code to parse must contain exactly one class declaration!
---------------------------
OK   
---------------------------

Unfortunately, the source code did contain exactly one class declaration.

Source class file was:


//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;

namespace BER.MenuHub.Data
{
   public partial class MenuItemDataChange : IHasIdentity<System.Guid>
   {
      partial void Init();

      /// <summary>
      /// Default constructor. Protected due to required properties, but present because EF needs it.
      /// </summary>
      protected MenuItemDataChange()
      {
         IsDone = false;

         Init();
      }

      /// <summary>
      /// Public constructor with required data
      /// </summary>
      /// <param name="_propertyname"></param>
      /// <param name="_responsibledepartment"></param>
      /// <param name="_isdone"></param>
      /// <param name="_menuitem"></param>
      /// <param name="_changeset"></param>
      public MenuItemDataChange(string _propertyname, string _responsibledepartment, MenuItem _menuitem, MenuItemChangeSet _changeset, bool _isdone = false)
      {
         if (string.IsNullOrEmpty(_propertyname)) throw new ArgumentNullException(nameof(_propertyname));
         PropertyName = _propertyname;
         if (string.IsNullOrEmpty(_responsibledepartment)) throw new ArgumentNullException(nameof(_responsibledepartment));
         ResponsibleDepartment = _responsibledepartment;
         IsDone = _isdone;
         if (_menuitem == null) throw new ArgumentNullException(nameof(_menuitem));
         MenuItem = _menuitem;

         if (_changeset == null) throw new ArgumentNullException(nameof(_changeset));
         ChangeSet = _changeset;

         Init();
      }

      /// <summary>
      /// Static create function (for use in LINQ queries, etc.)
      /// </summary>
      /// <param name="_propertyname"></param>
      /// <param name="_responsibledepartment"></param>
      /// <param name="_isdone"></param>
      /// <param name="_menuitem"></param>
      /// <param name="_changeset"></param>
      public static MenuItemDataChange Create(string _propertyname, string _responsibledepartment, MenuItem _menuitem, MenuItemChangeSet _changeset, bool _isdone = false)
      {
         return new MenuItemDataChange(_propertyname, _responsibledepartment, _menuitem, _changeset, _isdone);
      }

      // Persistent properties

      /// <summary>
      /// Identity, Required, Indexed
      /// </summary>
      public Guid Id { get; set; }

      /// <summary>
      /// Required, Max length = 50
      /// </summary>
      public string PropertyName { get; set; }

      /// <summary>
      /// Max length = 200
      /// </summary>
      public string LastUpdatedBy { get; set; }

      public DateTime? LastUpdatedDate { get; set; }

      /// <summary>
      /// Required, Max length = 50
      /// </summary>
      public string ResponsibleDepartment { get; set; }

      /// <summary>
      /// Max length = 4000
      /// </summary>
      public string Comments { get; set; }

      /// <summary>
      /// Required, Default value = false
      /// </summary>
      public bool IsDone { get; set; }

      // Persistent navigation properties

      public virtual MenuItem MenuItem { get; set; }  // Required
      public virtual MenuItemChangeSet ChangeSet { get; set; }  // Required
   }
}

Stack trace was:


   at DtoGenerator.Logic.Infrastructure.EntityParser.FromSyntaxTree(SyntaxTree syntaxTree)
   at DtoGenerator.Logic.Infrastructure.EntityParser.<FromDocument>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DtoGenerator.Logic.UI.EntityViewModel.<CreateRecursive>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at DtoGenerator.Logic.UI.EntityViewModel.<CreateRecursive>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DtoGenerator.Logic.UI.PropertySelectorViewModel.<Create>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at DtoGenerator.Vsix.GenerateDtoCommand.<MenuItemCallback>d__13.MoveNext() in F:\git\dto-generator\src\DtoGenerator\DtoGenerator.Vsix\GenerateDtoCommand.cs:line 235
----------------------------

Hope this helps track down the problem. BTW, it's not uncommon for me to get errors while generating DTOs with this tool, but it does remove enough of the drudgery that I haven't given up on it :-)

Thanks for your hard work.

@msawczyn
Copy link
Author

Had another one, but with a shorter stack trace. For the record, these were both v1.8.1. Same error message.

Stack trace is:

   at DtoGenerator.Logic.Infrastructure.EntityParser.FromSyntaxTree(SyntaxTree syntaxTree)
   at DtoGenerator.Logic.Infrastructure.EntityParser.<FromDocument>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DtoGenerator.Logic.UI.EntityViewModel.<CreateRecursive>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at DtoGenerator.Logic.UI.EntityViewModel.<CreateRecursive>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DtoGenerator.Logic.UI.PropertySelectorViewModel.<Create>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at DtoGenerator.Vsix.GenerateDtoCommand.<MenuItemCallback>d__13.MoveNext() in F:\git\dto-generator\src\DtoGenerator\DtoGenerator.Vsix\GenerateDtoCommand.cs:line 235
----------------------------

Class is:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;

namespace BER.MenuHub.Data
{
   public partial class Recipe : RecipeIngredient, IHasIdentity<System.Guid>
   {
      partial void Init();

      /// <summary>
      /// Default constructor. Protected due to required properties, but present because EF needs it.
      /// </summary>
      protected Recipe(): base()
      {
         Status = "DRAFT";
         ServingCosts = new System.Collections.Generic.HashSet<ServingCost>();
         Ingredients = new System.Collections.Generic.HashSet<RecipeItem>();
         ComboOptions = new System.Collections.Generic.HashSet<RecipeIngredient>();

         Init();
      }

      /// <summary>
      /// Public constructor with required data
      /// </summary>
      /// <param name="_status">What the status is for the recipe, whether it's active, draft, in test, in review</param>
      /// <param name="_recipetype">Determines if the recipe is for a prep to menu item </param>
      /// <param name="_name"></param>
      public Recipe(string _recipetype, string _name, string _status = "DRAFT")
      {
         if (string.IsNullOrEmpty(_status)) throw new ArgumentNullException(nameof(_status));
         Status = _status;
         if (string.IsNullOrEmpty(_recipetype)) throw new ArgumentNullException(nameof(_recipetype));
         RecipeType = _recipetype;
         if (string.IsNullOrEmpty(_name)) throw new ArgumentNullException(nameof(_name));
         Name = _name;
         ServingCosts = new HashSet<ServingCost>();
         Ingredients = new HashSet<RecipeItem>();
         ComboOptions = new HashSet<RecipeIngredient>();
         Init();
      }

      /// <summary>
      /// Static create function (for use in LINQ queries, etc.)
      /// </summary>
      /// <param name="_status">What the status is for the recipe, whether it's active, draft, in test, in review</param>
      /// <param name="_recipetype">Determines if the recipe is for a prep to menu item </param>
      /// <param name="_name"></param>
      public static Recipe Create(string _recipetype, string _name, string _status = "DRAFT")
      {
         return new Recipe(_recipetype, _name, _status);
      }

      // Persistent properties

      /// <summary>
      /// Indexed
      /// Number to be assigned to the recipe
      /// </summary>
      public int? RecipeNumber { get; set; }

      /// <summary>
      /// Max length = 200
      /// Description of the recipe 
      /// </summary>
      public string Description { get; set; }

      /// <summary>
      /// Required, Max length = 10, Default value = "DRAFT"
      /// What the status is for the recipe, whether it's active, draft, in test, in review
      /// </summary>
      public string Status { get; set; }

      /// <summary>
      /// Max length = 100
      /// PROBABLY DELETE
      /// </summary>
      public string ServingType { get; set; }

      /// <summary>
      /// How much of a unit is in the recipe
      /// </summary>
      public double? ServingSize { get; set; }

      /// <summary>
      /// Max length = 50
      /// Which unit is in the recipe
      /// </summary>
      public string ServingSizeUnit { get; set; }

      /// <summary>
      /// Max length = 2000
      /// Notes for the recipe
      /// </summary>
      public string Notes { get; set; }

      /// <summary>
      /// Max length = 50
      /// TO BE DETERMINED 
      /// </summary>
      public string PrepType { get; set; }

      /// <summary>
      /// Max length = 50
      /// </summary>
      public string MakeAs { get; set; }

      /// <summary>
      /// Theoretical value of FIFO 
      /// </summary>
      public bool? UseTheoUsage { get; set; }

      /// <summary>
      /// Max length = 2000
      /// Describes the yield amount left 
      /// </summary>
      public string YieldDescription { get; set; }

      /// <summary>
      /// Max length = 100
      /// How long it's good on the shelf 
      /// </summary>
      public string ShelfLife { get; set; }

      /// <summary>
      /// Max length = 50
      /// Amount of percentage to count as overhead for calculations 
      /// </summary>
      public string CushionPercentage { get; set; }

      /// <summary>
      /// Max length = 50
      /// How long to thaw the recipe 
      /// </summary>
      public string ThawTimeHours { get; set; }

      public bool? RoastAdjust { get; set; }

      /// <summary>
      /// Max length = 50
      /// If the recipe is active or not
      /// </summary>
      public string ActiveStatus { get; set; }

      /// <summary>
      /// Max length = 100
      /// What order the ingredients are in **
      /// </summary>
      public string WorksheetOrder { get; set; }

      /// <summary>
      /// Max length = 100
      /// Additional time into making the recipe
      /// </summary>
      public string AdditionalMakeTime { get; set; }

      /// <summary>
      /// Max length = 100
      /// Additional time for cleaning 
      /// </summary>
      public string CleanupTime { get; set; }

      /// <summary>
      /// Max length = 100
      /// Additional time that is uncounted for elsewhere 
      /// </summary>
      public string AdditionalTimeMeasure { get; set; }

      public bool? OpenPrepItem { get; set; }

      /// <summary>
      /// Max length = 100
      /// PROBABLY DELETE 
      /// </summary>
      public string CalculateUsageAgainst { get; set; }

      /// <summary>
      /// Max length = 2000
      /// Comments the admin can submit upon approving
      /// </summary>
      public string ApprovalComments { get; set; }

      /// <summary>
      /// Required, Max length = 10
      /// Determines if the recipe is for a prep to menu item 
      /// </summary>
      public string RecipeType { get; set; }

      /// <summary>
      /// Max length = 2000
      /// </summary>
      public string NutritionInfo { get; set; }

      /// <summary>
      /// Max length = 200
      /// Who edited Recipe last 
      /// </summary>
      public string LastUpdatedBy { get; set; }

      /// <summary>
      /// When Recipe was last edited
      /// </summary>
      public DateTime? LastUpdatedDate { get; set; }

      // Persistent navigation properties

      public virtual ICollection<ServingCost> ServingCosts { get; set; } 
      public virtual ICollection<RecipeItem> Ingredients { get; set; } 
      public virtual ICollection<RecipeIngredient> ComboOptions { get; set; } 
      public virtual MenuItem MenuItem { get; set; } 
   }
}


@mikethibault
Copy link

I am having this exact same issue. Same error, yet I also only have one class declaration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants