Giter VIP home page Giter VIP logo

altv.community.mvalueadapters.generators's Introduction

AltV.Community.MValueAdapters.Generators

NuGet badge

Quickstart

Installation

  1. Add the NuGet package to your project.
dotnet add package AltV.Community.MValueAdapters.Generators
  1. In case there are CS0436 warnings during compilation, you must add these attributes to your <PackageReference>.
<PackageReference Include="AltV.Community.MValueAdapters.Generators" PrivateAssets="all" ExcludeAssets="runtime" />

Note: If you use a shared project between client and server, only add the NuGet to the shared project and neither to the client nor server project to avoid ambigious references.

Generate your first MValue adapter

  1. Add MValueAdapter attribute to your class.
using AltV.Community.MValueAdapters.Generators;

[MValueAdapter]
public class ParentDto
{
    public string First { get; set; } = string.Empty;
    public string Second { get; set; } = string.Empty;
    public ChildDto Dto { get; set; } = null!;
}

[MValueAdapter]
public class ChildDto
{
    public string First { get; set; } = string.Empty;
    public string Second { get; set; } = string.Empty;
}
  1. Register the MValue adapters generated when the resource (client / server) starts.
public override void OnStart()
{
    AltExtensions.RegisterAdapters();
}

Huge thanks to deluvas1911 for sharing his great work and allowing me to open source this.

How To Contribute

If you'd like to contribute, some adjustments need to be made to the project setup.

  1. Fork the project, clone and build it dotnet build.
  2. Remove any existing <PackageReference> to this project from your Server/Client project.
  3. Add the following lines to an <ItemGroup> and replace the Include= value with the relative paths:
<ProjectReference Include="..\AltV.Community.MValueAdapters.Generators\AltV.Community.MValueAdapters.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="all" />
<ProjectReference Include="..\AltV.Community.MValueAdapters.Generators.Abstractions\AltV.Community.MValueAdapters.Generators.Abstractions.csproj" OutputItemType="Analyzer" />
  1. Add the following line to an <ItemGroup> in your Server/Client project to view generated files:
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
  1. In your Server/Client project, run dotnet clean before building, to ensure cache is cleared.

altv.community.mvalueadapters.generators's People

Contributors

deluvas1911 avatar duydang2311 avatar riffy avatar xluxy avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xluxy riffy

altv.community.mvalueadapters.generators's Issues

Roadmap for v0.2.0

Task list

  • Add support for Guid, DateTime, DateTimeOffset types.
  • Add support for mutable record and struct types.
  • Remove deprecated AltExtensions.RegisterAdapters.
  • Add MValueIgnoreAttribute.
  • Add enum support (#9).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.