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 1 commit
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
Prev Previous commit
Next Next commit
Add some missing docs, remove unused code
  • Loading branch information
kzu committed Sep 23, 2018
commit 67836532c6a747897240bbf2d41866f6328c456e
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
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
12 changes: 7 additions & 5 deletions src/Moq/Moq/contentFiles/cs/netstandard2.0/Mocks/Mock.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
using System;
using System.Reflection;
using Moq.Sdk;

namespace Moq
{
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using Moq.Sdk;

/// <summary>
/// Instantiates mocks for the specified types.
/// </summary>
[GeneratedCode("Stunts", "5.0")]
partial class Mock
{
/// <summary>
/// Creates the mock instance by using the specified types to
/// lookup the mock type in the assembly defining this class.
/// </summary>
static T Create<T>(MockBehavior behavior, object[] constructorArgs, params Type[] interfaces)
private static T Create<T>(MockBehavior behavior, object[] constructorArgs, params Type[] interfaces)
{
var mocked = (IMocked)MockFactory.Default.CreateMock(typeof(Mock).GetTypeInfo().Assembly, typeof(T), interfaces, constructorArgs);

Expand Down
2 changes: 2 additions & 0 deletions src/Moq/Moq/contentFiles/vb/netstandard2.0/Mocks/Mock.vb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Option Strict On

Imports System.CodeDom.Compiler
Imports System.Reflection
Imports Moq.Sdk

Namespace Global.Moq

<GeneratedCode("Stunts", "5.0")>
Partial Friend Class Mock

Private Shared Function Create(Of T)(ByVal behavior As MockBehavior, ByVal constructorArgs As Object(), ParamArray interfaces As Type()) As T
Expand Down

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

4 changes: 2 additions & 2 deletions src/Stunts/Stunts.CodeAnalysis/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@
<value>Generate all stunts in {0} {1}</value>
</data>
<data name="GenerateStuntCodeFix_Title" xml:space="preserve">
<value>Generate Stunt</value>
<value>Add Stunt</value>
</data>
<data name="GenerateStuntCodeFix_TitleFormat" xml:space="preserve">
<value>Generate {0}</value>
<value>Add {0} to {1}</value>
</data>
<data name="InvalidStuntTypes" xml:space="preserve">
<value>Only classes and interfaces can be used in stunts. Invalid set of symbols: {0}.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ namespace Stunts
// however, that the same reason the codefix isn't showing up when we ask for it, will cause that service to return
// an empty list of code actions too.
// It may be costly to investigate, and it doesn't seem like a core scenario anyway.
// Another workaround might be to let the user manually implement stunts/mocks and detect the presence of
// the IStunt interface and offer the rewriting codefix. This might be interesting too in general.
// It can be worked around by creating a custom mock.
// TODO: F#
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public class UnsupportedNestedTypeAnalyzer : DiagnosticAnalyzer
Expand Down
2 changes: 1 addition & 1 deletion src/Stunts/Stunts.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/Stunts/Stunts.CodeFix/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<value>Generate Stunt</value>
</data>
<data name="GenerateStuntCodeFix_TitleFormat" xml:space="preserve">
<value>Generate {0}</value>
<value>Add {0} to project</value>
</data>
<data name="InvalidStuntTypes" xml:space="preserve">
<value>Only classes and interfaces can be used in stunts. Invalid set of symbols: {0}.</value>
Expand Down
47 changes: 0 additions & 47 deletions src/Stunts/Stunts.Sdk/Processors/EnsureStuntsReference.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Stunts/Stunts.Sdk/StuntGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class StuntGenerator
/// </summary>
public static IDocumentProcessor[] GetDefaultProcessors() => new IDocumentProcessor[]
{
//new EnsureStuntsReference(),
new DefaultImports(),
new CSharpFileHeader(),
new CSharpScaffold(),
Expand Down
12 changes: 7 additions & 5 deletions src/Stunts/Stunts/contentFiles/cs/netstandard1.3/Stunts/Stunt.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using System;
using System.Reflection;

namespace Stunts
{
using System;
using System.CodeDom.Compiler;
using System.Reflection;

/// <summary>
/// Instantiates stunts for the specified types.
/// </summary>
[GeneratedCode("Stunts", "5.0")]
internal partial class Stunt
{
static T Create<T>(object[] constructorArgs, params Type[] interfaces) =>
private static T Create<T>(object[] constructorArgs, params Type[] interfaces) =>
(T)StuntFactory.Default.CreateStunt(typeof(Stunt).GetTypeInfo().Assembly, typeof(T), interfaces, constructorArgs);

/// <summary>
Expand Down Expand Up @@ -41,4 +43,4 @@ static T Create<T>(object[] constructorArgs, params Type[] interfaces) =>
[StuntGenerator]
public static T Of<T, T1, T2, T3, T4, T5, T6, T7, T8>(params object[] constructorArgs) => Create<T>(constructorArgs, typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Imports System
Imports System.CodeDom.Compiler
Imports System.Reflection

Namespace Global.Stunts

<GeneratedCode("Stunts", "5.0")>
Partial Friend Class Stunt

Private Shared Function Create(Of T)(ByVal constructorArgs As Object(), ParamArray interfaces As Type()) As T
Expand Down