rspec/rules/S2329/csharp/rule.adoc
2022-02-04 16:28:24 +00:00

42 lines
886 B
Plaintext

Using the ``++base++`` keyword to access a member in anonymous methods, iterator results, and lambda and query expressions results in the compiler creating extra classes under the covers. Those extra classes are "unverifiable", meaning that the under some trust levels, the code will not be allowed to run.
Instead, the access should be made from a helper method.
== Noncompliant Code Example
[source,csharp]
----
public Person GetBasePerson()
{
return delegate () { base.GetThePerson(); } // Noncompliant
}
----
== Compliant Solution
[source,csharp]
----
string BasePerson()
{
return base.GetThePerson();
}
public Person GetBasePerson()
{
return delegate () { BasePerson(); } // Noncompliant
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]