Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace T4 with raw string literale #29

Merged
merged 7 commits into from
Aug 10, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
// </auto-generated>
#pragma warning disable CS8669
using System;

namespace FileGenerate
{
[System.ComponentModel.TypeConverter(typeof(ATypeConverter))]
public readonly partial struct A : IEquatable<A>
readonly partial struct A : IEquatable<A>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public?

Copy link
Contributor Author

@hadashiA hadashiA Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The master branch seems to omit public modifier as well.
https://github.com/Cysharp/UnitGenerator/blob/master/src/UnitGenerator/CodeTemplate.tt#L34

Probably, since it is partial, the handwritten code will be followed ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, omit modifier is ok.

{
readonly int value;

Expand All @@ -17,8 +16,7 @@ public A(int value)
{
this.value = value;
}



public static explicit operator int(A value)
{
return value.value;
Expand Down Expand Up @@ -47,7 +45,7 @@ public override bool Equals(object obj)
return value.Equals((int)obj);
}

return value.Equals(obj);
return value.Equals(obj);
}

public override int GetHashCode()
Expand All @@ -57,7 +55,7 @@ public override int GetHashCode()

public override string ToString()
{
return "A(" + value + ")";
return value.ToString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

different ToString result?(I don't know which is better)

Copy link
Contributor Author

@hadashiA hadashiA Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I generate again with master branch, I seem to get a diff of this file.

It looks like value.ToString() is probably the implementation currently in use. Is this correct?
https://github.com/Cysharp/UnitGenerator/blob/master/src/UnitGenerator/CodeTemplate.tt#L88

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall changing it to a straightforward ToString because having type information made it harder to read, and it also reduced the convenience of ToString.

So, this implementation is OK!

}

public static bool operator ==(in A x, in A y)
Expand All @@ -70,15 +68,6 @@ public override string ToString()
return !x.value.Equals(y.value);
}










// Default
private class ATypeConverter : System.ComponentModel.TypeConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
// </auto-generated>
#pragma warning disable CS8669
using System;

namespace FileGenerate
{
[System.ComponentModel.TypeConverter(typeof(BTypeConverter))]
public readonly partial struct B : IEquatable<B>
readonly partial struct B : IEquatable<B>
{
readonly string value;

Expand All @@ -17,8 +16,7 @@ public B(string value)
{
this.value = value;
}



public static explicit operator string(B value)
{
return value.value;
Expand Down Expand Up @@ -57,7 +55,7 @@ public override int GetHashCode()

public override string ToString()
{
return "B(" + value + ")";
return value.ToString();
}

public static bool operator ==(in B x, in B y)
Expand All @@ -70,15 +68,6 @@ public override string ToString()
return !x.value.Equals(y.value);
}










// Default
private class BTypeConverter : System.ComponentModel.TypeConverter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated>
// <auto-generated>
// THIS (.cs) FILE IS GENERATED BY UnitGenerator. DO NOT CHANGE IT.
// </auto-generated>
#pragma warning disable CS8669
Expand Down Expand Up @@ -37,5 +37,7 @@ internal enum UnitGenerateOptions
MessagePackFormatter = 256,
DapperTypeHandler = 512,
EntityFrameworkValueConverter = 1024,
WithoutComparisonOperator = 2048,
JsonConverterDictionaryKeySupport = 4096
}
}
884 changes: 0 additions & 884 deletions src/UnitGenerator/CodeTemplate.cs

This file was deleted.

Loading