title: Overriding static properties in F# with extension methods
body: <p>F# extension methods can be defined on types with the same name and type signature as existing instance and static methods to effectively override the default implementation of these methods, however I can't get this to work on static properties.</p>
  
  <p>In particular, I'm trying to create an extension method for <code>DateTime</code> that returns a more precise time as follows:</p>
  
  <pre><code>#nowarn "51"
  
  open System
  
  module DateTimeExtensions =
  
      open System.Runtime.InteropServices
  
      [&lt;DllImport("Kernel32.dll", CallingConvention = CallingConvention.Winapi)&gt;]
      extern void private GetSystemTimePreciseAsFileTime(int64*)
  
      type System.DateTime with
          // example showing that static methods can be overridden
          static member IsLeapYear(_: DateTime) =
              printfn "Using overridden IsLeapYear!"
              true
  
          // more accurate UtcNow method (note: not supported by older OS versions)
          static member UtcNow =
              printfn "Using overridden UtcNow!"
              let mutable fileTime = 0L
              GetSystemTimePreciseAsFileTime(&amp;&amp;fileTime)
              DateTime.FromFileTimeUtc(fileTime)
  </code></pre>
  
  <p>However, the output when executing</p>
  
  <pre><code>open DateTimeExtensions
  let _ = DateTime.IsLeapYear(DateTime.UtcNow)
  </code></pre>
  
  <p>is just</p>
  
  <pre><code>Using overridden IsLeapYear!
  </code></pre>
  
  <p>which shows that the static method 'override' is working, but not the static property.</p>
  
  <p>(Note: I'm using F# 4.0)</p>