Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 713269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:56:31+00:00 2026-05-14T04:56:31+00:00

Consider my first attempt, a simple type in F# like the following: type Test()

  • 0

Consider my first attempt, a simple type in F# like the following:

type Test() =
    inherit BaseImplementingNotifyPropertyChangedViaOnPropertyChanged()
    let mutable prop: string = null
    member this.Prop
        with public get() = prop
        and public set value =
            match value with
                | _ when value = prop -> ()
                | _ -> 
                    let prop = value
                    this.OnPropertyChanged("Prop")

Now I test this via C# (this object is being exposed to a C# project, so apparent C# semantics are desirable):

[TestMethod]
public void TaskMaster_Test()
{
    var target = new FTest();
    string propName = null;
    target.PropertyChanged += (s, a) => propName = a.PropertyName;
    target.Prop = "newString";

    Assert.AreEqual("Prop", propName);
    Assert.AreEqual("newString", target.Prop);

    return;
}

propName is properly assigned, my F# Setter is running, but the second assert is failing because the underlying value of prop isn’t changed. This sort of makes sense to me, because if I remove mutable from the prop field, no error is generated (and one should be because I’m trying to mutate the value). I think I must be missing a fundamental concept.

What’s the correct way to rebind/mutate prop in the Test class so that I can pass my unit test?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:56:32+00:00Added an answer on May 14, 2026 at 4:56 am

    Try this:

    type Test() =
        inherit BaseImplementingNotifyPropertyChangedViaOnPropertyChanged()
        let mutable prop: string = null
        member this.Prop
            with public get() = prop
            and public set value =
                match value with
                    | _ when value = prop -> ()
                    | _ -> 
                        prop <- value
                        this.OnPropertyChanged("Prop")
    

    You need to make the binding mutable and then alter its value in your setter. In your initial code, you were just creating a new binding (also called prop) within your setter, so no change was visible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider a string array shaped like this: string[] someName = new string[] { First,
Let's first consider a simple scenario ( see complete source on ideone.com ): import
Let's first consider the following expressions in Java. Integer temp = new Integer(1); System.out.println(temp.equals(1));
Consider following 2 programs giving same error First calss: public class Testing { Testing
consider my source file looks like this. <Content xmlns=uuid:4522eb85-0a47-45f9-8e2b-1x82c78xx920> <first>Hello World.This is Fisrt field</first>
Consider the following HTML: <div> <p>Hello</p> World </div> Why $(div).append($(p)); first removes the <p>
Consider this code: String first = abc; String second = new String(abc); When using
Consider the following image: My app first finds all the blue pixels and also
Let's consider, for instance, the following relation: R ( A,B,C ,D,E,F) where the bold
Lets consider following two codes First: for (int i=0;i<10000000;i++) { char* tab = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.