-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
69 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,83 @@ | ||
namespace CodeAnalysisTest; | ||
namespace CodeAnalysisTest; | ||
|
||
public class OrganizeMembersTest | ||
/// <summary> | ||
/// Organize members test case | ||
/// </summary> | ||
public class OrganizeMembersTest : IExplicit, IImplicit | ||
{ | ||
// IDE0001 dotnet_style_predefined_type_for_locals_parameters_members = true | ||
private int _id; | ||
|
||
// IDE0001 dotnet_style_predefined_type_for_locals_parameters_members = true | ||
public int ID | ||
private bool _boolProp; | ||
public bool BoolProp | ||
{ | ||
get => _id; | ||
set => _id = value; | ||
get => _boolProp; | ||
set => _boolProp = value; | ||
} | ||
|
||
// IDE0001 dotnet_style_predefined_type_for_locals_parameters_members = true | ||
public void Display() | ||
/// <summary> | ||
/// The string property | ||
/// </summary> | ||
private string _strProp; | ||
/// <summary> | ||
/// Gets or sets the string property. | ||
/// </summary> | ||
/// <value> | ||
/// The string property. | ||
/// </value> | ||
public string StrProp | ||
{ | ||
throw new NotImplementedException(); | ||
get => _strProp; | ||
set => _strProp = value; | ||
} | ||
|
||
// IDE0001 dotnet_style_predefined_type_for_locals_parameters_members = true | ||
public event EventHandler MyEvent; | ||
/// <summary> | ||
/// My field | ||
/// </summary> | ||
private readonly int _myField; | ||
|
||
// IDE0001 dotnet_style_predefined_type_for_locals_parameters_members = true | ||
private static bool Test() | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="OrganizeMembersTest"/> class. | ||
/// </summary> | ||
/// <param name="boolProp">if set to <c>true</c> [bool property].</param> | ||
/// <param name="strProp">The string property.</param> | ||
/// <param name="myField">My field.</param> | ||
public OrganizeMembersTest(bool boolProp, string strProp, int myField) | ||
{ | ||
// ide0007 csharp_style_var_for_built_in_types = true | ||
int x = 5; | ||
int y = x; | ||
|
||
// ide0007 csharp_style_var_when_type_is_apparent = true | ||
MyClass obj = new MyClass(); | ||
var yy = obj.Age; | ||
_boolProp = boolProp; | ||
_strProp = strProp; | ||
_myField = myField; | ||
} | ||
|
||
// ide0007 csharp_style_var_elsewhere = true | ||
bool f = Random.Shared.Next() > 1; | ||
var yyy = f; | ||
/// <inheritdoc/> | ||
public Task TaskMethodAsync(CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
return true; | ||
Task IImplicit.TaskMethodAsync(CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Explicit interface | ||
/// </summary> | ||
public interface IExplicit | ||
{ | ||
/// <summary> | ||
/// Explicit method. | ||
/// </summary> | ||
/// <returns></returns> | ||
public Task TaskMethodAsync(CancellationToken cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// Implicit interface | ||
/// </summary> | ||
public interface IImplicit | ||
{ | ||
/// <summary> | ||
/// Implicit method. | ||
/// </summary> | ||
/// <returns></returns> | ||
public Task TaskMethodAsync(CancellationToken cancellationToken); | ||
} |