rspec/rules/S2325/csharp/rule.adoc
Fred Tingaud 51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
2023-06-22 10:38:01 +02:00

106 lines
1.7 KiB
Plaintext

== Why is this an issue?
Methods and properties that don't access instance data can be ``++static++`` to prevent any misunderstanding about the contract of the method.
=== Noncompliant code example
[source,csharp]
----
public class Utilities
{
public int MagicNum // Noncompliant
{
get
{
return 42;
}
}
private static string magicWord = "please";
public string MagicWord // Noncompliant
{
get
{
return magicWord;
}
set
{
magicWord = value;
}
}
public int Sum(int a, int b) // Noncompliant
{
return a + b;
}
}
----
=== Compliant solution
[source,csharp]
----
public class Utilities
{
public static int MagicNum
{
get
{
return 42;
}
}
private static string magicWord = "please";
public static string MagicWord
{
get
{
return magicWord;
}
set
{
magicWord = value;
}
}
public static int Sum(int a, int b)
{
return a + b;
}
}
----
=== Exceptions
Methods with the following names are excluded because they can't be made ``++static++``:
* Application_AuthenticateRequest
* Application_BeginRequest
* Application_End
* Application_EndRequest
* Application_Error
* Application_Init
* Application_Start
* Session_End
* Session_Start
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]