Base solution for your next web application
Open Closed

Auto Generate code created code with errors #5425


User avatar
0
kumaran created

I tried to create an "Event" entity and i got code generated with lots of errors in EventAppService.cs Eg:

Severity Code Description Project File Line Suppression State Error CS0161 'EventsAppService.GetEventForEdit(NullableIdDto<long>)': not all code paths return a value Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 69 Active Error CS0103 The name 'var' does not exist in the current context Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 71 Active Error IDE1007 The name 'input.Id' does not exist in the current context. Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 71 Active Error IDE1007 The name 'input' does not exist in the current context. Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 71 Active Error IDE1007 The name 'Id' does not exist in the current context. Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 71 Active Error CS0236 A field initializer cannot reference the non-static field, method, or property 'AbpServiceBase.ObjectMapper' Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 73 Active Error CS7036 There is no argument given that corresponds to the required formal parameter 'source' of 'IObjectMapper.Map<TDestination>(object)' Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 73 Active Error IDE1007 The name 'output' does not exist in the current context. Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 75 Active Error CS0103 The name 'Create' does not exist in the current context Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 81 Active Error CS0103 The name 'Update' does not exist in the current context Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 84 Active Error CS0103 The name 'var' does not exist in the current context Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 91 Active Error CS0103 The name 'ObjectMapper' does not exist in the current context Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 91 Active Error CS0103 The name '_eventRepository' does not exist in the current context Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 95 Active Error CS0103 The name 'var' does not exist in the current context Events.Application C:\Kumaran\AspnetZero\Events\aspnet-core\src\Events.Application\Event\EventsAppService.cs 101 Active


2 Answer(s)
  • User Avatar
    0
    yekalkan created

    Hi @kumaran,

    "event" is a keyword in c#. <a class="postlink" href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/">https://docs.microsoft.com/en-us/dotnet ... /keywords/</a>

    Generator uses camelCase variables in app service but any variable named "event" is not allowed in c#. This is the cause of the errors. You can rename those variables one by one for now.

  • User Avatar
    0
    kumaran created

    Yes you are right. Changing the entity name worked.