Skip to content

Commit

Permalink
Merge pull request #8 from Cysharp/fix_ulid
Browse files Browse the repository at this point in the history
Fix generate new ulid
  • Loading branch information
neuecc authored Feb 7, 2022
2 parents c8c72dd + 2a8457d commit 69f0e96
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions sandbox/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


Console.WriteLine(new Sample.Hp(100).ToString());
Console.WriteLine(BarId.New());

[UnitOf(typeof(int))]
public readonly partial struct NoNamespace
Expand Down
4 changes: 2 additions & 2 deletions src/UnitGenerator/CodeTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ public virtual string TransformText()
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write(" New()\r\n {\r\n return new ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write("(Ulid.NewGuid());\r\n }\r\n\r\n public static ");
this.Write("(Ulid.NewUlid());\r\n }\r\n\r\n public static ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write(" New");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write("()\r\n {\r\n return new ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write("(Ulid.NewGuid());\r\n }\r\n\r\n");
this.Write("(Ulid.NewUlid());\r\n }\r\n\r\n");
}
this.Write("\r\n");
if (HasFlag(UnitGenerateOptions.ParseMethod)) {
Expand Down
4 changes: 2 additions & 2 deletions src/UnitGenerator/CodeTemplate.tt
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ namespace <#= Namespace #>
<# if (Type == "Ulid" || Type == "System.Ulid") { #>
public static <#= Name #> New()
{
return new <#= Name #>(Ulid.NewGuid());
return new <#= Name #>(Ulid.NewUlid());
}

public static <#= Name #> New<#= Name #>()
{
return new <#= Name #>(Ulid.NewGuid());
return new <#= Name #>(Ulid.NewUlid());
}

<# } #>
Expand Down

0 comments on commit 69f0e96

Please sign in to comment.