0 people like it.

Obsolete warning

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
open System

// def version 1
type TestRecordV1 =
  { Field1 : string
    Feild2 : string } 
  static member Emtpy =
    { Field1 = null
      Feild2 = null }
// usage
let v1var1 = { TestRecordV1.Emtpy with Field1 = "field1" }
let v1var2 = { TestRecordV1.Emtpy with Feild2 = "field2" }
let v1var3 = { TestRecordV1.Field1 = "field1"; Feild2 = "field2" }
let v1access1 = v1var1.Field1
let v1access2 = v1var1.Feild2

// def version 2
type TestRecordV2 =
  { Field1 : string
    [<Obsolete("Use Field2 instead")>]
    Feild2 : string
    Field2 : string } 
  static member Emtpy =
    { Field1 = null
      Feild2 = null
      Field2 = null } // can we somehow hide the warning here
                      // (as it is obvious that we need to address it)
                      // at least limit to the "Feild2 = null" line
// usage
let v2var1 = { TestRecordV2.Emtpy with Field1 = "field1" } // why?
let v2var2 = { TestRecordV2.Emtpy with Feild2 = "field2" }
let v2var3 = { TestRecordV2.Emtpy with Field2 = "field2" } // why?
//let v2var3 = { TestRecordV2.Field1 = "field1"; Feild2 = "field2" } // broken, should never be used anyway (not even in version1)
let v2access1 = v2var1.Field1
let v2access2 = v2var1.Feild2
let v2access3 = v2var1.Field2

// def version 3
type TestRecordV3 =
  { Field1 : string
    Field2 : string } 
  static member Emtpy =
    { Field1 = null
      Field2 = null } // was broken
  [<Obsolete("Use Field2 instead")>]
  member x.Feild2 = x.Field2
// usage
let v3var1 = { TestRecordV3.Emtpy with Field1 = "field1" }
//let v3var2 = { TestRecordV3.Emtpy with Feild2 = "field2" } // broken
let v3var3 = { TestRecordV3.Emtpy with Field2 = "field2" }
let v3access1 = v3var1.Field1
let v3access2 = v3var1.Feild2 // obsolete, OK
let v3access3 = v3var1.Field2
namespace System
type TestRecordV1 =
  {Field1: string;
   Feild2: string;}
  static member Emtpy : TestRecordV1

Full name: Script.TestRecordV1
TestRecordV1.Field1: string
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = String

Full name: Microsoft.FSharp.Core.string
TestRecordV1.Feild2: string
static member TestRecordV1.Emtpy : TestRecordV1

Full name: Script.TestRecordV1.Emtpy
val v1var1 : TestRecordV1

Full name: Script.v1var1
property TestRecordV1.Emtpy: TestRecordV1
val v1var2 : TestRecordV1

Full name: Script.v1var2
val v1var3 : TestRecordV1

Full name: Script.v1var3
val v1access1 : string

Full name: Script.v1access1
val v1access2 : string

Full name: Script.v1access2
type TestRecordV2 =
  {Field1: string;
   Feild2: string;
   Field2: string;}
  static member Emtpy : TestRecordV2

Full name: Script.TestRecordV2
TestRecordV2.Field1: string
Multiple items
type ObsoleteAttribute =
  inherit Attribute
  new : unit -> ObsoleteAttribute + 2 overloads
  member IsError : bool
  member Message : string

Full name: System.ObsoleteAttribute

--------------------
ObsoleteAttribute() : unit
ObsoleteAttribute(message: string) : unit
ObsoleteAttribute(message: string, error: bool) : unit
TestRecordV2.Feild2: string
TestRecordV2.Field2: string
static member TestRecordV2.Emtpy : TestRecordV2

Full name: Script.TestRecordV2.Emtpy
val v2var1 : TestRecordV2

Full name: Script.v2var1
property TestRecordV2.Emtpy: TestRecordV2
val v2var2 : TestRecordV2

Full name: Script.v2var2
val v2var3 : TestRecordV2

Full name: Script.v2var3
val v2access1 : string

Full name: Script.v2access1
val v2access2 : string

Full name: Script.v2access2
val v2access3 : string

Full name: Script.v2access3
type TestRecordV3 =
  {Field1: string;
   Field2: string;}
  static member Emtpy : TestRecordV3

Full name: Script.TestRecordV3
TestRecordV3.Field1: string
TestRecordV3.Field2: string
static member TestRecordV3.Emtpy : TestRecordV3

Full name: Script.TestRecordV3.Emtpy
val x : TestRecordV3
val v3var1 : TestRecordV3

Full name: Script.v3var1
property TestRecordV3.Emtpy: TestRecordV3
val v3var3 : TestRecordV3

Full name: Script.v3var3
val v3access1 : string

Full name: Script.v3access1
val v3access2 : string

Full name: Script.v3access2
val v3access3 : string

Full name: Script.v3access3

More information

Link:http://fssnip.net/7OE
Posted:8 years ago
Author:
Tags: