Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-536

[Bug]: NRE in Weaver when property points to a RealmObject but doesn't have a setter

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • Q3-22FY
    • Affects Version/s: None
    • Component/s: None
    • None

      What happened?

      Fody fails to weave an object that has a getter-only property linking to a RealmObject

      Repro steps

      See example model.

      Version

      10.3.0

      What SDK flavour are you using?

      Local Database only

      What type of application is this?

      Console/Server

      Client OS and version

      N/A

      Code snippets

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      class Foo : RealmObject
      {
          public string StringProp { get; set; }
      
          // This causes the error
          public Foo FooLink { get; }
      }
      

      Stacktrace of the exception/crash you're getting

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Fody/Realm: Unexpected error caught weaving property 'LinkTypesObject.EmbeddedLink': Object reference not set to an instance of an object.. [C:\work\dotnet\Tests\Benchmarks\PerformanceTests\PerformanceTests.csproj]
      Callstack: [C:\work\dotnet\Tests\Benchmarks\PerformanceTests\PerformanceTests.csproj]
         at RealmWeaver.Weaver.ReplaceSetter(PropertyDefinition prop, FieldReference backingField, String columnName, MethodReference setValueReference) in Realm.Fody.dll:token 0x60000b6+0xf [C:\work\dotnet\Tests\Benchmarks\PerformanceTests\PerformanceTests.csproj]
         at RealmWeaver.Weaver.WeaveProperty(PropertyDefinition prop, TypeDefinition type) in Realm.Fody.dll:token 0x60000b2+0x569 [C:\work\dotnet\Tests\Benchmarks\PerformanceTests\PerformanceTests.csproj]
         at RealmWeaver.Weaver.WeaveType(TypeDefinition type) in Realm.Fody.dll:token 0x60000b1+0x62 [C:\work\dotnet\Tests\Benchmarks\PerformanceTests\PerformanceTests.csproj]
      

      Relevant log output

      No response

      Build environment

      No response

            Assignee:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Reporter:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: