Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Common settings that generally should always be used with your language specific settings
# A combination from https://github.com/gitattributes/gitattributes
# We normalize the repo line endings to LF and backstop with .editorconfig

# Auto detect text files and perform LF normalization
* text=auto eol=lf encoding=UTF-8

#
# The above will handle all files NOT found below
#

# Documents
*.bibtex text diff=bibtex
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md text diff=markdown
*.mdx text diff=markdown
*.tex text diff=tex
*.adoc text
*.textile text
*.mustache text
*.csv text
*.tab text
*.tsv text
*.txt text
*.sql text
*.epub diff=astextplain

# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
# SVG treated as text by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
*.eps binary

# Scripts
*.bash text
*.fish text
*.sh text
*.zsh text

# These are explicitly windows files and could use crlf, but all the tools support lf
*.bat text
*.cmd text


# Serialisation
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text

# Archives
*.7z binary
*.gz binary
*.tar binary
*.tgz binary
*.zip binary

# Text files where line endings should be preserved
*.patch -text

#
# Exclude files from exporting
#

.gitattributes export-ignore
.gitignore export-ignore
.gitkeep export-ignore

# CSharp files
*.cs text diff=csharp
*.cshtml text diff=html
*.csx text diff=csharp
*.sln text
*.csproj text

# See https://github.com/VerifyTests/Verify?tab=readme-ov-file#text-file-settings
*.verified.txt text eol=lf working-tree-encoding=UTF-8
*.verified.xml text eol=lf working-tree-encoding=UTF-8
*.verified.json text eol=lf working-tree-encoding=UTF-8

# Basic .gitattributes for a PowerShell repo.

# Source files
# ============
*.ps1 text
*.ps1x text
*.psm1 text
*.psd1 text
*.ps1xml text
*.pssc text
*.psrc text
*.cdxml text
# Fix syntax highlighting on GitHub to allow comments
.vscode/*.json linguist-language=JSON-with-Comments
62 changes: 31 additions & 31 deletions Moq.Analyzers.sln
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34928.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers", "Source\Moq.Analyzers\Moq.Analyzers.csproj", "{41ECC571-F586-460A-9BED-23528C8210C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers.Test", "Source\Moq.Analyzers.Test\Moq.Analyzers.Test.csproj", "{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41ECC571-F586-460A-9BED-23528C8210C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41ECC571-F586-460A-9BED-23528C8210C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41ECC571-F586-460A-9BED-23528C8210C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41ECC571-F586-460A-9BED-23528C8210C4}.Release|Any CPU.Build.0 = Release|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8C917BC1-C0DE-4A46-BEE8-32FD66B447B1}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34928.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers", "Source\Moq.Analyzers\Moq.Analyzers.csproj", "{41ECC571-F586-460A-9BED-23528C8210C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers.Test", "Source\Moq.Analyzers.Test\Moq.Analyzers.Test.csproj", "{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41ECC571-F586-460A-9BED-23528C8210C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41ECC571-F586-460A-9BED-23528C8210C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41ECC571-F586-460A-9BED-23528C8210C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41ECC571-F586-460A-9BED-23528C8210C4}.Release|Any CPU.Build.0 = Release|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8C917BC1-C0DE-4A46-BEE8-32FD66B447B1}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Diagnostic 1
Id: Moq1300
Location: SourceFile(Test0.cs[1376..1391))
Location: SourceFile(Test0.cs[1369..1384))
Highlight: BaseSampleClass
Lines: mock.As<BaseSampleClass>();
Severity: Error
Message: Mock.As() should take interfaces only

Diagnostic 2
Id: Moq1300
Location: SourceFile(Test0.cs[1541..1551))
Location: SourceFile(Test0.cs[1534..1544))
Highlight: OtherClass
Lines: mock.As<OtherClass>();
Severity: Error
Expand Down
42 changes: 21 additions & 21 deletions Source/Moq.Analyzers.Test/AsAcceptOnlyInterfaceAnalyzerTests.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
namespace Moq.Analyzers.Test
{
using System.IO;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using TestHelper;
using Xunit;
public class AsAcceptOnlyInterfaceAnalyzerTests : DiagnosticVerifier
{
[Fact]
public Task ShouldPassIfGoodParameters()
{
return Verify(VerifyCSharpDiagnostic(File.ReadAllText("Data/AsAcceptOnlyInterface.cs")));
}
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new AsShouldBeUsedOnlyForInterfaceAnalyzer();
}
}
namespace Moq.Analyzers.Test
{
using System.IO;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using TestHelper;
using Xunit;

public class AsAcceptOnlyInterfaceAnalyzerTests : DiagnosticVerifier
{
[Fact]
public Task ShouldPassIfGoodParameters()
{
return Verify(VerifyCSharpDiagnostic(File.ReadAllText("Data/AsAcceptOnlyInterface.cs")));
}

protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new AsShouldBeUsedOnlyForInterfaceAnalyzer();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Diagnostic 1
Id: Moq1100
Location: SourceFile(Test0.cs[1120..1127))
Location: SourceFile(Test0.cs[1090..1097))
Highlight: (int i)
Lines: mock.Setup(x => x.Do(It.IsAny<string>())).Callback((int i) => { });
Severity: Warning
Message: Callback signature must match the signature of the mocked method.

Diagnostic 2
Id: Moq1100
Location: SourceFile(Test0.cs[1201..1223))
Location: SourceFile(Test0.cs[1170..1192))
Highlight: (string s1, string s2)
Lines: mock.Setup(x => x.Do(It.IsAny<string>())).Callback((string s1, string s2) => { });
Severity: Warning
Message: Callback signature must match the signature of the mocked method.

Diagnostic 3
Id: Moq1100
Location: SourceFile(Test0.cs[1336..1355))
Location: SourceFile(Test0.cs[1304..1323))
Highlight: (string s1, int i1)
Lines: mock.Setup(x => x.Do(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<DateTime>())).Callback((string s1, int i1) => { });
Severity: Warning
Message: Callback signature must match the signature of the mocked method.

Diagnostic 4
Id: Moq1100
Location: SourceFile(Test0.cs[1435..1442))
Location: SourceFile(Test0.cs[1402..1409))
Highlight: (int i)
Lines: mock.Setup(x => x.Do(It.IsAny<List<string>>())).Callback((int i) => { });
Severity: Warning
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
namespace Moq.Analyzers.Test
{
using System.IO;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using TestHelper;
using Xunit;
public class CallbackSignatureShouldMatchMockedMethodAnalyzerTests : DiagnosticVerifier
{
[Fact]
public Task ShouldPassIfGoodParameters()
{
return Verify(VerifyCSharpDiagnostic(File.ReadAllText("Data/CallbackSignatureShouldMatchMockedMethod.cs")));
}
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new CallbackSignatureShouldMatchMockedMethodAnalyzer();
}
}
namespace Moq.Analyzers.Test
{
using System.IO;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using TestHelper;
using Xunit;

public class CallbackSignatureShouldMatchMockedMethodAnalyzerTests : DiagnosticVerifier
{
[Fact]
public Task ShouldPassIfGoodParameters()
{
return Verify(VerifyCSharpDiagnostic(File.ReadAllText("Data/CallbackSignatureShouldMatchMockedMethod.cs")));
}

protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new CallbackSignatureShouldMatchMockedMethodAnalyzer();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
namespace Moq.Analyzers.Test
{
using System.IO;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using TestHelper;
using Xunit;
public class CallbackSignatureShouldMatchMockedMethodCodeFixTests : CodeFixVerifier
{
[Fact]
public Task ShouldSuggestQuickFixIfBadParameters()
{
return Verify(VerifyCSharpFix(File.ReadAllText("Data/CallbackSignatureShouldMatchMockedMethod.cs")));
}
protected override CodeFixProvider GetCSharpCodeFixProvider()
{
return new CallbackSignatureShouldMatchMockedMethodCodeFix();
}
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new CallbackSignatureShouldMatchMockedMethodAnalyzer();
}
}
namespace Moq.Analyzers.Test
{
using System.IO;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using TestHelper;
using Xunit;

public class CallbackSignatureShouldMatchMockedMethodCodeFixTests : CodeFixVerifier
{
[Fact]
public Task ShouldSuggestQuickFixIfBadParameters()
{
return Verify(VerifyCSharpFix(File.ReadAllText("Data/CallbackSignatureShouldMatchMockedMethod.cs")));
}

protected override CodeFixProvider GetCSharpCodeFixProvider()
{
return new CallbackSignatureShouldMatchMockedMethodCodeFix();
}

protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new CallbackSignatureShouldMatchMockedMethodAnalyzer();
}
}
}
Loading