var type = typeResolver.Resolve(typename, serviceProvider);
- var pinfo = type.GetRuntimeProperties().FirstOrDefault(pi => pi.Name == membername && pi.GetMethod.IsStatic);
+ var pinfo = type.GetRuntimeProperties().FirstOrDefault(pi => pi.GetMethod != null && pi.Name == membername && pi.GetMethod.IsStatic);
if (pinfo != null)
- return pinfo.GetMethod.Invoke(null, new object[] { });
+ return pinfo.GetMethod?.Invoke(null, Array.Empty<object>());
var finfo = type.GetRuntimeFields().FirstOrDefault(fi => fi.Name == membername && fi.IsStatic);
if (finfo != null)
string indexerName = defaultMember != null ? defaultMember.MemberName : "Item";
MethodInfo getterInfo =
- declarerType.GetProperties().Where(pi => pi.Name == indexerName && pi.CanRead && pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic).Select(pi => pi.GetMethod).FirstOrDefault();
+ declarerType.GetProperties().Where(pi => (pi.GetMethod != null) && pi.Name == indexerName && pi.CanRead && pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic).Select(pi => pi.GetMethod).FirstOrDefault();
if (getterInfo != null)
{
if (getterInfo == methodCall.Method)
public IEnumerator<T> GetEnumerator()
{
- ReadOnlyCollection<T> snap = _snapshot;
- if (snap == null)
+ lock (_list)
{
- lock (_list)
- _snapshot = snap = new ReadOnlyCollection<T>(_list.ToList());
+ ReadOnlyCollection<T> snap = _snapshot;
+ if (snap == null)
+ {
+ _snapshot = snap = new ReadOnlyCollection<T>(_list.ToList());
+ }
+ return snap?.GetEnumerator();
}
-
- return snap?.GetEnumerator();
}
public int IndexOf(T item)