null - NullReferenceException in F# -


After

When I move through the following code on the second line, the report is empty. . (TaggedResportReportUIVO option) = Report to go = Option.get (taggedResearchReport) if not (report.Equals, the third line is a NullReferenceException

  member generates this.setTaggedResearchReportList (Tap)) then // some stuff here?   

Why is it so, and what can I do to avoid it? ! Thanks

Added later:

Here's the call that is this.setTaggedResearchReportList :

  getMostRecentTaggedResearchReportForSecurityId (item .id) (New fight & lt; _ & gt; (this.setTaggedResearchReportList 0))   

Here is the getMostRecentTaggedResearchReportForSecurityId method:

  getMostRecentTaggedResearchReportForSecurityId go (securityId: integer) (callbackUI: action    

Your TaggedResearchReportUIVO type explicitly F #, And does not allow null as a fair value. Therefore, the compiler will prevent you from using the literal null in the form of that type of value; However, some other code is going behind the compiler and sticking a zero value there. To work around the instant issue, you can call Unchecked Diedfolf & lt; TaggedResearchReportUIVO & gt; Instead of null you can try to compare.

However, to avoid this kind of problem, you should make some more significant changes to the first place. For example, if this null is understood as the appropriate value type TaggedResearchReportUIVO , then you [& lt; AllowNullLiteral & gt;] can add attributes in that type of alternative, alternatively, if it is not really understood to use null as a fair value, So you have to check the code that is causing the problematic value.

On the one hand, there are other parts of your code that can be quite clean. For example,

  funny (X: option & lt; JSONSingleResult & gt; tag Research done) & gt; & Gt;) - & gt; Match X Really - & gt; Some options (.gate) .result). False - & gt; Anyone   

to

  option.map (funny (jsr: JSONSingleResult & lt; _ & gt;) - & gt; jsr.result) < / Code>   

Comments