Skip to content

Commit

Permalink
Add test cases. (#98)
Browse files Browse the repository at this point in the history
* Fix warnings.
* Fix documents.
  • Loading branch information
maroontress-tomohisa authored Mar 15, 2019
1 parent 3b28bc7 commit 6258cef
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 4 deletions.
4 changes: 2 additions & 2 deletions StyleChecker/StyleChecker.Test/Framework/Belief.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public Result ToResult(
/// The new result.
/// </returns>
public Result ToResult(
string id,
string message,
string id,
string message,
DiagnosticSeverity serverity = DiagnosticSeverity.Warning)
=> new Result(SingleLocation(), id, message, serverity);

Expand Down
3 changes: 3 additions & 0 deletions StyleChecker/StyleChecker.Test/Framework/BeliefExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace StyleChecker.Test.Framework
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;

/// <summary>
/// Extracts <see cref="Belief"/>s embedded in a C# source code.
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class BeliefExtractor : DiagnosticAnalyzer
{
Expand Down
27 changes: 26 additions & 1 deletion StyleChecker/StyleChecker.Test/Framework/CompilationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,53 @@ public class CompilationException : Exception
/// The error message.
/// </param>
/// <param name="rawDiagnostics">
/// The diagnostics of the compiler.
/// The raw diagnostics of the compiler.
/// </param>
public CompilationException(
string message,
ImmutableArray<Diagnostic> rawDiagnostics)
: base(message)
=> RawDiagnostics = rawDiagnostics;

/// <summary>
/// Initializes a new instance of the <see cref="CompilationException"
/// /> class.
/// </summary>
public CompilationException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="CompilationException"
/// /> class.
/// </summary>
/// <param name="message">
/// The message that describes the error.
/// </param>
public CompilationException(string message)
: base(message)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="CompilationException"
/// /> class.
/// </summary>
/// <param name="message">
/// The error message that explains the reason for the exception.
/// </param>
/// <param name="innerException">
/// The exception that is the cause of the current exception, or a null
/// reference if no inner exception is specified.
/// </param>
public CompilationException(string message, Exception innerException)
: base(message, innerException)
{
}

/// <summary>
/// Gets the raw diagnostics of the compiler.
/// </summary>
public ImmutableArray<Diagnostic> RawDiagnostics { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ protected void VerifyDiagnostic(
/// <param name="analyzer">
/// The analyzer that was being run on the sources.
/// </param>
/// <param name="atmosphere">
/// The compilation environment.
/// </param>
/// <param name="expectedResults">
/// Diagnostic Results that should have appeared in the code.
/// </param>
Expand Down Expand Up @@ -361,6 +364,9 @@ void AssertOne<T>(
/// <param name="analyzer">
/// The analyzer that was being run on the sources.
/// </param>
/// <param name="atmosphere">
/// The compilation environment.
/// </param>
/// <param name="diagnostic">
/// The diagnostic that was found in the code.
/// </param>
Expand Down Expand Up @@ -426,6 +432,9 @@ string Message() => FormatDiagnostics(
/// <param name="analyzer">
/// The analyzer that this verifier tests.
/// </param>
/// <param name="atmosphere">
/// The compilation environment.
/// </param>
/// <param name="diagnostics">
/// The Diagnostics to be formatted.
/// </param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@ public void CallWithIntType()
PrintMethodExpression(typeof(int));
PrintGenericsMethod<object>(typeof(int));
}

public void CallWithTypeParameter<T>()
{
PrintMethod(typeof(T));
PrintMethodExpression(typeof(T));
PrintGenericsMethod<object>(typeof(T));
PrintGenericsMethod<T>(typeof(T));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,13 @@ public void CallWithIntType()
PrintMethodExpression<int>();
PrintGenericsMethod<object, int>();
}

public void CallWithTypeParameter<T>()
{
PrintMethod<T>();
PrintMethodExpression<T>();
PrintGenericsMethod<object, T>();
PrintGenericsMethod<T, T>();
}
}
}
2 changes: 1 addition & 1 deletion doc/rules/IsNull.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The code fix provides an option replacing expression `... is null` and
Replacing the expression `... is null` with `... == null`, as well as replacing
`!(... is null)` with `... != null`, can be a breaking change.
For more information, refer to
[the description of EqualsNull code fix](../EqualsNull.md#Remarks).
[the description of EqualsNull code fix](EqualsNull.md#Remarks).

## Example

Expand Down

0 comments on commit 6258cef

Please sign in to comment.