diff --git a/.gitignore b/.gitignore
index 1d48da87..c3f80cb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@ obj
*.log
*.binlog
*.rsp
-/src/Usage
\ No newline at end of file
+/src/Usage
+/src/Backup
diff --git a/NuGet.Config b/NuGet.Config
index 7d6789ea..a703d7f8 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -1,9 +1,6 @@
-
-
-
-
-
-
\ No newline at end of file
+
+
+
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 49459a6a..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-image: Visual Studio 2017
-
-init:
- - git config --global core.autocrlf input
-
-build_script:
- - cmd: echo /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" >> msbuild.rsp
- - cmd: msbuild /t:configure /p:configuration=release
- - cmd: msbuild /t:build /p:configuration=release
-
-nuget:
- disable_publish_on_pr: false
-
-artifacts:
- - path: out\*.nupkg
- name: Package
\ No newline at end of file
diff --git a/build.proj b/build.proj
index bf30d960..8e897f7f 100644
--- a/build.proj
+++ b/build.proj
@@ -24,7 +24,6 @@
-
diff --git a/src/Moq.sln b/src/Moq.sln
index 3bc24e01..e624ab5b 100644
--- a/src/Moq.sln
+++ b/src/Moq.sln
@@ -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
diff --git a/src/Moq/Moq.CodeAnalysis/MockDiagnostics.cs b/src/Moq/Moq.CodeAnalysis/MockDiagnostics.cs
index a920f2e7..ba543e85 100644
--- a/src/Moq/Moq.CodeAnalysis/MockDiagnostics.cs
+++ b/src/Moq/Moq.CodeAnalysis/MockDiagnostics.cs
@@ -1,4 +1,5 @@
-using Microsoft.CodeAnalysis;
+using System;
+using Microsoft.CodeAnalysis;
using Moq.Properties;
namespace Moq
@@ -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)));
@@ -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)));
}
diff --git a/src/Moq/Moq.CodeAnalysis/MockGeneratorAnalyzer.cs b/src/Moq/Moq.CodeAnalysis/MockGeneratorAnalyzer.cs
index 246a4af2..e775ef4b 100644
--- a/src/Moq/Moq.CodeAnalysis/MockGeneratorAnalyzer.cs
+++ b/src/Moq/Moq.CodeAnalysis/MockGeneratorAnalyzer.cs
@@ -1,6 +1,6 @@
-using Microsoft.CodeAnalysis;
+
+using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
-using Moq.Properties;
using Stunts;
namespace Moq
diff --git a/src/Moq/Moq.CodeAnalysis/MockNamingConvention.cs b/src/Moq/Moq.CodeAnalysis/MockNamingConvention.cs
index eb98664b..3218f73f 100644
--- a/src/Moq/Moq.CodeAnalysis/MockNamingConvention.cs
+++ b/src/Moq/Moq.CodeAnalysis/MockNamingConvention.cs
@@ -3,6 +3,10 @@
namespace Moq
{
+ ///
+ /// Customizes the code generation naming conventions for target namespace
+ /// and type suffix.
+ ///
public class MockNamingConvention : NamingConvention
{
public override string Namespace => MockNaming.Namespace;
diff --git a/src/Moq/Moq.CodeFix/CustomMockCodeFixProvider.cs b/src/Moq/Moq.CodeFix/CustomMockCodeFixProvider.cs
index 56d87491..2a1df8dd 100644
--- a/src/Moq/Moq.CodeFix/CustomMockCodeFixProvider.cs
+++ b/src/Moq/Moq.CodeFix/CustomMockCodeFixProvider.cs
@@ -13,10 +13,18 @@
namespace Moq
{
+ ///
+ /// Custom mocks allow manually creating classes that implement IMocked and the
+ /// behavior pipeline from the base stunt too. It allows to manually create mocks.
+ ///
[ExportCodeFixProvider(LanguageNames.CSharp, LanguageNames.VisualBasic, Name = "CustomMock")]
[ExtensionOrder(Before = "ImplementInterface")]
public class CustomMockCodeFixProvider : CodeFixProvider
{
+ ///
+ /// We fixup the implementation of abstract and interface members by forwarding
+ /// the implementations through the behavior pipeline.
+ ///
public override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create(
// See http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp.Features/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs,15
"CS0534",
diff --git a/src/Moq/Moq.CodeFix/MockGenerator.cs b/src/Moq/Moq.CodeFix/MockGenerator.cs
index d30839d2..4b78d0dd 100644
--- a/src/Moq/Moq.CodeFix/MockGenerator.cs
+++ b/src/Moq/Moq.CodeFix/MockGenerator.cs
@@ -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())
diff --git a/src/Moq/Moq.CodeFix/Moq.CodeFix.csproj b/src/Moq/Moq.CodeFix/Moq.CodeFix.csproj
index e06f9807..f7565100 100644
--- a/src/Moq/Moq.CodeFix/Moq.CodeFix.csproj
+++ b/src/Moq/Moq.CodeFix/Moq.CodeFix.csproj
@@ -31,6 +31,20 @@
+
+ PreserveNewest
+ $(PrimaryOutputKind)
+ true
+ true
+ %(Filename)%(Extension)
+ false
+
+
+ PreserveNewest
+ true
+ $(PrimaryOutputKind)
+ true
+
PreserveNewest
$(PrimaryOutputKind)
diff --git a/src/Moq/Moq.CodeFix/Moq.props b/src/Moq/Moq.CodeFix/Moq.props
new file mode 100644
index 00000000..3a54ed03
--- /dev/null
+++ b/src/Moq/Moq.CodeFix/Moq.props
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Moq/Moq.CodeFix/Moq.targets b/src/Moq/Moq.CodeFix/Moq.targets
index 8c504e72..d0d20592 100644
--- a/src/Moq/Moq.CodeFix/Moq.targets
+++ b/src/Moq/Moq.CodeFix/Moq.targets
@@ -1,12 +1,10 @@
-
-
-
+
+
+
+ Mocks/%(Filename)%(Extension)
+ false
+
+
\ No newline at end of file
diff --git a/src/Moq/Moq.CodeFix/Processors/CSharpMocked.cs b/src/Moq/Moq.CodeFix/Processors/CSharpMocked.cs
index 53c1783f..dd8be342 100644
--- a/src/Moq/Moq.CodeFix/Processors/CSharpMocked.cs
+++ b/src/Moq/Moq.CodeFix/Processors/CSharpMocked.cs
@@ -11,6 +11,9 @@
namespace Moq.Processors
{
+ ///
+ /// Generates the C# implementation of the mock interfaces.
+ ///
class CSharpMocked : IDocumentProcessor
{
public string[] Languages { get; } = new[] { LanguageNames.CSharp };
diff --git a/src/Moq/Moq.CodeFix/Processors/EnsureSdkReference.cs b/src/Moq/Moq.CodeFix/Processors/EnsureSdkReference.cs
deleted file mode 100644
index f8ec504a..00000000
--- a/src/Moq/Moq.CodeFix/Processors/EnsureSdkReference.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Moq.Properties;
-using Moq.Sdk;
-using Stunts;
-
-namespace Moq.Processors
-{
- class EnsureSdkReference : IDocumentProcessor
- {
- static readonly string MoqSdkAssembly = typeof(IMock).Assembly.GetName().Name;
- static readonly string MoqSdkFile = Path.GetFileName(typeof(IMock).Assembly.ManifestModule.FullyQualifiedName);
-
- public string[] Languages { get; } = new[] { LanguageNames.CSharp, LanguageNames.VisualBasic };
-
- public ProcessorPhase Phase => ProcessorPhase.Prepare;
-
- public Task ProcessAsync(Document document, CancellationToken cancellationToken = default)
- {
- // TODO: throwing doesn't seem useful at all here.
- // Maybe we should have another analyzer that reports at a different level (compilation, semantic?).
- // But maybe the whole scenario is moot since the analyzer will come from Moq itself which will bring in the SDK, so...
-
- // Moq must either be a direct metadata/assembly reference
- if (!document.Project.MetadataReferences.Any(r => r.Display.EndsWith(MoqSdkFile, StringComparison.Ordinal)) &&
- // or a resolved project reference to the Stunts project (if someone is using it as source/submodule
- !document.Project.ProjectReferences.Select(r => document.Project.Solution.GetProject(r.ProjectId)?.AssemblyName)
- .Any(n => MoqSdkAssembly.Equals(n, StringComparison.Ordinal)))
- {
- throw new ArgumentException(Strings.MoqRequired(document.Project.Name));
- }
-
- return Task.FromResult(document);
- }
- }
-}
diff --git a/src/Moq/Moq.CodeFix/Processors/VisualBasicMocked.cs b/src/Moq/Moq.CodeFix/Processors/VisualBasicMocked.cs
index 566c0783..6af488a4 100644
--- a/src/Moq/Moq.CodeFix/Processors/VisualBasicMocked.cs
+++ b/src/Moq/Moq.CodeFix/Processors/VisualBasicMocked.cs
@@ -12,6 +12,9 @@
namespace Moq.Processors
{
+ ///
+ /// Generates the VB implementation of the mock interfaces.
+ ///
class VisualBasicMocked : IDocumentProcessor
{
public string[] Languages { get; } = new[] { LanguageNames.VisualBasic };
diff --git a/src/Moq/Moq.CodeFix/Properties/Resources.Designer.cs b/src/Moq/Moq.CodeFix/Properties/Resources.Designer.cs
index 5c06bfaa..abdda99f 100644
--- a/src/Moq/Moq.CodeFix/Properties/Resources.Designer.cs
+++ b/src/Moq/Moq.CodeFix/Properties/Resources.Designer.cs
@@ -79,7 +79,7 @@ internal static string CustomMockCodeFix_Implement {
}
///
- /// Looks up a localized string similar to Generate {0}.
+ /// Looks up a localized string similar to Add {0} to project.
///
internal static string GenerateMockCodeFix_TitleFormat {
get {
diff --git a/src/Moq/Moq.CodeFix/Properties/Resources.resx b/src/Moq/Moq.CodeFix/Properties/Resources.resx
index 760b6388..1bf8b403 100644
--- a/src/Moq/Moq.CodeFix/Properties/Resources.resx
+++ b/src/Moq/Moq.CodeFix/Properties/Resources.resx
@@ -124,7 +124,7 @@
Implement mock
- Generate {0}
+ Add {0} to project
Invoked method requires a mock to be generated at design-time or compile-time.
diff --git a/src/Moq/Moq.Package/Moq.Package.nuproj b/src/Moq/Moq.Package/Moq.Package.nuproj
index 9bad76ae..7841cdea 100644
--- a/src/Moq/Moq.Package/Moq.Package.nuproj
+++ b/src/Moq/Moq.Package/Moq.Package.nuproj
@@ -1,4 +1,4 @@
-
+
@@ -21,13 +21,11 @@
-
+
-
-
+
<_PackageContent Condition="'%(Kind)' == 'Dependency'">
.NETStandard,Version=v2.0
@@ -36,5 +34,4 @@
-
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Build.Tests/App.config b/src/Moq/Moq.Sdk.Build.Tests/App.config
deleted file mode 100644
index fb1376a7..00000000
--- a/src/Moq/Moq.Sdk.Build.Tests/App.config
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Build.Tests/GeneratorTests.cs b/src/Moq/Moq.Sdk.Build.Tests/GeneratorTests.cs
deleted file mode 100644
index 942fa247..00000000
--- a/src/Moq/Moq.Sdk.Build.Tests/GeneratorTests.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using System.Collections.Immutable;
-using System.ComponentModel;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Moq.Proxy;
-using Moq.Sdk;
-using Xunit;
-using Xunit.Abstractions;
-using static TestHelpers;
-
-namespace Moq.Tests
-{
- public class GeneratorTests
- {
- ITestOutputHelper output;
-
- public GeneratorTests(ITestOutputHelper output) => this.output = output;
-
- [InlineData(LanguageNames.CSharp)]
- [Theory(Skip = "Manual Testing")]
- public async Task GeneratesAdditionalStuff(string languageName)
- {
- var workspace = new AdhocWorkspace(ProxyGenerator.CreateHost(typeof(CSharpMockGenerator).Assembly));
- var projectInfo = CreateProjectInfo(languageName, "code");
- var project = workspace.AddProject(projectInfo);
- var compilation = await project.GetCompilationAsync(TimeoutToken(5));
-
- var typeToProxy = compilation.GetTypeByMetadataName(typeof(INotifyPropertyChanged).FullName);
- var document = await new ProxyGenerator().GenerateProxyAsync(workspace, project, TimeoutToken(5),
- new ITypeSymbol[]
- {
- compilation.GetTypeByMetadataName(typeof(INotifyPropertyChanged).FullName),
- compilation.GetTypeByMetadataName(typeof(INotifyPropertyChanging).FullName),
- }.ToImmutableArray(),
- new ITypeSymbol[]
- {
- compilation.GetTypeByMetadataName(typeof(IMocked).FullName),
- }.ToImmutableArray());
-
- await AssertCode.NoErrorsAsync(document);
-
-#if DEBUG
- output.WriteLine((await document.GetSyntaxRootAsync()).NormalizeWhitespace().ToString());
-#endif
-
- //var assembly = compilation.Emit();
- //var proxyType = assembly.GetExportedTypes().FirstOrDefault();
-
- //Assert.NotNull(proxyType);
- //Assert.True(typeof(IDisposable).IsAssignableFrom(proxyType));
- //Assert.False(proxyType.FullName.Contains(nameof(IDisposable)),
- // $"Generated proxy should not contain the additional type {nameof(IDisposable)} in its name.");
- }
-
- }
-}
diff --git a/src/Moq/Moq.Sdk.Build.Tests/Misc.cs b/src/Moq/Moq.Sdk.Build.Tests/Misc.cs
deleted file mode 100644
index 41178aa2..00000000
--- a/src/Moq/Moq.Sdk.Build.Tests/Misc.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System.ComponentModel;
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using Moq.Proxy;
-using System.Runtime.CompilerServices;
-
-[CompilerGeneratedAttribute]
-public partial class INotifyPropertyChangedINotifyPropertyChangingProxy : INotifyPropertyChanged, INotifyPropertyChanging, IProxy
-{
- BehaviorPipeline pipeline = new BehaviorPipeline();
- public event PropertyChangedEventHandler PropertyChanged
- {
- add
- {
- pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value));
- propertyChanged = ((PropertyChangedEventHandler)(Delegate.Combine(propertyChanged, value)));
- }
-
- remove
- {
- pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value));
- propertyChanged = ((PropertyChangedEventHandler)(Delegate.Remove(propertyChanged, value)));
- }
- }
-
- public event PropertyChangingEventHandler PropertyChanging
- {
- add
- {
- pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value));
- propertyChanging = ((PropertyChangingEventHandler)(Delegate.Combine(propertyChanging, value)));
- }
-
- remove
- {
- pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value));
- propertyChanging = ((PropertyChangingEventHandler)(Delegate.Remove(propertyChanging, value)));
- }
- }
-
- IList IProxy.Behaviors => pipeline.Behaviors;
- PropertyChangedEventHandler propertyChanged;
- PropertyChangingEventHandler propertyChanging;
-
- delegate void ChotaHanlder(string name, int index);
-
- public Delegate GetEvent(string eventName)
- {
- switch (eventName)
- {
- case nameof(PropertyChanged):
- return propertyChanged;
- case nameof(PropertyChanging):
- return propertyChanging;
- default:
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Build.Tests/Moq.Sdk.Build.Tests.csproj b/src/Moq/Moq.Sdk.Build.Tests/Moq.Sdk.Build.Tests.csproj
deleted file mode 100644
index bf492d06..00000000
--- a/src/Moq/Moq.Sdk.Build.Tests/Moq.Sdk.Build.Tests.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- net461
- true
- true
- 42415884-4ef7-4c04-8a1d-0faf032e4767
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Generator/CSharpMocked.cs b/src/Moq/Moq.Sdk.Generator/CSharpMocked.cs
deleted file mode 100644
index 6aca4139..00000000
--- a/src/Moq/Moq.Sdk.Generator/CSharpMocked.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Moq.Proxy;
-using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Moq.Sdk
-{
- [ExportLanguageService(typeof(IDocumentVisitor), LanguageNames.CSharp, DocumentVisitorLayer.Fixup)]
- public class CSharpMocked : CSharpSyntaxRewriter, IDocumentVisitor
- {
- SyntaxGenerator generator;
-
- public async Task VisitAsync(Document document, CancellationToken cancellationToken = default(CancellationToken))
- {
- var hasSdk = document.Project.MetadataReferences.Any(x => x.Display.EndsWith("Moq.Sdk.dll")) ||
- document.Project.ProjectReferences.Select(x => document.Project.Solution.GetProject(x.ProjectId).AssemblyName).Any(x => x == "Moq.Sdk");
-
- // Only apply the Moq visitor if the project actually contains a Moq.Sdk reference.
- if (!hasSdk)
- return document;
-
- generator = SyntaxGenerator.GetGenerator(document);
- var syntax = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- syntax = Visit(syntax);
-
- return document.WithSyntaxRoot(syntax);
- }
-
- public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
- => base.VisitCompilationUnit(node.AddUsings(
- UsingDirective(IdentifierName(typeof(LazyInitializer).Namespace)),
- UsingDirective(IdentifierName(typeof(IMocked).Namespace))));
-
- public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
- {
- var result = generator.AddInterfaceType(
- base.VisitClassDeclaration(node),
- generator.IdentifierName(nameof(IMocked)));
-
- result = generator.AddMembers(result,
- generator.FieldDeclaration("mock", ParseTypeName(nameof(IMock)))
- // #region IMocked
- .WithLeadingTrivia(
- CarriageReturnLineFeed,
- Trivia(RegionDirectiveTrivia(true)
- .WithRegionKeyword(Token(
- TriviaList(),
- SyntaxKind.RegionKeyword,
- TriviaList(Space)))
- .WithEndOfDirectiveToken(Token(
- TriviaList(PreprocessingMessage(nameof(IMocked))),
- SyntaxKind.EndOfDirectiveToken,
- TriviaList(CarriageReturnLineFeed))
- )
- )
- )
- );
-
- var prop = PropertyDeclaration(IdentifierName(nameof(IMock)), nameof(IMocked.Mock))
- // Make IMocked properties explicit.
- .WithExplicitInterfaceSpecifier(
- ExplicitInterfaceSpecifier(
- IdentifierName(nameof(IMocked))))
- .WithModifiers(TokenList())
- // => LazyInitializer.EnsureInitialized(ref mock, () => new MockInfo(pipeline.Behaviors));
- .WithExpressionBody(ArrowExpressionClause(
- InvocationExpression(
- MemberAccessExpression(
- SyntaxKind.SimpleMemberAccessExpression,
- IdentifierName(nameof(LazyInitializer)),
- IdentifierName(nameof(LazyInitializer.EnsureInitialized))),
- ArgumentList(SeparatedList(new ArgumentSyntax[]
- {
- Argument(RefExpression(IdentifierName("mock"))),
- Argument(ParenthesizedLambdaExpression(
- ObjectCreationExpression(
- IdentifierName(nameof(MockInfo)))
- .WithArgumentList(ArgumentList(SingletonSeparatedList(Argument(
- ThisExpression()
- ))))
- ))
- }))
- )
- ))
- .WithSemicolonToken(Token(SyntaxKind.SemicolonToken))
- // #endregion
- .WithTrailingTrivia(
- CarriageReturnLineFeed,
- Trivia(EndRegionDirectiveTrivia(false)),
- CarriageReturnLineFeed);
-
- result = generator.AddMembers(result, prop);
-
- return result;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Build.props b/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Build.props
deleted file mode 100644
index 0dfb6a31..00000000
--- a/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Build.props
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Build.targets b/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Build.targets
deleted file mode 100644
index 4220c43f..00000000
--- a/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Build.targets
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Generator.csproj b/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Generator.csproj
deleted file mode 100644
index 91b1b228..00000000
--- a/src/Moq/Moq.Sdk.Generator/Moq.Sdk.Generator.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- net461
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Generator/Readme.txt b/src/Moq/Moq.Sdk.Generator/Readme.txt
deleted file mode 100644
index 46c661d8..00000000
--- a/src/Moq/Moq.Sdk.Generator/Readme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-This project contains the VB and C# document visitors that inject the
-IMocked interface and implementation into the generated proxies.
-
-This is a great example too on how to extend the proxy generation from
-third-parties.
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk.Generator/VisualBasicMocked.cs b/src/Moq/Moq.Sdk.Generator/VisualBasicMocked.cs
deleted file mode 100644
index f9dd432c..00000000
--- a/src/Moq/Moq.Sdk.Generator/VisualBasicMocked.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.VisualBasic;
-using Microsoft.CodeAnalysis.VisualBasic.Syntax;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Moq.Proxy;
-using static Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory;
-using System;
-using System.Linq;
-
-namespace Moq.Sdk
-{
- [ExportLanguageService(typeof(IDocumentVisitor), LanguageNames.VisualBasic, DocumentVisitorLayer.Fixup)]
- public class VisualBasicMocked : VisualBasicSyntaxRewriter, IDocumentVisitor
- {
- SyntaxGenerator generator;
-
- public async Task VisitAsync(Document document, CancellationToken cancellationToken = default(CancellationToken))
- {
- var hasSdk = document.Project.MetadataReferences.Any(x => x.Display.EndsWith("Moq.Sdk.dll")) ||
- document.Project.ProjectReferences.Select(x => document.Project.Solution.GetProject(x.ProjectId).AssemblyName).Any(x => x == "Moq.Sdk");
-
- // Only apply the Moq visitor if the project actually contains a Moq.Sdk reference.
- if (!hasSdk)
- return document;
-
- generator = SyntaxGenerator.GetGenerator(document);
- var syntax = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- syntax = Visit(syntax);
-
- return document.WithSyntaxRoot(syntax);
- }
-
- public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
- => base.VisitCompilationUnit(node.AddImports(
- ImportsStatement(SingletonSeparatedList(SimpleImportsClause(IdentifierName(typeof(LazyInitializer).Namespace)))),
- ImportsStatement(SingletonSeparatedList(SimpleImportsClause(IdentifierName(typeof(IMocked).Namespace))))));
-
- public override SyntaxNode VisitClassBlock(ClassBlockSyntax node)
- {
- var result = generator.AddInterfaceType(
- base.VisitClassBlock(node),
- generator.IdentifierName(nameof(IMocked)));
-
- result = generator.AddMembers(result,
- generator.FieldDeclaration("_mock", ParseTypeName(nameof(IMock)))
- .WithLeadingTrivia(Whitespace(Environment.NewLine)));
-
- var property = (PropertyBlockSyntax)generator.PropertyDeclaration(
- nameof(IMocked.Mock),
- ParseTypeName(nameof(IMock)),
- modifiers: DeclarationModifiers.ReadOnly,
- getAccessorStatements: new[]
- {
- generator.ReturnStatement(
- generator.InvocationExpression(
- generator.MemberAccessExpression(
- generator.IdentifierName(nameof(LazyInitializer)),
- nameof(LazyInitializer.EnsureInitialized)),
- generator.Argument(
- RefKind.Ref,
- generator.IdentifierName("_mock")),
- ParenthesizedExpression(
- SingleLineFunctionLambdaExpression(
- FunctionLambdaHeader(List(), TokenList(), ParameterList(), null),
- ObjectCreationExpression(
- List(),
- IdentifierName(nameof(MockInfo)),
- ArgumentList(SingletonSeparatedList(
- SimpleArgument(MeExpression())
- )),
- null
- )
- )
- )
- )
- )
- });
-
- property = property.WithPropertyStatement(
- property.PropertyStatement.WithImplementsClause(
- ImplementsClause(QualifiedName(IdentifierName(nameof(IMocked)), IdentifierName(nameof(IMocked.Mock))))));
-
- result = generator.AddMembers(result, property);
-
- return result;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Moq/Moq.Sdk/IMocked.cs b/src/Moq/Moq.Sdk/IMocked.cs
index 8ed6909f..3392a811 100644
--- a/src/Moq/Moq.Sdk/IMocked.cs
+++ b/src/Moq/Moq.Sdk/IMocked.cs
@@ -8,7 +8,9 @@ namespace Moq.Sdk
/// the interface for introspecting
/// a mock instance.
///
- [GeneratedCode("Moq", ThisAssembly.Project.Properties.AssemblyVersion)] // This attribute prevents registering the "Implement through behavior pipeline" codefix.
+ // These attributes prevent registering the "Implement through behavior pipeline" codefix.
+ // See CustomMockCodeFixProvider and its base class CustomStuntCodeFixProvider.
+ [GeneratedCode("Moq", ThisAssembly.Metadata.Version)]
[CompilerGenerated]
public interface IMocked
{
diff --git a/src/Moq/Moq.Tests/Moq.Tests.csproj b/src/Moq/Moq.Tests/Moq.Tests.csproj
index 86a16b96..f2f08457 100644
--- a/src/Moq/Moq.Tests/Moq.Tests.csproj
+++ b/src/Moq/Moq.Tests/Moq.Tests.csproj
@@ -9,7 +9,7 @@
false
-
+
diff --git a/src/Moq/Moq/contentFiles/cs/netstandard2.0/Mock.Overloads.cs b/src/Moq/Moq/contentFiles/cs/netstandard2.0/Mocks/Mock.Overloads.cs
similarity index 100%
rename from src/Moq/Moq/contentFiles/cs/netstandard2.0/Mock.Overloads.cs
rename to src/Moq/Moq/contentFiles/cs/netstandard2.0/Mocks/Mock.Overloads.cs
diff --git a/src/Moq/Moq/contentFiles/cs/netstandard2.0/Mock.cs b/src/Moq/Moq/contentFiles/cs/netstandard2.0/Mocks/Mock.cs
similarity index 69%
rename from src/Moq/Moq/contentFiles/cs/netstandard2.0/Mock.cs
rename to src/Moq/Moq/contentFiles/cs/netstandard2.0/Mocks/Mock.cs
index b9d1860d..3aabbfef 100644
--- a/src/Moq/Moq/contentFiles/cs/netstandard2.0/Mock.cs
+++ b/src/Moq/Moq/contentFiles/cs/netstandard2.0/Mocks/Mock.cs
@@ -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;
+
///
/// Instantiates mocks for the specified types.
///
+ [GeneratedCode("Stunts", "5.0")]
partial class Mock
{
///
/// Creates the mock instance by using the specified types to
/// lookup the mock type in the assembly defining this class.
///
- static T Create(MockBehavior behavior, object[] constructorArgs, params Type[] interfaces)
+ private static T Create(MockBehavior behavior, object[] constructorArgs, params Type[] interfaces)
{
var mocked = (IMocked)MockFactory.Default.CreateMock(typeof(Mock).GetTypeInfo().Assembly, typeof(T), interfaces, constructorArgs);
diff --git a/src/Moq/Moq/contentFiles/vb/netstandard2.0/Mock.Overloads.vb b/src/Moq/Moq/contentFiles/vb/netstandard2.0/Mocks/Mock.Overloads.vb
similarity index 100%
rename from src/Moq/Moq/contentFiles/vb/netstandard2.0/Mock.Overloads.vb
rename to src/Moq/Moq/contentFiles/vb/netstandard2.0/Mocks/Mock.Overloads.vb
diff --git a/src/Moq/Moq/contentFiles/vb/netstandard2.0/Mock.vb b/src/Moq/Moq/contentFiles/vb/netstandard2.0/Mocks/Mock.vb
similarity index 89%
rename from src/Moq/Moq/contentFiles/vb/netstandard2.0/Mock.vb
rename to src/Moq/Moq/contentFiles/vb/netstandard2.0/Mocks/Mock.vb
index 3bf1b5bb..0c8c5261 100644
--- a/src/Moq/Moq/contentFiles/vb/netstandard2.0/Mock.vb
+++ b/src/Moq/Moq/contentFiles/vb/netstandard2.0/Mocks/Mock.vb
@@ -1,10 +1,12 @@
Option Strict On
+Imports System.CodeDom.Compiler
Imports System.Reflection
Imports Moq.Sdk
Namespace Global.Moq
+
Partial Friend Class Mock
Private Shared Function Create(Of T)(ByVal behavior As MockBehavior, ByVal constructorArgs As Object(), ParamArray interfaces As Type()) As T
diff --git a/src/Samples/Directory.Build.props b/src/Samples/Directory.Build.props
index 994aebec..e017dd40 100644
--- a/src/Samples/Directory.Build.props
+++ b/src/Samples/Directory.Build.props
@@ -3,5 +3,6 @@
$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .gitignore))\
$(RootPath)bin\$(Configuration)\
+ true
\ No newline at end of file
diff --git a/src/Samples/Moq.CSharp/Moq.CSharp.csproj b/src/Samples/Moq.CSharp/Moq.CSharp.csproj
index 6e483998..cfbfdb36 100644
--- a/src/Samples/Moq.CSharp/Moq.CSharp.csproj
+++ b/src/Samples/Moq.CSharp/Moq.CSharp.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/Samples/Moq.CSharp/Recursive.cs b/src/Samples/Moq.CSharp/Recursive.cs
index 871a0988..af179fff 100644
--- a/src/Samples/Moq.CSharp/Recursive.cs
+++ b/src/Samples/Moq.CSharp/Recursive.cs
@@ -17,6 +17,9 @@ public void FieldTest()
calculator.Setup(m => m.Memory.Recall()).Returns(5);
var c = Mock.Of();
+ c.Recall("foo").Returns(5);
+
+
c.Setup(x => x.Store("foo", 5));
}
}
diff --git a/src/Samples/Moq.VisualBasic/Moq.VisualBasic.vbproj b/src/Samples/Moq.VisualBasic/Moq.VisualBasic.vbproj
index a938fb84..cf893431 100644
--- a/src/Samples/Moq.VisualBasic/Moq.VisualBasic.vbproj
+++ b/src/Samples/Moq.VisualBasic/Moq.VisualBasic.vbproj
@@ -5,7 +5,7 @@
-
+
My Project\%(Filename)%(Extension)
false
diff --git a/src/Samples/Stunts.CSharp/Class1.cs b/src/Samples/Stunts.CSharp/Class1.cs
index a1655ee4..00cb522d 100644
--- a/src/Samples/Stunts.CSharp/Class1.cs
+++ b/src/Samples/Stunts.CSharp/Class1.cs
@@ -2,6 +2,7 @@
using Sample;
using System.Linq;
using Stunts;
+using System.Reflection;
public class Tests
{
@@ -29,13 +30,43 @@ public void WhenFakingFormatterThenCanInvokeIt()
Console.WriteLine(result1);
Console.WriteLine(result2);
- var foo = Stunt.Of();
+ var bar = Stunt.Of();
+ }
+
+ public void when_using_custom_generator()
+ {
+ var ping = Randomizer.Of();
+
+ Console.WriteLine(ping.Ping());
+ Console.WriteLine(ping.Ping());
}
}
+public interface IPing
+{
+ int Ping();
+}
+
+public static class Randomizer
+{
+ static readonly Random random = new Random();
+
+ [StuntGenerator]
+ public static T Of()
+ => Stunt.Of()
+ .AddBehavior(
+ (invocation, next) => invocation.CreateValueReturn(random.Next()),
+ invocation => invocation.MethodBase is MethodInfo info && info.ReturnType == typeof(int));
+}
+
+
+
namespace Sample
{
- public interface IBar { }
+ public interface IBar
+ {
+ void Bar();
+ }
public interface IFoo
{
diff --git a/src/Samples/Stunts.CSharp/MyClass.cs b/src/Samples/Stunts.CSharp/MyClass.cs
new file mode 100644
index 00000000..c264a8f5
--- /dev/null
+++ b/src/Samples/Stunts.CSharp/MyClass.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Reflection;
+
+using Stunts;
+
+public class MyBase { }
+
+public class MyClassTest
+{
+ public void Configure()
+ {
+ // var instance = new MyClass();
+
+ var cloneable = Stunt.Of();
+
+ }
+}
+
+public class MyClass : IDisposable, IStunt
+{
+ private readonly BehaviorPipeline pipeline = new BehaviorPipeline();
+
+ ObservableCollection IStunt.Behaviors => pipeline.Behaviors;
+
+ public void Dispose() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+}
+
+//[CompilerGenerated]
+//public override bool Equals(object obj) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), obj));
+//[CompilerGenerated]
+//public override int GetHashCode() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+//[CompilerGenerated]
+//public override string ToString() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
diff --git a/src/Samples/Stunts.CSharp/MyProxy.cs b/src/Samples/Stunts.CSharp/MyProxy.cs
new file mode 100644
index 00000000..9e383192
--- /dev/null
+++ b/src/Samples/Stunts.CSharp/MyProxy.cs
@@ -0,0 +1,34 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using Sample;
+using Stunts;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+public class MyProxy : IDisposable, IBar, IStunt
+{
+ readonly BehaviorPipeline pipeline = new BehaviorPipeline();
+
+ [CompilerGenerated]
+ ObservableCollection IStunt.Behaviors => pipeline.Behaviors;
+
+ [CompilerGenerated]
+ public void Bar() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+ [CompilerGenerated]
+ public void Dispose() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+ [CompilerGenerated]
+ public override bool Equals(object obj) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), obj));
+ [CompilerGenerated]
+ public override int GetHashCode() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+ [CompilerGenerated]
+ public override string ToString() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+}
diff --git a/src/Samples/Stunts.CSharp/Stunts.CSharp.csproj b/src/Samples/Stunts.CSharp/Stunts.CSharp.csproj
index 10413e5a..5b8edb57 100644
--- a/src/Samples/Stunts.CSharp/Stunts.CSharp.csproj
+++ b/src/Samples/Stunts.CSharp/Stunts.CSharp.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/Samples/Stunts.CSharp/Stunts/IBarStunt.cs b/src/Samples/Stunts.CSharp/Stunts/IBarStunt.cs
index b7ee2828..6f977eb8 100644
--- a/src/Samples/Stunts.CSharp/Stunts/IBarStunt.cs
+++ b/src/Samples/Stunts.CSharp/Stunts/IBarStunt.cs
@@ -23,6 +23,8 @@ public partial class IBarStunt : IBar, IStunt
[CompilerGenerated]
ObservableCollection IStunt.Behaviors => pipeline.Behaviors;
+ [CompilerGenerated]
+ public void Bar() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
[CompilerGenerated]
public override bool Equals(object obj) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), obj));
[CompilerGenerated]
diff --git a/src/Samples/Stunts.CSharp/Stunts/ICalculatorStunt.cs b/src/Samples/Stunts.CSharp/Stunts/ICalculatorStunt.cs
new file mode 100644
index 00000000..00b0431a
--- /dev/null
+++ b/src/Samples/Stunts.CSharp/Stunts/ICalculatorStunt.cs
@@ -0,0 +1,72 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using Sample;
+using System;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using Stunts;
+using System.Runtime.CompilerServices;
+
+namespace Stunts
+{
+ public partial class ICalculatorStunt : ICalculator, IStunt
+ {
+ readonly BehaviorPipeline pipeline = new BehaviorPipeline();
+
+ [CompilerGenerated]
+ ObservableCollection IStunt.Behaviors => pipeline.Behaviors;
+
+ [CompilerGenerated]
+ public int? this[string name] { get => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), name)); set => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), name, value)); }
+
+ [CompilerGenerated]
+ public bool IsOn => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+
+ [CompilerGenerated]
+ public CalculatorMode Mode { get => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod())); set => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value)); }
+
+ [CompilerGenerated]
+ public ICalculatorMemory Memory => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+
+ [CompilerGenerated]
+ public int Add(int x, int y) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), x, y));
+ [CompilerGenerated]
+ public int Add(int x, int y, int z) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), x, y, z));
+ [CompilerGenerated]
+ public void Clear(string name) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), name));
+ [CompilerGenerated]
+ public override bool Equals(object obj) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), obj));
+ [CompilerGenerated]
+ public override int GetHashCode() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+ [CompilerGenerated]
+ public int? Recall(string name) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), name));
+ [CompilerGenerated]
+ public void Store(string name, int value) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), name, value));
+ [CompilerGenerated]
+ public override string ToString() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+
+ [CompilerGenerated]
+ public bool TryAdd(ref int x, ref int y, out int z)
+ {
+ z = default(int);
+ var returns = pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), x, y, z));
+ x = (int)returns.Outputs["x"];
+ y = (int)returns.Outputs["y"];
+ z = (int)returns.Outputs["z"];
+ return (bool)returns.ReturnValue;
+ }
+
+ [CompilerGenerated]
+ public void TurnOn() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));
+
+ [CompilerGenerated]
+ public event EventHandler TurnedOn { add => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value)); remove => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value)); }
+ }
+}
\ No newline at end of file
diff --git a/src/Samples/Stunts.CSharp/Stunts/ICloneableStunt.cs b/src/Samples/Stunts.CSharp/Stunts/ICloneableStunt.cs
new file mode 100644
index 00000000..a7300c7b
--- /dev/null
+++ b/src/Samples/Stunts.CSharp/Stunts/ICloneableStunt.cs
@@ -0,0 +1,34 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using Stunts;
+using System.Runtime.CompilerServices;
+
+namespace Stunts
+{
+ public partial class ICloneableStunt : ICloneable, IStunt
+ {
+ readonly BehaviorPipeline pipeline = new BehaviorPipeline();
+
+ [CompilerGenerated]
+ ObservableCollection IStunt.Behaviors => pipeline.Behaviors;
+
+ [CompilerGenerated]
+ public object Clone() => pipeline.Execute
+
\ No newline at end of file
diff --git a/src/build/Settings.props b/src/build/Settings.props
index c2a6648b..02990783 100644
--- a/src/build/Settings.props
+++ b/src/build/Settings.props
@@ -1,8 +1,15 @@
-
+
+
+ false
+ true
+
+
+ true
+ None
Latest
@@ -10,9 +17,12 @@
false
+ false
+
+ $(DefaultExcludeItems);*.binlog
true
- $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\'))
+ $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)..\..'))
true
@@ -27,13 +37,8 @@
-
-
-
-
-
-
+
diff --git a/src/build/Settings.targets b/src/build/Settings.targets
index 090848cf..2779c65f 100644
--- a/src/build/Settings.targets
+++ b/src/build/Settings.targets
@@ -24,7 +24,7 @@
-
diff --git a/src/build/Version.targets b/src/build/Version.targets
index d33f7780..d3c29a2e 100644
--- a/src/build/Version.targets
+++ b/src/build/Version.targets
@@ -5,52 +5,56 @@
true
-
+
+ SetVersions;$(GenerateNuspecDependsOn)
+ SetVersions;$(GetPackageVersionDependsOn)
+
+
+
+
-
+
+
-
- $([MSBuild]::Add('$(GitCommits)', '1'))
+ $(SYSTEM_PULLREQUEST_TARGETBRANCH)
+ $(BUILD_SOURCEBRANCHNAME)
-
-
-
+
+
+
+
+
+
+
+
-
-
- $(GitSemVerDashLabel)-pr$(BUILD_SOURCEBRANCH.Substring(10).TrimEnd('/merge'))
- $(GitSemVerDashLabel)-pr$(APPVEYOR_PULL_REQUEST_NUMBER)
-
-
- $(SYSTEM_PULLREQUEST_TARGETBRANCH)
- $(BUILD_SOURCEBRANCHNAME)
- $(APPVEYOR_REPO_BRANCH)
-
-
- <_IndexOfBranchSlash>$(GitBranch.LastIndexOf('/'))
- <_IndexOfBranchSubstring>$([MSBuild]::Add('$(_IndexOfBranchSlash)', '1'))
- <_GitBranch Condition="'$(_IndexOfBranchSlash)' != '0'">$(GitBranch.Substring($(_IndexOfBranchSubstring)))
- <_GitBranch Condition="'$(_IndexOfBranchSlash)' == '0'">$(GitBranch)
-
-
- $(_GitBranch).
- $(SemVerMetadata)g$(GitCommit)
-
-
- $(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(GitSemVerDashLabel).$(GitCommits)+$(SemVerMetadata)
-
- $(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)+$(SemVerMetadata)
- $(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)
- $(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)
- $(PackageVersion)
+ @(VersionMetadata -> '%(Identity)', '-')
+ +$(VersionMetadataLabel)
+ $(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(GitSemVerDashLabel)$(VersionMetadataPlusLabel)
+ $(PackageVersion)
+
+
+
+ <_Parameter1>Version
+ <_Parameter2>$(Version)
+
+
+ <_Parameter1>PackageVersion
+ <_Parameter2>$(PackageVersion)
+
+
+
\ No newline at end of file