[stringtemplate-interest] Current C# Dev Version

Sam Harwell sharwell at pixelminegames.com
Tue Aug 4 13:31:43 PDT 2009


Awesome,

 

If you saw my last email about the accessors, well, they unintentionally
fixed this. :) I was not trying to do so!

 

Sam

 

From: Dustin A. Lambert [mailto:dustin at biztechetc.com] 
Sent: Tuesday, August 04, 2009 3:12 PM
To: Sam Harwell
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] Current C# Dev Version

 

I tested some different dates to see what $Today.Year$ evaluates to:

8/4/2009: 8434
8/4/2010: 6784
8/4/2011: 5135
1/1/2009: 1398
1/1/2010: 14362
1/1/2011: 12712

I know this sounds crazy... Not sure what else to do.

Interesting that future dates have exactly 1650 difference between
years...

Dustin Lambert



On Tue, Aug 4, 2009 at 3:38 PM, Dustin A. Lambert
<dustin at biztechetc.com> wrote:

I've been trying over and over to get the right results with this
version, but to no avail.

I dumped everything and just created a clean project with the test in
it...

I ran the same test and it always is false... $Today.Year$ is evaluating
to "8434."

For fun, I went back and tried the same test in versions 3.0 and 3.1b1
and it succeeds as expected.

I feel like it is a reflection error, but I am unable to track it
down... Is the source code available?

Thanks,

Dustin Lambert





---------- Forwarded message ----------
From: Sam Harwell <sharwell at pixelminegames.com>
Date: Tue, Aug 4, 2009 at 3:07 PM
Subject: RE: [stringtemplate-interest] Current C# Dev Version
To: "Dustin A. Lambert" <dustin at biztechetc.com>
Cc: stringtemplate-interest at antlr.org



Hi Dustin,

 

I added a unit test to the StringTemplate test suite and it passes
without any changes:

 

[TestMethod]

public void TestDateTimeFormatting()

{

    StringTemplate e = new StringTemplate(

            "<p>&copy; 2008- $Today.Year$ . All rights reserved.</p>"

        );

    e = e.GetInstanceOf();

    e.SetAttribute("Today", new DateTime(2009, 8, 4));

    string expecting = "<p>&copy; 2008- 2009 . All rights
reserved.</p>";

    Assert.AreEqual(expecting, e.ToString());

}

 

Sam

 

 

From: Dustin A. Lambert [mailto:dustin at biztechetc.com] 
Sent: Tuesday, August 04, 2009 1:37 PM
To: Sam Harwell
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] Current C# Dev Version

 

I'm using 3.2... from file: StringTemplate-3.2-2009-06-28.7z

When I look at the version on Antlr3.StringTemplate, it states
"3.1.3.6002"

I've removed and re-added several times... I get the same result.


I setup a renderer for integers and ST is passing through the weird
numbers, so I suppose that it is a problem with reading off the int from
DateTime...

Dustin Lambert



On Tue, Aug 4, 2009 at 2:22 PM, Sam Harwell
<sharwell at pixelminegames.com> wrote:

When you say you were testing the latest beta, were you talking about
mine (3.2) or the one previously (before last weekend) posted as the
"latest beta (3.1)." :)

 

Sam

 

From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Dustin
A. Lambert
Sent: Tuesday, August 04, 2009 6:19 AM
To: stringtemplate-interest at antlr.org
Subject: [stringtemplate-interest] Current C# Dev Version

 

Greetings,

I've been testing the latest C# beta and discovered a problem...

If I set a template parameter to an object of System.DateTime like so:
var master = Global.Templates.GetInstanceOf("master");
master.SetAttribute("Today", System.DateTime.Now);

And then in the template do something like this:
<p>&copy; 2008- $Today.Year$ . All rights reserved.</p>

$Today.Year$ comes out as a weird number... i.e. "(c) 2008- 10540 "

I checked for custom renderers and did not find any..
?master.GetAttributeRenderer(typeof(DateTime))
null

?master.GetAttributeRenderer(typeof(int))
null

Any suggestions?

Thanks!

Dustin Lambert

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20090804/e72012f7/attachment-0001.html 


More information about the stringtemplate-interest mailing list