temperlang / temper

3 stars 0 forks source link

Stop generating Date class for C# #68

Closed tjpalmer closed 10 months ago

tjpalmer commented 10 months ago

We're building a std Date class for C#:

temper.out\csharp\std\src\Temporal\Date.cs

It also causes some warnings from the C# compiler:

C:\Users\work2\Documents\projects\snippets\temper.out\csharp\std\src\Temporal\Date.cs(6,22): warning CS0649: Field 'Date.month__35' is never assigned to, a
nd will always have its default value 0 [C:\Users\work2\Documents\projects\snippets\temper.out\csharp\std\src\TemperLang.Std.csproj]
C:\Users\work2\Documents\projects\snippets\temper.out\csharp\std\src\Temporal\Date.cs(7,22): warning CS0649: Field 'Date.day__36' is never assigned to, and
 will always have its default value 0 [C:\Users\work2\Documents\projects\snippets\temper.out\csharp\std\src\TemperLang.Std.csproj]
C:\Users\work2\Documents\projects\snippets\temper.out\csharp\std\src\Temporal\Date.cs(5,22): warning CS0649: Field 'Date.year__34' is never assigned to, an
d will always have its default value 0 [C:\Users\work2\Documents\projects\snippets\temper.out\csharp\std\src\TemperLang.Std.csproj]

But I don't see the class generated for other backends, so there's probably some way to avoid it.

tjpalmer commented 10 months ago

In TmpLTranslator, the Date type definition has all these in be-csharp:

_members = {ArrayList@6631}  size = 6
 0 = {TmpL$InstanceProperty@6638} @docString(["The year.  1900 means 1900.", "The year.  1900 means 1900.", "std//temporal.temper.md"]) let year__34: Int;
 1 = {TmpL$InstanceProperty@6639} @docString(["The month of the year in [1, 12].", "The month of the year in [1, 12].", "std//temporal.temper.md"]) let month__35: Int;
 2 = {TmpL$InstanceProperty@6640} @docString(["The day of the month in [1, 31]\nadditionally constrained by the length of [month].", "The day of the month in [1, 31]\nadditionally constrained by the length of [month].", "std//temporal.temper.md"]) let day__36: Int;
 3 = {TmpL$Getter@6641} get.year -> getyear__53(this = this__54, this__54: System.DateTime): Int {return /* this */ this__54.year__34;}
 4 = {TmpL$Getter@6642} get.month -> getmonth__57(this = this__58, this__58: System.DateTime): Int {return /* this */ this__58.month__35;}
 5 = {TmpL$Getter@6643} get.day -> getday__61(this = this__62, this__62: System.DateTime): Int {return /* this */ this__62.day__36;}

But it only has the instance properties in be-py.

I have no idea yet why it would be different between the two.

tjpalmer commented 10 months ago

I think it's because I don't connect the getters. And I don't because default rendering is fine for C#. But then it's confusing the part that figures out if the definitions of those getters is needed. I guess I'll connect them to simple member getters after all.

tjpalmer commented 10 months ago

Completed in a recent PR.