Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ obj
*.log
*.binlog
*.rsp
/src/Usage
/src/Usage
/src/Backup
9 changes: 3 additions & 6 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nugetizer" value="https://ci.appveyor.com/nuget/nugetizer3000" />
<add key="offline" value="%userprofile%\.nuget\packages" />
</packageSources>
</configuration>
<add key="nugetizer" value="https://ci.appveyor.com/nuget/nugetizer3000" />
</packageSources>
</configuration>
16 changes: 0 additions & 16 deletions appveyor.yml

This file was deleted.

1 change: 0 additions & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
</ItemDefinitionGroup>

<ItemGroup>
<Solution Include="src\Stunts.sln" />
<Solution Include="src\Moq.sln" />
<Solution Include="src\Samples\Samples.sln" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Moq.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Tests", "Moq\Moq.Tests\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{1DBDFC27-21EC-4EAC-B51B-84EDC8DBB9D5}"
ProjectSection(SolutionItems) = preProject
build\CI.props = build\CI.props
build\PackageReference.CopyLocal.targets = build\PackageReference.CopyLocal.targets
build\PackageReferences.targets = build\PackageReferences.targets
build\Packaging.props = build\Packaging.props
build\Packaging.targets = build\Packaging.targets
Expand Down
7 changes: 4 additions & 3 deletions src/Moq/Moq.CodeAnalysis/MockDiagnostics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.CodeAnalysis;
using System;
using Microsoft.CodeAnalysis;
using Moq.Properties;

namespace Moq
Expand All @@ -10,7 +11,7 @@ public static class MockDiagnostics
new ResourceString(nameof(Resources.MissingMockAnalyzer_Title)),
new ResourceString(nameof(Resources.MissingMockAnalyzer_Message)),
"Build",
DiagnosticSeverity.Error,
bool.TryParse(Environment.GetEnvironmentVariable("AutoCodeFix"), out var value) && value ? DiagnosticSeverity.Warning : DiagnosticSeverity.Info,
true,
new ResourceString(nameof(Resources.MissingMockAnalyzer_Description)));

Expand All @@ -19,7 +20,7 @@ public static class MockDiagnostics
new ResourceString(nameof(Resources.OutdatedMockAnalyzer_Title)),
new ResourceString(nameof(Resources.OutdatedMockAnalyzer_Message)),
"Build",
DiagnosticSeverity.Error,
bool.TryParse(Environment.GetEnvironmentVariable("AutoCodeFix"), out var value) && value ? DiagnosticSeverity.Warning : DiagnosticSeverity.Info,
true,
new ResourceString(nameof(Resources.OutdatedMockAnalyzer_Description)));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Moq/Moq.CodeAnalysis/MockGeneratorAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.CodeAnalysis;

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Moq.Properties;
using Stunts;

namespace Moq
Expand Down
4 changes: 4 additions & 0 deletions src/Moq/Moq.CodeAnalysis/MockNamingConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

namespace Moq
{
/// <summary>
/// Customizes the code generation naming conventions for target namespace
/// and type suffix.
/// </summary>
public class MockNamingConvention : NamingConvention
{
public override string Namespace => MockNaming.Namespace;
Expand Down
8 changes: 8 additions & 0 deletions src/Moq/Moq.CodeFix/CustomMockCodeFixProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@

namespace Moq
{
/// <summary>
/// Custom mocks allow manually creating classes that implement IMocked and the
/// behavior pipeline from the base stunt too. It allows to manually create mocks.
/// </summary>
[ExportCodeFixProvider(LanguageNames.CSharp, LanguageNames.VisualBasic, Name = "CustomMock")]
[ExtensionOrder(Before = "ImplementInterface")]
public class CustomMockCodeFixProvider : CodeFixProvider
{
/// <summary>
/// We fixup the implementation of abstract and interface members by forwarding
/// the implementations through the behavior pipeline.
/// </summary>
public override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create(
// See http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp.Features/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs,15
"CS0534",
Expand Down
1 change: 0 additions & 1 deletion src/Moq/Moq.CodeFix/MockGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class MockGenerator : StuntGenerator
public MockGenerator(NamingConvention naming)
: base(naming, new IDocumentProcessor[]
{
new EnsureSdkReference(),
new DefaultImports(typeof(LazyInitializer).Namespace, typeof(IMocked).Namespace),
}
.Concat(GetDefaultProcessors())
Expand Down
14 changes: 14 additions & 0 deletions src/Moq/Moq.CodeFix/Moq.CodeFix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
</ItemGroup>

<ItemGroup>
<None Include="$(NuGetPackageRoot)\netstandard.library\$(NETStandardLibraryPackageVersion)\build\$(TargetFramework)\ref\netstandard.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Kind>$(PrimaryOutputKind)</Kind>
<FrameworkSpecific>true</FrameworkSpecific>
<Pack>true</Pack>
<TargetPath>%(Filename)%(Extension)</TargetPath>
<Visible>false</Visible>
</None>
<None Update="Moq.props">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<FrameworkSpecific>true</FrameworkSpecific>
<Kind>$(PrimaryOutputKind)</Kind>
<Pack>true</Pack>
</None>
<None Update="Moq.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Kind>$(PrimaryOutputKind)</Kind>
Expand Down
13 changes: 13 additions & 0 deletions src/Moq/Moq.CodeFix/Moq.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<!-- Auto-generate mocks flagged by these two analyers. -->
<AutoFix Include="MOQ001;MOQ002" />

<!-- CodeFix analyzers should only be added to DTBs since they depend on
editor features that are not available from csc/vbc -->
<CodeFix Include="$(MSBuildThisFileDirectory)netstandard.dll" />
<CodeFix Include="$(MSBuildThisFileDirectory)Moq.CodeFix.dll" />
</ItemGroup>

</Project>
16 changes: 7 additions & 9 deletions src/Moq/Moq.CodeFix/Moq.targets
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Because our analyzers are intended to be design-time only,
we cannot just include them in the package `analyzer` folder.
Instead, we have to use an alternative mechanism that only
adds them for VS. The chosen hook is to check for the DesignTimeBuild
property which is passed by VS to the project when retrieving the
analyers to run as part of the design-time build only.
-->
<ItemGroup Condition="'$(DesignTimeBuild)' == 'true'">
<Analyzer Include="$(MSBuildThisFileDirectory)*.dll"/>

<ItemGroup>
<Compile Include="$(IntermediateOutputPath)Mocks/*$(DefaultLanguageSourceExtension)">
<Link>Mocks/%(Filename)%(Extension)</Link>
<Visible>false</Visible>
</Compile>
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/Moq/Moq.CodeFix/Processors/CSharpMocked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Moq.Processors
{
/// <summary>
/// Generates the C# implementation of the mock interfaces.
/// </summary>
class CSharpMocked : IDocumentProcessor
{
public string[] Languages { get; } = new[] { LanguageNames.CSharp };
Expand Down
40 changes: 0 additions & 40 deletions src/Moq/Moq.CodeFix/Processors/EnsureSdkReference.cs

This file was deleted.

3 changes: 3 additions & 0 deletions src/Moq/Moq.CodeFix/Processors/VisualBasicMocked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

namespace Moq.Processors
{
/// <summary>
/// Generates the VB implementation of the mock interfaces.
/// </summary>
class VisualBasicMocked : IDocumentProcessor
{
public string[] Languages { get; } = new[] { LanguageNames.VisualBasic };
Expand Down
2 changes: 1 addition & 1 deletion src/Moq/Moq.CodeFix/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Moq/Moq.CodeFix/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<value>Implement mock</value>
</data>
<data name="GenerateMockCodeFix_TitleFormat" xml:space="preserve">
<value>Generate {0}</value>
<value>Add {0} to project</value>
</data>
<data name="MissingMockAnalyzer_Description" xml:space="preserve">
<value>Invoked method requires a mock to be generated at design-time or compile-time.</value>
Expand Down
9 changes: 3 additions & 6 deletions src/Moq/Moq.Package/Moq.Package.nuproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(NuGetAuthoringPath)\NuGet.Packaging.Authoring.props" Condition="Exists('$(NuGetAuthoringPath)\NuGet.Packaging.Authoring.props')" />
<PropertyGroup Label="Globals">
Expand All @@ -21,13 +21,11 @@
<ProjectReference Include="..\Moq.CodeFix\Moq.CodeFix.csproj" />
<ProjectReference Include="..\Moq.Sdk\Moq.Sdk.csproj" />
<ProjectReference Include="..\Moq\Moq.csproj" />
<ProjectReference Include="..\..\Stunts\Stunts.Package\Stunts.Package.nuproj" />
<ProjectReference Include="..\..\Stunts\Stunts.Package\Stunts.Package.nuproj" IncludeAssets="all" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<Import Project="$(NuGetAuthoringPath)\NuGet.Packaging.Authoring.targets" Condition="Exists('$(NuGetAuthoringPath)\NuGet.Packaging.Authoring.targets')" />

<Target Name="FixPackageFileFramework" BeforeTargets="Pack" AfterTargets="$(GetPackageContents)"
Returns="@(_PackageContent)">
<Target Name="FixPackageFileFramework" BeforeTargets="Pack" AfterTargets="$(GetPackageContents)" Returns="@(_PackageContent)">
<ItemGroup>
<_PackageContent Condition="'%(Kind)' == 'Dependency'">
<TargetFrameworkMoniker>.NETStandard,Version=v2.0</TargetFrameworkMoniker>
Expand All @@ -36,5 +34,4 @@
</_PackageContent>
</ItemGroup>
</Target>

</Project>
43 changes: 0 additions & 43 deletions src/Moq/Moq.Sdk.Build.Tests/App.config

This file was deleted.

58 changes: 0 additions & 58 deletions src/Moq/Moq.Sdk.Build.Tests/GeneratorTests.cs

This file was deleted.

Loading