diff options
author | Daniel Grunwald <daniel@danielgrunwald.de> | 2014-05-02 00:02:53 +0400 |
---|---|---|
committer | Daniel Grunwald <daniel@danielgrunwald.de> | 2014-06-27 22:35:46 +0400 |
commit | 17aefe2446b1edc1dcd5fca14bc7f402d18947c6 (patch) | |
tree | da55ea773c5d8ad01d9f5f035e02b8950c37c9f0 /ICSharpCode.NRefactory | |
parent | 877394a22a92818c7e6ed0a7371fee393f130c7e (diff) |
Handle blob decoding errors in the type system instead of placing catch-all handlers in random spots.
Diffstat (limited to 'ICSharpCode.NRefactory')
-rw-r--r-- | ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs | 11 | ||||
-rw-r--r-- | ICSharpCode.NRefactory/TypeSystem/Implementation/ResolvedAttributeBlob.cs | 17 |
2 files changed, 14 insertions, 14 deletions
diff --git a/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs b/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs index d72afe19..7b247c1b 100644 --- a/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs +++ b/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs @@ -47,9 +47,8 @@ namespace ICSharpCode.NRefactory.Completion var browsableState = entity.Attributes.FirstOrDefault(attr => attr.AttributeType.Name == "EditorBrowsableAttribute" && attr.AttributeType.Namespace == "System.ComponentModel"); if (browsableState != null && browsableState.PositionalArguments.Count == 1) { - try { - return (System.ComponentModel.EditorBrowsableState)browsableState.PositionalArguments [0].ConstantValue; - } catch (Exception) {} + if (browsableState.PositionalArguments [0].ConstantValue is int) + return (System.ComponentModel.EditorBrowsableState)(int)browsableState.PositionalArguments [0].ConstantValue; } return System.ComponentModel.EditorBrowsableState.Always; } @@ -66,11 +65,7 @@ namespace ICSharpCode.NRefactory.Completion /// </param> public static bool IsBrowsable(this IEntity entity) { - try { - return GetEditorBrowsableState (entity) != System.ComponentModel.EditorBrowsableState.Never; - } catch (Exception) { - return true; - } + return GetEditorBrowsableState (entity) != System.ComponentModel.EditorBrowsableState.Never; } } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/ResolvedAttributeBlob.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/ResolvedAttributeBlob.cs index d446b6ff..8c747250 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/ResolvedAttributeBlob.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/ResolvedAttributeBlob.cs @@ -148,7 +148,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation arg = reader.ReadFixedArg (ctorParameter); positionalArguments.Add(arg); isError = arg.IsError; - } catch (Exception) { + } catch (Exception ex) { + Debug.WriteLine("Crash during blob decoding: " + ex); isError = true; } if (isError) { @@ -160,11 +161,15 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return; } } - ushort numNamed = reader.ReadUInt16(); - for (int i = 0; i < numNamed; i++) { - var namedArg = reader.ReadNamedArg(attributeType); - if (namedArg.Key != null) - namedArguments.Add(namedArg); + try { + ushort numNamed = reader.ReadUInt16(); + for (int i = 0; i < numNamed; i++) { + var namedArg = reader.ReadNamedArg(attributeType); + if (namedArg.Key != null) + namedArguments.Add(namedArg); + } + } catch (Exception ex) { + Debug.WriteLine("Crash during blob decoding: " + ex); } } } |