Skip to main content
added 19 characters in body
Source Link
Peter Taylor
  • 5.1k
  • 1
  • 36
  • 59

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> using System; namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks.ToString()); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks.ToString()); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> using System; namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks.ToString()); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

Fix bug
Source Link
Peter Taylor
  • 5.1k
  • 1
  • 36
  • 59

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks.ToString()); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks.ToString()); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

One approach which I'm amazed no-one has mentioned yet is to use T4 Text Templates for code generation.

<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System" #> <#@ output extension=".g.cs" #> namespace Foo.Bar { public static partial class Constants { public static DateTime CompilationTimestampUtc { get { return new DateTime(<# Write(DateTime.UtcNow.Ticks); #>L, DateTimeKind.Utc); } } } } 

Pros:

  • Locale-independent
  • Allows a lot more than just the time of compilation

Cons:

Source Link
Peter Taylor
  • 5.1k
  • 1
  • 36
  • 59
Loading