-
Notifications
You must be signed in to change notification settings - Fork 378
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,256 changed files
with
778 additions
and
1,622 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/bin | ||
/obj | ||
/TestResults |
8 changes: 8 additions & 0 deletions
8
ExternalProjects/BizHawk.AnalyzersTests/.run_tests_with_configuration.sh
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
set -e | ||
config="$1" | ||
shift | ||
dotnet test -c "$config" \ | ||
-l "junit;LogFilePath=TestResults/{assembly}.coverage.xml;MethodFormat=Class;FailureBodyFormat=Verbose" \ | ||
-l "console;verbosity=detailed" \ | ||
"$@" |
61 changes: 61 additions & 0 deletions
61
...nalProjects/BizHawk.AnalyzersTests/BizHawk.Analyzer/FeatureNotImplementedAnalyzerTests.cs
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace BizHawk.Tests.Analyzers; | ||
|
||
using System.Threading.Tasks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Verify = Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier< | ||
BizHawk.Analyzers.FeatureNotImplementedAnalyzer, | ||
Microsoft.CodeAnalysis.Testing.DefaultVerifier>; | ||
|
||
[TestClass] | ||
public sealed class FeatureNotImplementedAnalyzerTests | ||
{ | ||
[TestMethod] | ||
public Task CheckMisuseOfFeatureNotImplementedAttr() | ||
=> Verify.VerifyAnalyzerAsync(""" | ||
using System; | ||
using BizHawk.Emulation.Common; | ||
public static class Cases { | ||
[FeatureNotImplemented] private static int X => throw new NotImplementedException(); | ||
private static int Y { | ||
[FeatureNotImplemented] get => throw new NotImplementedException(); | ||
[FeatureNotImplemented] set => throw new NotImplementedException(); | ||
} | ||
[FeatureNotImplemented] private static int Z() | ||
=> throw new NotImplementedException(); | ||
{|BHI3300:[FeatureNotImplemented] private static int A => default;|} | ||
private static int B { | ||
{|BHI3300:[FeatureNotImplemented] get => default;|} | ||
{|BHI3300:[FeatureNotImplemented] set => _ = value;|} | ||
} | ||
{|BHI3300:[FeatureNotImplemented] private static int C() | ||
=> default;|} | ||
// wrong exception type, same code but different message: | ||
[FeatureNotImplemented] private static int D => {|BHI3300:throw new InvalidOperationException()|}; | ||
private static int E { | ||
[FeatureNotImplemented] get => {|BHI3300:throw new InvalidOperationException()|}; | ||
[FeatureNotImplemented] set => {|BHI3300:throw new InvalidOperationException()|}; | ||
} | ||
[FeatureNotImplemented] private static int F() | ||
=> {|BHI3300:throw new InvalidOperationException()|}; | ||
// same code but different message, since only the simplest of expected syntaxes is checked for: | ||
[FeatureNotImplemented] private static int G => {|BHI3300:throw (new NotImplementedException())|}; | ||
private static int H { | ||
[FeatureNotImplemented] get => {|BHI3300:throw (new NotImplementedException())|}; | ||
[FeatureNotImplemented] set => {|BHI3300:throw (new NotImplementedException())|}; | ||
} | ||
[FeatureNotImplemented] private static int I() | ||
=> {|BHI3300:throw (new NotImplementedException())|}; | ||
// the "wat" cases (at least the ones that are reachable in practice) | ||
{|BHI3300:[FeatureNotImplemented] private static int K { | ||
get => default; | ||
set => _ = value; | ||
}|} | ||
} | ||
namespace BizHawk.Emulation.Common { | ||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)] | ||
public sealed class FeatureNotImplementedAttribute: Attribute {} | ||
} | ||
"""); | ||
} |
37 changes: 37 additions & 0 deletions
37
...alProjects/BizHawk.AnalyzersTests/BizHawk.Analyzer/FirstOrDefaultOnStructAnalyzerTests.cs
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace BizHawk.Tests.Analyzers; | ||
|
||
using System.Threading.Tasks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Verify = Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier< | ||
BizHawk.Analyzers.FirstOrDefaultOnStructAnalyzer, | ||
Microsoft.CodeAnalysis.Testing.DefaultVerifier>; | ||
|
||
[TestClass] | ||
public sealed class FirstOrDefaultOnStructAnalyzerTests | ||
{ | ||
[TestMethod] | ||
public Task CheckMisuseOfFirstOrDefault() | ||
=> Verify.VerifyAnalyzerAsync(""" | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
public static class Cases { | ||
private static string? Y() | ||
=> new[] { 0x80.ToString(), 0x20.ToString(), 0x40.ToString() }.FirstOrDefault(static s => s.Length > 2); | ||
private static string? Z() | ||
=> new List<int> { 0x80, 0x20, 0x40 }.Select(static n => n.ToString()).FirstOrDefault(); | ||
private static int A() | ||
=> {|BHI3100:new[] { 0x80, 0x20, 0x40 }.FirstOrDefault()|}; | ||
private static int B() | ||
=> {|BHI3100:new List<int> { 0x80, 0x20, 0x40 }.FirstOrDefault()|}; | ||
private static int C() | ||
=> {|BHI3100:new[] { 0x80, 0x20, 0x40 }.FirstOrDefault(static n => n.ToString().Length > 2)|}; | ||
private static int D() | ||
=> {|BHI3100:new List<int> { 0x80, 0x20, 0x40 }.FirstOrDefault(static n => n.ToString().Length > 2)|}; | ||
} | ||
namespace BizHawk.Common.CollectionExtensions { | ||
public static class CollectionExtensions {} // Analyzer short-circuits if this doesn't exist, since that's where the extension lives | ||
} | ||
"""); | ||
} |
Oops, something went wrong.