diff --git a/src/absil/illib.fs b/src/absil/illib.fs index e25067f7030..a3d2e31ef06 100644 --- a/src/absil/illib.fs +++ b/src/absil/illib.fs @@ -716,8 +716,8 @@ type LazyWithContext<'T,'ctxt> = funcOrException = box f; findOriginalException = findOriginalException } static member NotLazy(x:'T) : LazyWithContext<'T,'ctxt> = - { value = x; - funcOrException = null; + { value = x + funcOrException = null findOriginalException = id } member x.IsDelayed = (match x.funcOrException with null -> false | :? LazyWithContextFailure -> false | _ -> true) member x.IsForced = (match x.funcOrException with null -> true | _ -> false) diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs index c0cb29b7766..88fa20b8f58 100644 --- a/src/absil/ilwritepdb.fs +++ b/src/absil/ilwritepdb.fs @@ -205,10 +205,9 @@ let writePortablePdbInfo (fixupSPs:bool) showTimes fpdb (info:PdbData) = let _spCounts, _allSps = fixupOverlappingSequencePoints fixupSPs showTimes info.Methods let externalRowCounts = getRowCounts info.TableRowCounts let docs = - if info.Documents = null then - Array.empty - else - info.Documents + match info.Documents with + | null -> Array.empty + | _ -> info.Documents let metadata = MetadataBuilder() let serializeDocumentName (name:string) = @@ -251,9 +250,9 @@ let writePortablePdbInfo (fixupSPs:bool) showTimes fpdb (info:PdbData) = info.Methods |> Array.iteri (fun _i minfo -> let docHandle, sequencePointBlob = let sps = - if minfo.SequencePoints = null then - Array.empty - else + match minfo.SequencePoints with + | null -> Array.empty + | _ -> match minfo.Range with | None -> Array.empty | Some (_,_) -> minfo.SequencePoints @@ -266,7 +265,7 @@ let writePortablePdbInfo (fixupSPs:bool) showTimes fpdb (info:PdbData) = | false, _ -> Unchecked.defaultof | true, f -> f - // Return a document that the entire method body is declared within. + // Return a document that the entire method body is declared within. // If part of the method body is in another document returns nil handle. let tryGetSingleDocumentIndex = let mutable singleDocumentIndex = 0 diff --git a/src/fsharp/ErrorLogger.fs b/src/fsharp/ErrorLogger.fs index 4bdebfbbb88..f6335c1e06b 100755 --- a/src/fsharp/ErrorLogger.fs +++ b/src/fsharp/ErrorLogger.fs @@ -518,7 +518,7 @@ let NewlineifyErrorString (message:string) = message.Replace(stringThatIsAProxyF /// NOTE: newlines are recognized and replaced with stringThatIsAProxyForANewlineInFlatErrors (ASCII 29, the 'group separator'), /// which is decoded by the IDE with 'NewlineifyErrorString' back into newlines, so that multi-line errors can be displayed in QuickInfo let NormalizeErrorString (text : string) = - if text = null then nullArg "text" + if isNull text then nullArg "text" let text = text.Trim() let buf = System.Text.StringBuilder() diff --git a/src/fsharp/FSharp.Core/control.fs b/src/fsharp/FSharp.Core/control.fs index 80a543ba0bb..6f58a8c47e0 100644 --- a/src/fsharp/FSharp.Core/control.fs +++ b/src/fsharp/FSharp.Core/control.fs @@ -50,7 +50,7 @@ namespace System.Threading member this.Equals(ctr:CancellationTokenRegistration) = match this.source with - | null -> ctr.source = null + | null -> isNull ctr.source | _ -> this.source.Equals(ctr.source) && this.id = ctr.id override this.Equals(o:obj) = @@ -91,7 +91,7 @@ namespace System.Threading member this.Equals(ct:CancellationToken) = match this.source with - | null -> ct.source = null + | null -> isNull ct.source | _ -> this.source.Equals(ct.source) override this.Equals(o:obj) = diff --git a/src/fsharp/FSharp.Core/math/z.fs b/src/fsharp/FSharp.Core/math/z.fs index ae03db625d1..286e11f5143 100644 --- a/src/fsharp/FSharp.Core/math/z.fs +++ b/src/fsharp/FSharp.Core/math/z.fs @@ -305,7 +305,7 @@ namespace System.Numerics | _ -> invalidArg "x" "signs should be +/- 1 or 0" static member Parse(text:string) = - if text = null then raise (new ArgumentNullException("text")) + if isNull text then raise (new ArgumentNullException("text")) let text = text.Trim() let len = text.Length if len = 0 then raise (new System.FormatException(SR.GetString(SR.badFormatString))) diff --git a/src/fsharp/FSharp.Core/prim-types.fs b/src/fsharp/FSharp.Core/prim-types.fs index a522f25fbc5..a3b0f055e1d 100644 --- a/src/fsharp/FSharp.Core/prim-types.fs +++ b/src/fsharp/FSharp.Core/prim-types.fs @@ -4128,7 +4128,7 @@ namespace Microsoft.FSharp.Core #if FX_NO_CHAR_PARSE // replace System.Char.Parse let inline charParse (s: string) = - if s = null then raise (System.ArgumentNullException()) + if isNull s then raise (System.ArgumentNullException()) elif s.Length = 1 then s.[0] else raise (System.FormatException "String must be exactly one character long.") #endif diff --git a/src/fsharp/FSharp.Core/printf.fs b/src/fsharp/FSharp.Core/printf.fs index 7aece24c5d4..46b61d3e7fc 100644 --- a/src/fsharp/FSharp.Core/printf.fs +++ b/src/fsharp/FSharp.Core/printf.fs @@ -490,7 +490,10 @@ module internal PrintfImpl = let invariantCulture = System.Globalization.CultureInfo.InvariantCulture let inline boolToString v = if v then "true" else "false" - let inline stringToSafeString v = if v = null then "" else v + let inline stringToSafeString v = + match v with + | null -> "" + | _ -> v [] let DefaultPrecision = 6 @@ -1001,25 +1004,30 @@ module internal PrintfImpl = type private PrintfBuilder<'S, 'Re, 'Res>() = let mutable count = 0 - - let verifyMethodInfoWasTaken (_mi : System.Reflection.MemberInfo) = #if DEBUG - if _mi = null then + let verifyMethodInfoWasTaken (mi : System.Reflection.MemberInfo) = + if isNull mi then ignore (System.Diagnostics.Debugger.Launch()) #else - () #endif let buildSpecialChained(spec : FormatSpecifier, argTys : Type[], prefix : string, tail : obj, retTy) = if spec.TypeChar = 'a' then let mi = typeof>.GetMethod("LittleAChained", NonPublicStatics) +#if DEBUG verifyMethodInfoWasTaken mi +#else +#endif + let mi = mi.MakeGenericMethod([| argTys.[1]; retTy |]) let args = [| box prefix; tail |] mi.Invoke(null, args) elif spec.TypeChar = 't' then let mi = typeof>.GetMethod("TChained", NonPublicStatics) +#if DEBUG verifyMethodInfoWasTaken mi +#else +#endif let mi = mi.MakeGenericMethod([| retTy |]) let args = [| box prefix; tail |] mi.Invoke(null, args) @@ -1031,9 +1039,10 @@ module internal PrintfImpl = let prefix = if spec.TypeChar = '%' then "PercentStarChained" else "StarChained" let name = prefix + (string n) typeof>.GetMethod(name, NonPublicStatics) - +#if DEBUG verifyMethodInfoWasTaken mi - +#else +#endif let argTypes, args = if spec.TypeChar = '%' then [| retTy |], [| box prefix; tail |] @@ -1048,13 +1057,19 @@ module internal PrintfImpl = let buildSpecialFinal(spec : FormatSpecifier, argTys : Type[], prefix : string, suffix : string) = if spec.TypeChar = 'a' then let mi = typeof>.GetMethod("LittleAFinal", NonPublicStatics) +#if DEBUG verifyMethodInfoWasTaken mi +#else +#endif let mi = mi.MakeGenericMethod(argTys.[1] : Type) let args = [| box prefix; box suffix |] mi.Invoke(null, args) elif spec.TypeChar = 't' then let mi = typeof>.GetMethod("TFinal", NonPublicStatics) +#if DEBUG verifyMethodInfoWasTaken mi +#else +#endif let args = [| box prefix; box suffix |] mi.Invoke(null, args) else @@ -1065,8 +1080,10 @@ module internal PrintfImpl = let prefix = if spec.TypeChar = '%' then "PercentStarFinal" else "StarFinal" let name = prefix + (string n) typeof>.GetMethod(name, NonPublicStatics) - +#if DEBUG verifyMethodInfoWasTaken mi +#else +#endif let mi, args = if spec.TypeChar = '%' then @@ -1081,13 +1098,19 @@ module internal PrintfImpl = let buildPlainFinal(args : obj[], argTypes : Type[]) = let mi = typeof>.GetMethod("Final" + (argTypes.Length.ToString()), NonPublicStatics) +#if DEBUG verifyMethodInfoWasTaken mi +#else +#endif let mi = mi.MakeGenericMethod(argTypes) mi.Invoke(null, args) let buildPlainChained(args : obj[], argTypes : Type[]) = let mi = typeof>.GetMethod("Chained" + ((argTypes.Length - 1).ToString()), NonPublicStatics) +#if DEBUG verifyMethodInfoWasTaken mi +#else +#endif let mi = mi.MakeGenericMethod(argTypes) mi.Invoke(null, args) diff --git a/src/fsharp/FSharp.Core/quotations.fs b/src/fsharp/FSharp.Core/quotations.fs index 4377312f897..f333cc9c1bc 100644 --- a/src/fsharp/FSharp.Core/quotations.fs +++ b/src/fsharp/FSharp.Core/quotations.fs @@ -931,7 +931,7 @@ module Patterns = | Some methInfo -> methInfo let bindMethodHelper (parentT: Type, nm,marity,argtys,rty) = - if parentT = null then invalidArg "parentT" (SR.GetString(SR.QparentCannotBeNull)) + if isNull parentT then invalidArg "parentT" (SR.GetString(SR.QparentCannotBeNull)) if marity = 0 then let tyargTs = if parentT.IsGenericType then parentT.GetGenericArguments() else [| |] let argTs = Array.ofList (List.map (instFormal tyargTs) argtys) diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 38063e54b6d..11ba64fdcd0 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -5162,7 +5162,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv,names,takenNames) ty pat | _ -> error(Error(FSComp.SR.tcUnionCaseFieldCannotBeUsedMoreThanOnce(id.idText), id.idRange)) for i = 0 to nargtys - 1 do - if box result.[i] = null then + if isNull (box result.[i]) then result.[i] <- SynPat.Wild(m.MakeSynthetic()) let args = List.ofArray result @@ -8299,7 +8299,7 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution for (_, id, arg) in namedCallerArgs do match argNames |> List.tryFindIndex (fun id2 -> id.idText = id2.idText) with | Some i -> - if box fittedArgs.[i] = null then + if isNull(box fittedArgs.[i]) then fittedArgs.[i] <- arg let argContainerOpt = match item with | Item.UnionCase(uci,_) -> Some(ArgumentContainer.UnionCase(uci)) @@ -8325,7 +8325,7 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution | _ -> false if isSpecialCaseForBackwardCompatibility then - assert (box fittedArgs.[currentIndex] = null) + assert (isNull(box fittedArgs.[currentIndex])) fittedArgs.[currentIndex] <- List.item currentIndex args // grab original argument, not item from the list of named parametere currentIndex <- currentIndex + 1 else diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 5a171a6b023..025c94de91b 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -561,24 +561,26 @@ type ParamData = type ILFieldInit with /// Compute the ILFieldInit for the given provided constant value for a provided enum type. static member FromProvidedObj m (v:obj) = - if v = null then ILFieldInit.Null else - let objTy = v.GetType() - let v = if objTy.IsEnum then objTy.GetField("value__").GetValue(v) else v - match v with - | :? single as i -> ILFieldInit.Single i - | :? double as i -> ILFieldInit.Double i - | :? bool as i -> ILFieldInit.Bool i - | :? char as i -> ILFieldInit.Char (uint16 i) - | :? string as i -> ILFieldInit.String i - | :? sbyte as i -> ILFieldInit.Int8 i - | :? byte as i -> ILFieldInit.UInt8 i - | :? int16 as i -> ILFieldInit.Int16 i - | :? uint16 as i -> ILFieldInit.UInt16 i - | :? int as i -> ILFieldInit.Int32 i - | :? uint32 as i -> ILFieldInit.UInt32 i - | :? int64 as i -> ILFieldInit.Int64 i - | :? uint64 as i -> ILFieldInit.UInt64 i - | _ -> error(Error(FSComp.SR.infosInvalidProvidedLiteralValue(try v.ToString() with _ -> "?"),m)) + match v with + | null -> ILFieldInit.Null + | _ -> + let objTy = v.GetType() + let v = if objTy.IsEnum then objTy.GetField("value__").GetValue(v) else v + match v with + | :? single as i -> ILFieldInit.Single i + | :? double as i -> ILFieldInit.Double i + | :? bool as i -> ILFieldInit.Bool i + | :? char as i -> ILFieldInit.Char (uint16 i) + | :? string as i -> ILFieldInit.String i + | :? sbyte as i -> ILFieldInit.Int8 i + | :? byte as i -> ILFieldInit.UInt8 i + | :? int16 as i -> ILFieldInit.Int16 i + | :? uint16 as i -> ILFieldInit.UInt16 i + | :? int as i -> ILFieldInit.Int32 i + | :? uint32 as i -> ILFieldInit.UInt32 i + | :? int64 as i -> ILFieldInit.Int64 i + | :? uint64 as i -> ILFieldInit.UInt64 i + | _ -> error(Error(FSComp.SR.infosInvalidProvidedLiteralValue(try v.ToString() with _ -> "?"),m)) /// Compute the OptionalArgInfo for a provided parameter. diff --git a/src/fsharp/vs/ServiceDeclarations.fs b/src/fsharp/vs/ServiceDeclarations.fs index a6482c6d31c..464a620945d 100644 --- a/src/fsharp/vs/ServiceDeclarations.fs +++ b/src/fsharp/vs/ServiceDeclarations.fs @@ -1243,7 +1243,7 @@ type FSharpDeclarationListItem(name, glyph:int, info) = // The dataTipSpinWaitTime limits how long we block the UI thread while a tooltip pops up next to a selected item in an IntelliSense completion list. // This time appears to be somewhat amortized by the time it takes the VS completion UI to actually bring up the tooltip after selecting an item in the first place. - if task = null then + if isNull task then // kick off the actual (non-cooperative) work task <- System.Threading.Tasks.Task.Factory.StartNew(fun() -> let text = decl.DescriptionTextAsync |> Async.RunSynchronously diff --git a/src/utils/CompilerLocationUtils.fs b/src/utils/CompilerLocationUtils.fs index 85efb2e5735..32e28fca14e 100644 --- a/src/utils/CompilerLocationUtils.fs +++ b/src/utils/CompilerLocationUtils.fs @@ -99,12 +99,13 @@ module internal FSharpEnvironment = Option.ofString (try let key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32) - if key = null then null - else + match key with + | null -> null + | _ -> let sub = key.OpenSubKey(subKey) - if sub = null then null - else - downcast (sub.GetValue(null, null)) + match sub with + | null -> null + | _ -> downcast (sub.GetValue(null, null)) with e-> System.Diagnostics.Debug.Assert(false, sprintf "Failed in Get32BitRegistryStringValueViaDotNet: %s" (e.ToString())) null) diff --git a/src/utils/sformat.fs b/src/utils/sformat.fs index 62175ba758e..eec0d6a7a70 100644 --- a/src/utils/sformat.fs +++ b/src/utils/sformat.fs @@ -832,7 +832,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat | res -> let attr = (res.[0] :?> StructuredFormatDisplayAttribute) let txt = attr.Value - if txt = null || txt.Length <= 1 then + if isNull txt || txt.Length <= 1 then None else let messageRegexPattern = @"^(?
.*?)(?.*?)(?.*)$"
@@ -1169,8 +1169,11 @@ namespace Microsoft.FSharp.Text.StructuredFormat
             | :? unativeint  as d -> d.ToString() + "un"
             | :? bool   as b -> (if b then "true" else "false")
             | :? char   as c -> "\'" + formatChar true c + "\'"
-            | _ -> try  let text = obj.ToString()
-                        if text = null then "" else text
+            | _ -> try 
+                        let text = obj.ToString()
+                        match text with
+                        | null -> ""
+                        | _ -> text
                    with e ->
                      // If a .ToString() call throws an exception, catch it and use the message as the result.
                      // This may be informative, e.g. division by zero etc...
diff --git a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs
index 8454370be55..77b8146d992 100644
--- a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs
+++ b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs
@@ -256,7 +256,7 @@ type internal FSharpLanguageServiceBackgroundRequests
     // Called before a Goto Definition to wait a moment to synchonize the parse
     member fls.TrySynchronizeParseFileInformation(view: IVsTextView, source: ISource, millisecondsTimeout:int) =
 
-        if (lastParseFileRequest = null || lastParseFileRequest.Timestamp <> source.ChangeCount) then
+        if isNull lastParseFileRequest || lastParseFileRequest.Timestamp <> source.ChangeCount then
             let req = fls.TriggerParseFile(view, source)
                     
             if req <> null && (req.IsSynchronous || req.Result <> null) then
diff --git a/vsintegration/src/FSharp.LanguageService/FSharpSource.fs b/vsintegration/src/FSharp.LanguageService/FSharpSource.fs
index 56df3d9fcd6..62d2c3c7337 100644
--- a/vsintegration/src/FSharp.LanguageService/FSharpSource.fs
+++ b/vsintegration/src/FSharp.LanguageService/FSharpSource.fs
@@ -438,7 +438,7 @@ type internal FSharpSource(service:LanguageService, textLines, colorizer, vsFile
         member source.HandleCompletionResponse(req) =
             match req with
             | null -> source.ResetFSharpIntelliSenseToAppearAdornment()
-            | _ when req.View = null || req.ResultIntellisenseInfo = null -> source.ResetFSharpIntelliSenseToAppearAdornment()
+            | _ when isNull req.View || isNull req.ResultIntellisenseInfo -> source.ResetFSharpIntelliSenseToAppearAdornment()
             | _ when (req.Timestamp <> source.ChangeCount) -> source.ResetFSharpIntelliSenseToAppearAdornment()
             | _ ->
                   source.HandleResponseHelper(req)
@@ -448,7 +448,7 @@ type internal FSharpSource(service:LanguageService, textLines, colorizer, vsFile
                   async {
                       let! decls = req.ResultIntellisenseInfo.GetDeclarations(req.Snapshot, req.Line, req.Col, reason)
                       do! Async.SwitchToContext UIThread.TheSynchronizationContext
-                      if (decls = null || decls.IsEmpty()) && req.Timestamp <> req.ResultTimestamp then
+                      if (isNull decls || decls.IsEmpty()) && req.Timestamp <> req.ResultTimestamp then
                           // Second chance intellisense: we didn't get any result and the basis typecheck was stale. We need to retrigger the completion.
                           source.Completion(req.View, req.TokenInfo, req.Reason, RequireFreshResults.Yes)
                       else
diff --git a/vsintegration/src/FSharp.LanguageService/QuickParse.fs b/vsintegration/src/FSharp.LanguageService/QuickParse.fs
index 28fa4fb3b1e..e242f30c591 100644
--- a/vsintegration/src/FSharp.LanguageService/QuickParse.fs
+++ b/vsintegration/src/FSharp.LanguageService/QuickParse.fs
@@ -76,7 +76,7 @@ module internal QuickParse =
     /// allow us to use find the correct qualified items rather than resorting
     /// to the more expensive and less accurate environment lookup.
     let GetCompleteIdentifierIslandImpl (s : string) (p : int) : (string*int*bool) option =
-        if p<0 || s = null || p>=s.Length then None 
+        if p < 0 || isNull s || p >= s.Length then None 
         else
             let fixup =
                 match () with
@@ -159,34 +159,33 @@ module internal QuickParse =
 
     /// Get the partial long name of the identifier to the left of index.
     let GetPartialLongName(line:string,index) =
-        if line = null then ([],"")
-        elif index<0 then ([],"")
-        elif index>=line.Length then ([],"")
+        if isNull line then [],""
+        elif index < 0 then [],""
+        elif index >= line.Length then [],""
         else
-            let IsIdentifierPartCharacter(pos) = IsIdentifierPartCharacter(line.[pos])
-            let IsLongIdentifierPartCharacter(pos) = IsLongIdentifierPartCharacter(line.[pos])
-            let IsDot(pos) = line.[pos]='.'
+            let IsIdentifierPartCharacter pos = IsIdentifierPartCharacter line.[pos]
+            let IsLongIdentifierPartCharacter pos = IsLongIdentifierPartCharacter line.[pos]
+            let IsDot pos = line.[pos] = '.'
 
             let rec InLeadingIdentifier(pos,right,(prior,residue)) = 
-                let PushName() = 
-                    ((line.Substring(pos+1,right-pos-1))::prior),residue
+                let PushName() = ((line.Substring(pos+1,right-pos-1))::prior),residue
                 if pos < 0 then PushName()
-                elif IsIdentifierPartCharacter(pos) then InLeadingIdentifier(pos-1,right,(prior,residue))
-                elif IsDot(pos) then InLeadingIdentifier(pos-1,pos,PushName())
+                elif IsIdentifierPartCharacter pos then InLeadingIdentifier(pos-1,right,(prior,residue))
+                elif IsDot pos then InLeadingIdentifier(pos-1,pos,PushName())
                 else PushName()
 
             let rec InName(pos,startResidue,right) =
                 let NameAndResidue() = 
                     [line.Substring(pos+1,startResidue-pos-1)],(line.Substring(startResidue+1,right-startResidue))
                 if pos < 0 then [line.Substring(pos+1,startResidue-pos-1)],(line.Substring(startResidue+1,right-startResidue))
-                elif IsIdentifierPartCharacter(pos) then InName(pos-1,startResidue,right) 
-                elif IsDot(pos) then InLeadingIdentifier(pos-1,pos,NameAndResidue())
+                elif IsIdentifierPartCharacter pos then InName(pos-1,startResidue,right) 
+                elif IsDot pos then InLeadingIdentifier(pos-1,pos,NameAndResidue())
                 else NameAndResidue()
 
             let rec InResidue(pos,right) =
                 if pos < 0 then [],(line.Substring(pos+1,right-pos))
-                elif IsDot(pos) then InName(pos-1,pos,right)
-                elif IsLongIdentifierPartCharacter(pos) then InResidue(pos-1, right)
+                elif IsDot pos then InName(pos-1,pos,right)
+                elif IsLongIdentifierPartCharacter pos then InResidue(pos-1, right)
                 else [],(line.Substring(pos+1,right-pos))
                 
             let result = InResidue(index,index)
@@ -198,7 +197,7 @@ module internal QuickParse =
 
     /// Get the partial long name of the identifier to the left of index.
     let GetPartialLongNameEx(line:string,index) : (string list * string) =
-        if line = null then ([],"")
+        if isNull line then ([],"")
         elif index<0 then ([],"")
         elif index>=line.Length then ([],"")
         else
diff --git a/vsintegration/src/FSharp.VS.FSI/fsiBasis.fs b/vsintegration/src/FSharp.VS.FSI/fsiBasis.fs
index 2accf112c0c..c27f56a8d5b 100644
--- a/vsintegration/src/FSharp.VS.FSI/fsiBasis.fs
+++ b/vsintegration/src/FSharp.VS.FSI/fsiBasis.fs
@@ -110,7 +110,7 @@ module internal Util =
         /// returns Some(value) if key/value exists, None otherwise
         let tryReadHKCU<'t> subkey valueName =
             use key = Registry.CurrentUser.OpenSubKey(subkey)
-            if key = null then None else
+            if isNull key then None else
             match key.GetValue(valueName) with
             | :? 't as valTyped -> Some(valTyped)
             | _ -> None
diff --git a/vsintegration/src/FSharp.VS.FSI/fsiLanguageService.fs b/vsintegration/src/FSharp.VS.FSI/fsiLanguageService.fs
index 1ed409382ab..7448072159b 100644
--- a/vsintegration/src/FSharp.VS.FSI/fsiLanguageService.fs
+++ b/vsintegration/src/FSharp.VS.FSI/fsiLanguageService.fs
@@ -202,7 +202,7 @@ type internal FsiLanguageService() =
     member this.Sessions with set x = sessions <- Some x
     
     override this.GetLanguagePreferences() =
-        if preferences = null then
+        if isNull preferences then
             preferences <- new LanguagePreferences(this.Site,
                                                    typeof.GUID,
                                                    this.Name)
@@ -211,7 +211,7 @@ type internal FsiLanguageService() =
         preferences
         
     override this.GetScanner(buffer:IVsTextLines) =
-        if scanner = null then
+        if isNull scanner then
             scanner <- (new FsiScanner(buffer) :> IScanner)
         scanner
         
diff --git a/vsintegration/src/FSharp.VS.FSI/fsiSessionToolWindow.fs b/vsintegration/src/FSharp.VS.FSI/fsiSessionToolWindow.fs
index 29e14418558..e4ed7127423 100644
--- a/vsintegration/src/FSharp.VS.FSI/fsiSessionToolWindow.fs
+++ b/vsintegration/src/FSharp.VS.FSI/fsiSessionToolWindow.fs
@@ -116,7 +116,7 @@ type internal FsiToolWindow() as this =
 
     // The IP sample called GetService() to obtain the LanguageService.
     let fsiLangService = provider.GetService(typeof) |> unbox : FsiLanguageService
-    do  if box fsiLangService = null then
+    do  if isNull(box fsiLangService) then
             // This would be unexpected, since this package provides the service.
             System.Windows.Forms.MessageBox.Show(VFSIstrings.SR.couldNotObtainFSharpLS()) |> ignore
             failwith "No FsiLanguageService"
@@ -443,7 +443,7 @@ type internal FsiToolWindow() as this =
         let fsiProcId = sessions.ProcessID
         let dte = provider.GetService(typeof) :?> DTE
 
-        if dte.Debugger.DebuggedProcesses = null || dte.Debugger.DebuggedProcesses.Count = 0 then
+        if isNull dte.Debugger.DebuggedProcesses || dte.Debugger.DebuggedProcesses.Count = 0 then
             FsiDebuggerState.NotRunning, None
         else
             let debuggedFsi =
@@ -478,7 +478,7 @@ type internal FsiToolWindow() as this =
             let fsiProcId = sessions.ProcessID
             let dte = provider.GetService(typeof) :?> DTE
             let fsiProc = 
-                if dte.Debugger.LocalProcesses = null then None else
+                if isNull dte.Debugger.LocalProcesses then None else
                 dte.Debugger.LocalProcesses
                 |> Seq.cast
                 |> Seq.tryFind (fun p -> p.ProcessID = fsiProcId)
@@ -684,9 +684,9 @@ type internal FsiToolWindow() as this =
             let originalFilter = textView.AddCommandFilter(this :> IOleCommandTarget) |> throwOnFailure1
             // Create a command service that will use the previous command target
             // as parent target and will route to it the commands that it can not handle.
-            if commandService = null then
+            if isNull commandService then
                 commandService <-             
-                    if (null = originalFilter) then                    
+                    if isNull originalFilter then                    
                         new OleMenuCommandService(this)            
                     else
                         new OleMenuCommandService(this, originalFilter)