Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
/.idea
/.idea
/.vs
19 changes: 14 additions & 5 deletions DtoGenerator.sln
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DtoGenerator", "DtoGenerator\DtoGenerator.csproj", "{96A4BF52-6343-45BA-AF3C-F0EA58E7561B}"
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DtoGenerator", "DtoGenerator\DtoGenerator.csproj", "{B78BCDF2-CE7D-4360-9349-04EBB73E08E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{96A4BF52-6343-45BA-AF3C-F0EA58E7561B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96A4BF52-6343-45BA-AF3C-F0EA58E7561B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96A4BF52-6343-45BA-AF3C-F0EA58E7561B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96A4BF52-6343-45BA-AF3C-F0EA58E7561B}.Release|Any CPU.Build.0 = Release|Any CPU
{B78BCDF2-CE7D-4360-9349-04EBB73E08E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B78BCDF2-CE7D-4360-9349-04EBB73E08E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B78BCDF2-CE7D-4360-9349-04EBB73E08E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B78BCDF2-CE7D-4360-9349-04EBB73E08E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ED6BF01A-C084-43DC-924F-958623C2252A}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions DtoGenerator/Attributes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SourceGenerator;
namespace TenJames.DtoGenerator;

using System;

Expand All @@ -7,7 +7,7 @@
/// </summary>
/// <param name="dtoType">Targets of Dto</param>
[AttributeUsage(AttributeTargets.Class)]
public class GenerateDtoAttribute(DtoType dtoType) : Attribute { }

Check warning on line 10 in DtoGenerator/Attributes.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Parameter 'dtoType' is unread.

/// <summary>
/// Attribute to ignore a property in the generated DTO.
Expand All @@ -21,7 +21,7 @@
/// <param name="type">The target type to map to.</param>
/// <param name="mapExpression">The mapping expression. having base object as src</param>
[AttributeUsage(AttributeTargets.Property)]
public class MapToAttribute(Type type, string mapExpression) : Attribute { }

Check warning on line 24 in DtoGenerator/Attributes.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Parameter 'type' is unread.

Check warning on line 24 in DtoGenerator/Attributes.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Parameter 'mapExpression' is unread.

/// <summary>
/// Attribute to map a property from a specified type and expression.
Expand All @@ -29,14 +29,14 @@
/// <param name="type">The source type to map from.</param>
/// <param name="mapExpression">The mapping expression. having base object as src</param>
[AttributeUsage(AttributeTargets.Property)]
public class MapFromAttribute(Type type, string mapExpression) : Attribute { }

Check warning on line 32 in DtoGenerator/Attributes.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Parameter 'type' is unread.

Check warning on line 32 in DtoGenerator/Attributes.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Parameter 'mapExpression' is unread.

/// <summary>
/// Determines the visibility of a property in a DTO.
/// </summary>
/// <param name="dtoType"></param>
[AttributeUsage(AttributeTargets.Property)]
public class DtoVisibilityAttribute(DtoType dtoType) : Attribute { }

Check warning on line 39 in DtoGenerator/Attributes.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Parameter 'dtoType' is unread.

/// <summary>
/// Enumeration of DTO types.
Expand Down Expand Up @@ -73,4 +73,4 @@
/// DTO for all operations.
/// </summary>
All = Create | Read | Update | ReadDetail
}
}
4 changes: 2 additions & 2 deletions DtoGenerator/DtoGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp;
using System.Linq;
using System.Text;
using SourceGenerator;
using TenJames.DtoGenerator;

[Generator]
public class DtoGenerator : IIncrementalGenerator

Check warning on line 11 in DtoGenerator/DtoGenerator.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'DtoGenerator'
{
public void Initialize(IncrementalGeneratorInitializationContext context)
{
Expand Down
102 changes: 70 additions & 32 deletions DtoGenerator/DtoGenerator.csproj
Original file line number Diff line number Diff line change
@@ -1,37 +1,75 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<Nullable>enable</Nullable>
<Version>0.1.0</Version>
<Title>Dto Generator Library</Title>
<Description>Generate your Dtos and mappers with simple attributes on Enity</Description>
<PackageProjectUrl>https://github.com/Ten-James/DtoGenerator</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ten-James/DtoGenerator</RepositoryUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>Jakub Indrák</Authors>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseUrl>https://github.com/Ten-James/DtoGenerator/blob/master/LICENSE.md</PackageLicenseUrl>
<PackageId>TenJames.DtoGenerator</PackageId>
<Copyright>MIT</Copyright>
<PackageTags>Generator DTO WebApi </PackageTags>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>bin\Release\DtoGenerator.xml</DocumentationFile>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<Nullable>enable</Nullable>
<IncludeBuildOutput>true</IncludeBuildOutput>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RootNamespace>TenJames.DtoGenerator</RootNamespace>
</PropertyGroup>

<PropertyGroup>
<Version>0.1.6</Version>
<Title>Dto Generator Library</Title>
<Description>Generate your Dtos and mappers with simple attributes on Enity</Description>
<PackageProjectUrl>https://github.com/Ten-James/DtoGenerator</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ten-James/DtoGenerator</RepositoryUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>Jakub Indrák</Authors>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseUrl>https://github.com/Ten-James/DtoGenerator/blob/master/LICENSE.md</PackageLicenseUrl>
<PackageId>TenJames.DtoGenerator</PackageId>
<Copyright>MIT</Copyright>
<PackageTags>Generator DTO WebApi </PackageTags>
<!--<DevelopmentDependency>true</DevelopmentDependency> -->
<NoPackageAnalysis>false</NoPackageAnalysis>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>bin\Release\DtoGenerator.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<None Include="..\readme.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<Compile Update="Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
<EmbeddedResource Update="Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
</ItemGroup>


<ItemGroup>
<None Include="..\readme.md" Link="readme.md">
<PackagePath>\</PackagePath>
<Pack>true</Pack>
</None>
</ItemGroup>

<ItemGroup>
<None Update="tools\*.ps1" CopyToOutputDirectory="PreserveNewest" Pack="true" PackagePath="" />
</ItemGroup>

<Target Name="_AddAnalyzersToOutput">
<ItemGroup>
<TfmSpecificPackageFile Include="$(OutputPath)\DtoGenerator.dll" PackagePath="analyzers/dotnet/cs" />
</ItemGroup>
</Target>

<Target Name="_AddAssembliesToOutput">
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<None Include="..\readme.md" Pack="true" PackagePath="\"/>
<TfmSpecificPackageFile Include="$(OutputPath)\DtoGenerator.dll" PackagePath="lib/netstandard2.0/" />
</ItemGroup>
</Target>

</Project>
7 changes: 3 additions & 4 deletions DtoGenerator/ObjectSpecification.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#nullable enable
#nullable enable
using System.Collections.Generic;

namespace SourceGenerator;
namespace TenJames.DtoGenerator;

internal struct ObjectSpecification
{
Expand All @@ -24,6 +23,6 @@

internal class MappingSpecification
{
internal string ToType { get; set; }

Check warning on line 26 in DtoGenerator/ObjectSpecification.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Non-nullable property 'ToType' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
internal string Function { get; set; }

Check warning on line 27 in DtoGenerator/ObjectSpecification.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Non-nullable property 'Function' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
}
7 changes: 3 additions & 4 deletions DtoGenerator/ObjectSpecificationParser.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#nullable enable
#nullable enable
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;

namespace SourceGenerator;
namespace TenJames.DtoGenerator;

internal static class ObjectSpecificationParser
{
Expand Down Expand Up @@ -56,7 +55,7 @@

private static DtoType GetDtoType(INamedTypeSymbol symbol)
{
return (DtoType)symbol.GetAttributes().FirstOrDefault(a => a.AttributeClass?.Name == "GenerateDtoAttribute")

Check warning on line 58 in DtoGenerator/ObjectSpecificationParser.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Dereference of a possibly null reference.
.ConstructorArguments[0].Value!;
}

Expand Down Expand Up @@ -99,4 +98,4 @@
symbol = symbol.BaseType;
}
}
}
}
Loading
Loading