Skip to content

Commit

Permalink
Add analyzer support for static interface members
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Apr 2, 2024
1 parent 8d618dc commit 05b1c8a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
Expand Down Expand Up @@ -77,7 +77,7 @@ IEnumerable<AnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {
foreach (EventDef ev in type.Events.Where(e => e.Name.EndsWith(analyzedEvent.Name))) {
var accessor = GetAccessor(ev);
// Don't include abstract accessors, they don't implement anything
if (accessor is null || !accessor.IsVirtual || accessor.IsAbstract)
if (accessor is null || (!accessor.IsVirtual && !accessor.IsStatic) || accessor.IsAbstract)
continue;
if (accessor.HasOverrides && accessor.Overrides.Any(m => CheckEquals(m.MethodDeclaration.ResolveMethodDef(), analyzedMethod))) {
yield return new EventNode(ev) { Context = Context };
Expand All @@ -88,7 +88,7 @@ IEnumerable<AnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {
foreach (EventDef ev in type.Events.Where(e => e.Name == analyzedEvent.Name)) {
var accessor = GetAccessor(ev);
// Don't include abstract accessors, they don't implement anything
if (accessor is null || !accessor.IsVirtual || accessor.IsAbstract)
if (accessor is null || (!accessor.IsVirtual && !accessor.IsStatic) || accessor.IsAbstract)
continue;
if (TypesHierarchyHelpers.MatchInterfaceMethod(accessor, analyzedMethod, implementedInterfaceRef)) {
yield return new EventNode(ev) { Context = Context };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
Expand Down Expand Up @@ -57,7 +57,7 @@ IEnumerable<AnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {

foreach (var method in type.Methods) {
// Don't include abstract methods, they don't implement anything
if (!method.IsVirtual || method.IsAbstract)
if ((!method.IsVirtual && !method.IsStatic) || method.IsAbstract)
continue;
if (method.HasOverrides && method.Overrides.Any(m => CheckOverride(m))) {
yield return new MethodNode(method) { Context = Context };
Expand All @@ -80,7 +80,7 @@ IEnumerable<AnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {
if (implementedInterfaceRef is not null) {
foreach (var method in type.Methods) {
// Don't include abstract methods, they don't implement anything
if (!method.IsVirtual || method.IsAbstract)
if ((!method.IsVirtual && !method.IsStatic) || method.IsAbstract)
continue;
if (method.Name != analyzedMethod.Name)
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
Expand Down Expand Up @@ -65,7 +65,7 @@ IEnumerable<AnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {
foreach (PropertyDef property in type.Properties.Where(e => e.Name.EndsWith(analyzedProperty.Name))) {
MethodDef accessor = isGetter ? property.GetMethod : property.SetMethod;
// Don't include abstract accessors, they don't implement anything
if (accessor is null || !accessor.IsVirtual || accessor.IsAbstract)
if (accessor is null || (!accessor.IsVirtual && !accessor.IsStatic) || accessor.IsAbstract)
continue;
if (accessor.HasOverrides && accessor.Overrides.Any(m => CheckEquals(m.MethodDeclaration.ResolveMethodDef(), analyzedMethod))) {
yield return new PropertyNode(property) { Context = Context };
Expand All @@ -76,7 +76,7 @@ IEnumerable<AnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {
foreach (PropertyDef property in type.Properties.Where(e => e.Name == analyzedProperty.Name)) {
MethodDef accessor = isGetter ? property.GetMethod : property.SetMethod;
// Don't include abstract accessors, they don't implement anything
if (accessor is null || !accessor.IsVirtual || accessor.IsAbstract)
if (accessor is null || (!accessor.IsVirtual && !accessor.IsStatic) || accessor.IsAbstract)
continue;
if (TypesHierarchyHelpers.MatchInterfaceMethod(accessor, analyzedMethod, implementedInterfaceRef)) {
yield return new PropertyNode(property) { Context = Context };
Expand Down

0 comments on commit 05b1c8a

Please sign in to comment.