[Mono-list] Fwd: Not implemented exceptions in Getters

Kevin Connell kevin at connells.net
Sat Jul 12 00:20:28 UTC 2014


---------- Forwarded message ----------
From: Kevin Connell <kevin at connells.net>
Date: Fri, Jul 11, 2014 at 8:18 PM
Subject: Re: [Mono-list] Not implemented exceptions in Getters
To: Dave Curylo <curylod at asme.org>


Here is the stack trace

Newtonsoft.Json.JsonSerializationException: Error getting value from
'IsSecurityCritical' on 'System.Reflection.MonoMethod'. --->
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> System.NotImplementedException: The
requested feature is not implemented.
  at System.Reflection.MethodBase.get_IsSecurityCritical () [0x00000] in
<filename unknown>:0
  at (wrapper delegate-invoke) <Module>:invoke_bool__this___MethodBase
(System.Reflection.MethodBase)
  at System.Reflection.MonoProperty.GetterAdapterFrame[MethodBase,Boolean]
(System.Reflection.Getter`2 getter, System.Object obj) [0x00000] in
<filename unknown>:0
  at System.Reflection.MonoProperty.GetValue (System.Object obj,
System.Object[] index) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoProperty.GetValue (System.Object obj,
System.Object[] index) [0x00000] in <filename unknown>:0
  at Newtonsoft.Json.Utilities.ReflectionUtils.GetMemberValue
(System.Reflection.MemberInfo member, System.Object target) [0x00000] in
<filename unknown>:0
  at Newtonsoft.Json.Serialization.ReflectionValueProvider.GetValue
(System.Object target) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Newtonsoft.Json.Serialization.ReflectionValueProvider.GetValue
(System.Object target) [0x00000] in <filename unknown>:0
  at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues
(Newtonsoft.Json.JsonWriter writer, System.Object value,
Newtonsoft.Json.Serialization.JsonContainerContract contract,
Newtonsoft.Json.Serialization.JsonProperty member,
Newtonsoft.Json.Serialization.JsonProperty property,
Newtonsoft.Json.Serialization.JsonContract& memberContract, System.Object&
memberValue) [0x00000] in <filename unknown>:0
  at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject
(Newtonsoft.Json.JsonWriter writer, System.Object value,
Newtonsoft.Json.Serialization.JsonObjectContract contract,
Newtonsoft.Json.Serialization.JsonProperty member,
Newtonsoft.Json.Serialization.JsonContainerContract collectionContract,
Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x00000] in
<filename unknown>:0
2014-07-11 11:39:27,093


On Fri, Jul 11, 2014 at 8:07 PM, Dave Curylo <curylod at asme.org> wrote:

> On Friday, July 11, 2014, Kevin Connell <kevin at connells.net> wrote:
>
>> Is throwing a NotImplementedExceptions  an appropriate pattern in a
>> getter?
>>
>>
> Not really an appropriate pattern, no. Which classes were these? Part of
> the mono framework?
>
> "Avoid throwing exceptions from property getters.
> Property getters should be simple operations without any preconditions. If
> a getter might throw an exception, consider redesigning the property to be
> a method. This recommendation does not apply to indexers. Indexers can
> throw exceptions because of invalid arguments."
>
> From
> http://msdn.microsoft.com/en-us/library/vstudio/ms229006(v=vs.100).aspx
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20140711/841a0ede/attachment.html>


More information about the Mono-list mailing list