Code Generation
Attributes that control what gets generated — DTOs, services, mappers, and source generator output.
SpiderlyEntity
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Required on every hand-written entity class. Without [SpiderlyEntity], the source generators ignore the class and emit no DTO, mapper, controller, validator, or Angular form for it. The spiderly add-new-entity CLI adds this attribute automatically.
Example:
[SpiderlyEntity]
public class Product : BusinessObject<long>
{
[Required]
[StringLength(100, MinimumLength = 1)]
public string Name { get; set; }
}SpiderlyDTO
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Required on every hand-written DTO class that the generator should pass through to the Angular client. Generated DTOs ({Entity}DTO, {Entity}SaveBodyDTO, {Entity}MainUIFormDTO) are emitted by Spiderly directly and need no marker — apply this attribute only to DTOs you write by hand.
Example:
[SpiderlyDTO]
public class GenerateApiKeyResponseDTO
{
[Required]
[StringLength(64)]
public string ApiKey { get; set; }
}SpiderlyController
Namespace: Spiderly.Shared.Attributes
Usage:
Required on every hand-written controller. Without [SpiderlyController], the source generators ignore the class and skip any routing/permission wiring that depends on it.
Example:
[SpiderlyController]
[ApiController]
[Route("/api/[controller]/[action]")]
public class ProductController : ProductBaseController
{
// Custom endpoints and overrides
}SpiderlyService
Namespace: Spiderly.Shared.Attributes
Usage:
Required on every hand-written entity service override (and on AuthorizationService). The source generator enrolls these classes in DI registration and forwards resolves of {Entity}ServiceGenerated to your override. Without the marker, the override is invisible to the generator and only the generated base is registered.
Example:
[SpiderlyService]
public class ProductService : ProductServiceGenerated
{
public ProductService(EntityServiceDependencies deps) : base(deps) { }
protected override async Task OnBeforeProductInsert(Product product, ProductDTO productDTO)
{
// Custom logic
}
}SpiderlyEnum
Namespace: Spiderly.Shared.Attributes
Usage:
Required on every C# enum or class-based enum that should be emitted into enums.generated.ts for the Angular client. Classes/enums without this marker stay backend-only — that is the correct default for enums that carry no frontend value.
Applies to both:
public enum {Name}Codes— generated as a numeric TypeScript enumpublic static partial class {Name}Codeswith string constants — generated as a string TypeScript enum
Example:
[SpiderlyEnum]
public enum OrderStatusCodes
{
PendingPayment = 1,
Pending = 2,
Shipped = 3,
Delivered = 4,
Cancelled = 5,
}BlobName
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Marks a string property as a reference to a file stored in Azure Blob Storage. This property will contain the unique identifier (blob name) used to locate and access the file in Azure Storage.
When you add a property decorated with the BlobName inside your entity, Spiderly will automatically generate an additional property in the corresponding DTO (e.g., ProfilePictureData). This new property will contain the Base64-encoded string of the file. To display this image in your HTML, use the Spiderly helper method getHtmlImgDisplayString64 and pass its result as the src attribute of an <img> tag.
Example:
public class User : BusinessObject<long>
{
[BlobName]
[StringLength(80, MinimumLength = 30)] // GUID length
public string ProfilePicture { get; set; }
}IncludeInDTO
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Specifies that a property should be included in the generated DTO. This attribute is particularly useful for enumerable properties, which are not included in DTOs by default.
Note:
This attribute only affects DTO generation and does not influence the mapping behavior (Entity ↔ DTO).
ExcludeFromDTO
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Specifies that a property should be excluded from the generated DTO.
ExcludeServiceMethodsFromGeneration
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Prevents the generation of standard business service methods for the decorated property in the generated entity service class.
Use this attribute when you want to:
- Implement custom business logic instead of using generated methods
- Override the default generated behavior with your own implementation
- Exclude specific properties from the standard service method generation
Note:
The property will still be part of the entity, but no service methods will be generated for it in the generated entity service class.
GenerateCommaSeparatedDisplayName
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Generates a string property in the DTO containing comma-separated display names for a collection property in the entity.
Example:
public class Project : BusinessObject<long>
{
[DisplayName]
public string Name { get; set; }
[GenerateCommaSeparatedDisplayName]
public virtual List<User> TeamMembers { get; set; } = new();
}
public class User : BusinessObject<long>
{
[DisplayName]
public string Email { get; set; }
}
// In the UI table, the TeamMembers column will show:
// "john@example.com, jane@example.com, bob@example.com"ProjectToDTO
Namespace: Spiderly.Shared.Attributes.Entity
Usage:
Specifies custom mapping configuration when projecting an entity to its DTO.
Example:
[ProjectToDTO(".Map(dest => dest.TransactionPrice, src => src.Transaction.Price)")]
public class Achievement : BusinessObject<long>
{
// Properties
}SpiderlyDataMapper
Namespace: Spiderly.Shared.Attributes
Usage:
Marks a class for custom object mapping implementation.
Example:
[SpiderlyDataMapper]
public static partial class Mapper
{
// Custom mapping methods
}Note:
Use this attribute when you need to implement specialized mapping logic that cannot be handled by the default mapping configuration.
Output
Namespace: Spiderly.Shared.Attributes
Usage:
Specifies the output configuration for the Source Generator.
Note:
This is a temporary solution and may be replaced in future versions.