• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-dotnet / 9881710012

10 Jul 2024 09:26PM UTC coverage: 81.928% (+0.6%) from 81.376%
9881710012

Pull #3644

github

59a21e
nirinchev
Prepare a debug build
Pull Request #3644: Prepare a debug build

2317 of 3019 branches covered (76.75%)

Branch coverage included in aggregate %.

9402 of 11285 relevant lines covered (83.31%)

42998.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/Realm/Realm/DataBinding/RealmObjectTypeDelegator.cs
1
////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2016 Realm Inc.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
//
17
////////////////////////////////////////////////////////////////////////////
18

19
using System;
20
using System.Collections.Concurrent;
21
using System.Linq;
22
using System.Reflection;
23
using Realms.Schema;
24

25
namespace Realms.DataBinding
26
{
27
    internal class RealmObjectTypeDelegator : TypeDelegator
28
    {
29
        // Holds property name -> PropertyInfo map to avoid creating a new WovenPropertyInfo for each GetDeclaredProperty call.
30
        private readonly ConcurrentDictionary<string, PropertyInfo> _propertyCache = new();
1✔
31

32
        private readonly ObjectSchema? _schema;
33

34
        internal RealmObjectTypeDelegator(Type type, ObjectSchema? schema) : base(type)
1✔
35
        {
1✔
36
            _schema = schema;
1✔
37
        }
1✔
38

39
        protected override PropertyInfo? GetPropertyImpl(string name, BindingFlags bindingAttr, Binder? binder, Type? returnType, Type[]? types, ParameterModifier[]? modifiers)
40
        {
19✔
41
            var result = base.GetPropertyImpl(name, bindingAttr, binder, returnType, types, modifiers);
19✔
42

43
            if (result == null)
19!
44
            {
×
45
                return null;
×
46
            }
47

48
            // Schema is null only for woven unmanaged objects
49
            if (_schema?.Any(p => p.ManagedName == name) ?? result.GetCustomAttribute<WovenPropertyAttribute>() != null)
44!
50
            {
19✔
51
                return _propertyCache.GetOrAdd(name, _ => new WovenPropertyInfo(result));
21✔
52
            }
53

54
            return result;
×
55
        }
19✔
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc