Skip to main content

CopyTo by Paul Braetz

Nuget / site data

Nuget GitHub last commit GitHub Repo stars

Details

Info

info

Name: CopyTo

Generate a CopyTo method for copying one instances property values to another.

Author: Paul Braetz

NuGet: https://www.nuget.org/packages/RhoMicro.CodeAnalysis.CopyToGenerator

You can find more details at https://github.com/PaulBraetz/RhoMicro.CodeAnalysis

Source : https://github.com/PaulBraetz/RhoMicro.CodeAnalysis

Original Readme

note

Rhomicro.CodeAnalysis

Build

This repository contains my explorations on c# source code generation and analysis.

The [UnionsGenerator](https://github.com/PaulBraetz/RhoMicro.CodeAnalysis/UnionsGenerator generator enables the use of union types in C#.

The [UtilityGenerators](https://github.com/PaulBraetz/RhoMicro.CodeAnalysis/UtilityGenerators generator helps you write code generators and analyzers.

The [CopyTo](https://github.com/PaulBraetz/RhoMicro.CodeAnalysis/CopyTo generator generates methods to copy the contents of one instance to another. I created this generator for a friend, so it is not as feature rich as it could be.

About

note

Generating copy to code for properties of a class

How to use

Example ( source csproj, source files )

This is the CSharp Project that references CopyTo

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="RhoMicro.CodeAnalysis.CopyToGenerator" Version="14.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>

Generated Files

Those are taken from $(BaseIntermediateOutputPath)\GX

namespace RhoMicro.CodeAnalysis;

using System;

[global::System.AttributeUsage(AttributeTargets.Class)]
#if GENERATOR
[RhoMicro.CodeAnalysis.GenerateFactory]
#endif
internal sealed partial class GenerateCopyToAttribute : global::System.Attribute { }

Usefull

Download Example (.NET C# )

Share CopyTo

https://ignatandrei.github.io/RSCG_Examples/v2/docs/CopyTo

In the same category (EnhancementClass) - 24 other generators

ApparatusAOT

AspectGenerator

CommonCodeGenerator

DudNet

FastGenericNew

GeneratorEquals

HsuSgSync

Immutype

Ling.Audit

Lombok.NET

M31.FluentAPI

MemoryPack

Meziantou.Polyfill

Microsoft.Extensions.Logging

Microsoft.Extensions.Options.Generators.OptionsValidatorGenerator

Microsoft.Interop.JavaScript.JSImportGenerator

OptionToStringGenerator

RSCG_Decorator

RSCG_UtilityTypes

StaticReflection

SyncMethodGenerator

System.Runtime.InteropServices

System.Text.RegularExpressions

TelemetryLogging