Coder Social home page Coder Social logo

t4immutable's People

Contributors

xaviergonz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

t4immutable's Issues

Parent Child Feature

I came across your repo while searching for related topic recently. I created a thread on CoreFx asking about developing your own immutable class APIs, but with also a parent/child relationship. Meaning, I could have an object with children and those children could have children, etc.. However, I need the ability to include/update the respective parent (and ancestors) when updating the properties of the child(ren).

Here is the CoreFx issue: https://github.com/dotnet/corefx/issues/18357

Any help/examples is appreciated.

Inconsistent builder accessibility

With the following declaration:

    [ImmutableClass(Options = ImmutableClassOptions.IncludeOperatorEquals | ImmutableClassOptions.ExcludeToString | ImmutableClassOptions.ExcludeWith, ConstructorAccessLevel = ConstructorAccessLevel.Internal, BuilderAccessLevel = BuilderAccessLevel.Internal)]
    public sealed partial class IndicativeIndexRollover {

We get the following issue. The ToBuilder method accessibility needs to match the builder class accessibility.

image

Is this repo still being maintained?

@xaviergonz Hi, I've just taken over a project which uses this Nuget package extensively and have been experimenting/learning what it's for. I notice you haven't updated the repo for a long time. I have some issues, but not sure it's worth creating them here unless you expect to do any work on it to support VS2022, .NET 5,6,7 etc.

.NETStandard 1.3 issue

Hello,

I'm interested in this class and was trying to use it in a PCL .netStandard 1.3 and it fails to install. Can you support .NETStandard?

Cannot reference packages that use T4Immutable

I created a netstandard 2.0 library that used T4Immutable, and packaged that as a nuget package.
Then, I created a new solution with projects that referenced my nuget package.
It resulted in the following:

  1. The new projects had a link to T4Immutable.tt when they shouldn't.
  2. The new projects would not build:

image

Support for Nullable Properties?

Hi,

Awesome library by the way. It's reminiscent of Google's AutoValue.

How could we go about adding support for nullable properties? Right now, using the Builder class requires non-null properties, but the regular constructor supports nullables. Ideally we'd add an attribute for [Nullable], which then affects the Builder code emitted at https://github.com/xaviergonz/T4Immutable/blob/master/src/content/T4Immutable/T4Immutable.tt#L421. It looks like everything else (Helpers and OptParam) already support nulls.

I can work on the PR, just wanted to make sure you agree with the approach.

Michael

Improvement idea - GetHashCode inside Equals

Hi,
I have to say it is great idea that you have created this T4, it is very helpful and saved me lot of code to write. :)

What I found is, that you can improve a performance in Equals method by adding in generated method ImmutableEquals by adding this.GetHashCode().Equals(obj.GetHashCode()) as first code in return statement, before T4Immutable.Helpers.AreEqual for each property.

Because by Microsoft specification,:
https://msdn.microsoft.com/en-us/library/system.object.gethashcode(v=vs.110).aspx

A hash function must have the following properties:
If two objects compare as equal, the GetHashCode method for each object must return the same value. However, if two objects do not compare as equal, the GetHashCode methods for the two objects do not have to return different values.

You will be sure, that these two object are same and also it is faster to compare two integers first, and than all properties

What do you think?

Thanks
Frankie

T4Immutable content folder won't get copied for new-style (project.json based) projects

Applicable to new-style (.NET Core, .NET Standard, UWP, Portable Class Libraries...) but not to old-style (.NET Framework) projects

Since AFAIK right now NuGet does not support copying files to the project itself you will need to follow the next steps:

  1. Install the T4Immutable nuget package
  2. Create a folder in the root of your project named "T4Immutable"
  3. Download the T4Immutable sources at https://github.com/xaviergonz/T4Immutable/archive/master.zip
  4. Extract the folder src/content/T4Immutable (inside the ZIP) to the T4Immutable folder of your project

"Build - Transform All T4 Templates" won't work, so you will need to right click the file T4Immutable/T4Immutable.tt and click on "Run custom tool" whenever you want to regenerate your templates.

You will need to do 2 and 3 everytime you update this nuget package.

Does anybody know how to overcome this limitation?

Exclude some properties from the `With` method parameter list

In the case of the class, I'd like the generated With method to create a new object updating Price but not capable of updating 'Id'.
Can we decorate the 'Id' property to prevent it being included in the With method parameter list?

[ImmutableClass]
class StockStatus { 
  [SomeExcludeAttribute]
  public string Id { get; } // Wish to exclude this from the With method
  public decimal Price { get; }
}

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.