Skip to content

Commit f5b699e

Browse files
committed
Merge pull request #1028 from autoboosh/next
fix visual studio 2015 invalidcastexception for built-in declarations
2 parents 6af8a66 + 2da50c0 commit f5b699e

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Rubberduck.Parsing/Symbols/AdodbObjectModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5-
using System.Text;
6-
using System.Threading.Tasks;
75
using Rubberduck.VBEditor;
6+
using System.Runtime.CompilerServices;
87

98
namespace Rubberduck.Parsing.Symbols
109
{
@@ -19,7 +18,7 @@ public static IEnumerable<Declaration> Declarations
1918
{
2019
if (_adodbDeclarations == null)
2120
{
22-
var nestedTypes = typeof(AdodbObjectModel).GetNestedTypes(BindingFlags.NonPublic);
21+
var nestedTypes = typeof(AdodbObjectModel).GetNestedTypes(BindingFlags.NonPublic).Where(t => Attribute.GetCustomAttribute(t, typeof(CompilerGeneratedAttribute)) == null);
2322
var fields = nestedTypes.SelectMany(t => t.GetFields());
2423
var values = fields.Select(f => f.GetValue(null));
2524
_adodbDeclarations = values.Cast<Declaration>();

Rubberduck.Parsing/Symbols/ExcelObjectModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Linq;
33
using System.Reflection;
44
using Rubberduck.VBEditor;
5+
using System.Runtime.CompilerServices;
6+
using System;
57

68
namespace Rubberduck.Parsing.Symbols
79
{
@@ -21,7 +23,7 @@ public static IEnumerable<Declaration> Declarations
2123
{
2224
if (_excelDeclarations == null)
2325
{
24-
var nestedTypes = typeof(ExcelObjectModel).GetNestedTypes(BindingFlags.NonPublic);
26+
var nestedTypes = typeof(ExcelObjectModel).GetNestedTypes(BindingFlags.NonPublic).Where(t => Attribute.GetCustomAttribute(t, typeof(CompilerGeneratedAttribute)) == null);
2527
var fields = nestedTypes.SelectMany(t => t.GetFields());
2628
var values = fields.Select(f => f.GetValue(null));
2729
_excelDeclarations = values.Cast<Declaration>();

Rubberduck.Parsing/Symbols/VbaStandardLib.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Linq;
33
using System.Reflection;
44
using Rubberduck.VBEditor;
5+
using System.Runtime.CompilerServices;
6+
using System;
57

68
namespace Rubberduck.Parsing.Symbols
79
{
@@ -19,7 +21,7 @@ public static IEnumerable<Declaration> Declarations
1921
{
2022
if (_standardLibDeclarations == null)
2123
{
22-
var nestedTypes = typeof(VbaStandardLib).GetNestedTypes(BindingFlags.NonPublic);
24+
var nestedTypes = typeof(VbaStandardLib).GetNestedTypes(BindingFlags.NonPublic).Where(t => Attribute.GetCustomAttribute(t, typeof(CompilerGeneratedAttribute)) == null);
2325
var fields = nestedTypes.SelectMany(t => t.GetFields());
2426
var values = fields.Select(f => f.GetValue(null));
2527
_standardLibDeclarations = values.Cast<Declaration>();

0 commit comments

Comments
 (0)