I've created a SpecFlow Plugin following their page below. And have created a Generator Plugin as I needed to modify the auto generated code behind my features.
https://github.com/techtalk/SpecFlow/wiki/Plugins.
SpecFlowPlugin Code
[assembly: GeneratorPlugin(typeof(SpecFlowSpiraAdapterPlugin))]
namespace SpiraTest.SpecFlowPlugin
{
/// <summary>
/// A adapterpPlugin is needed to use a custom MSTest generator with SpecFlow.
/// </summary>
public class SpecFlowSpiraAdapterPlugin : IGeneratorPlugin
{
/// <summary>
/// By implementing the Initialize- Method on the IGeneratorPlugin interface, you get access to the GeneratorPluginEvents and GeneratorPluginParameters
/// </summary>
/// <param name="generatorPluginEvents"></param>
/// <param name="generatorPluginParameters"></param>
public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters)
{
generatorPluginEvents.CustomizeDependencies += GeneratorPluginEvents_CustomizeDependencies;
}
private void GeneratorPluginEvents_CustomizeDependencies(object sender, CustomizeDependenciesEventArgs e)
{
e.ObjectContainer.RegisterTypeAs<MSTestCustomGenerator, IUnitTestGeneratorProvider>();
}
}
}
Problem
I'm getting an error message when trying to run my tests indicating that i don't have the below attribute.
[assembly:RuntimePlugin] attribute
However I don't need that attribute as I have the [assembly: GeneratorPlugin] attribute instead.
No idea why it's saying that. Any ideas?
Message: Class Initialization method
MiJobsAdminPortal.UITests.Login.LoginFeature.FeatureSetup threw
exception. TechTalk.SpecFlow.SpecFlowException:
TechTalk.SpecFlow.SpecFlowException: Missing [assembly:RuntimePlugin]
attribute in SpiraTest.SpecFlowPlugin, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null. Please check
http://go.specflow.org/doc-plugins for details..
For SpecFlow every plugin is a Generator and a Runtime plugin, except you configure it otherwise. This is the code for that: https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow/Infrastructure/ContainerBuilder.cs#L127
As an example for configuration, have a look at the configuration of the SpecFlow+Excel plugin, which is also only a generator plugin.
<specFlow>
<plugins>
<add name="SpecFlow.Plus.Excel" type="Generator" />
</plugins>
</specFlow>
You have to specify the type as Generator. If not SpecFlow is always searching for both plugin types.
This behaviour is not documented, but is there since years. I will update the documentation in the next days.
Full disclosure: I am one of the maintainers of SpecFlow & SpecFlow+
Related
I'm trying to follow the code at the end of this video here, but I'm getting this error around the 1:11:10 mark:
error CS0310: 'MvxWpfSetup<App>' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TMvxSetup' in the generic type or method 'MvxSetupExtensions.RegisterSetupType<TMvxSetup>(object, params Assembly[])'
I really have no idea what code is relevant, but this is the file thats giving the error:
using MvvmCross.Core;
using MvvmCross.Platforms.Wpf.Core;
using MvvmCross.Platforms.Wpf.Views;
namespace MvxStarter.Wpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : MvxApplication
{
protected override void RegisterSetup()
{
this.RegisterSetupType<MvxWpfSetup<MvxStarter.Core.App>>();
}
}
}
I went over this whole section multiple times and I'm pretty certain I have exactly what he has. I even downloaded his source code, but I couldnt open the project so I copied and pasted all the code and I'm still getting this error. What should I do? I can post more relevant code if you tell me what to post. I have no idea what this error means and nothing I can find online about it makes any sense.
edit: I tried following the official documentation example project and I got the exact same error on the exact same line. Is something wrong with my installation?
https://www.mvvmcross.com/documentation/tutorials/tipcalc/the-core-project
https://www.mvvmcross.com/documentation/tutorials/tipcalc/a-wpf-ui-project
Need to create Setup class so code becomes.
using MvvmCross.Core;
using MvvmCross.Platforms.Wpf.Core;
using MvvmCross.Platforms.Wpf.Views;
namespace MvxStarter.Wpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : MvxApplication
{
protected override void RegisterSetup()
{
this.RegisterSetupType<Setup>();
}
}
}
Then Setup becomes
namespace MvxStarter.Wpf
{
public class Setup : MvxWpfSetup<Core.App>
{
protected override ILoggerProvider CreateLogProvider()
{
return new SerilogLoggerProvider();
}
protected override ILoggerFactory CreateLogFactory()
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.CreateLogger();
return new SerilogLoggerFactory();
}
}
}
or similar. This used Nuget Serilog as well as others.
I was running in to the same problem and found out it is due to breaking changes between MvvmCross 7 and MvvmCross8. In the video of Tim Corey version 7 is used.
Here is a link to the upgrade page: https://www.mvvmcross.com/documentation/upgrading/upgrade-to-mvvmcross-80
I want to add to ivie's answer that when using mvvmcross 8, you also need to add the attributes
[MvxContentPresentation]
[MvxViewFor(typeof(*YOURCLASSNAME*ViewModel))]
on top of the partial class in your corresponding view.
As shown on the TipsCalc example class on github
https://github.com/MvvmCross/MvvmCross-Samples/blob/master/TipCalc/TipCalc.WPF/Views/TipView.xaml.cs
I'm having an issue with RazorEngine (version 3.4.1.0).
I'm using Razor.Parse method with very simple template in a service that fires up every few minutes, and it works without any issues most of the times, but every now and then it throws this exception on me:
System.IO.FileNotFoundException:
Could not find file 'C:\Users\username\AppData\Local\Temp\cw3sv4yk.dll'.
File name: 'C:\Users\username\AppData\Local\Temp\cw3sv4yk.dll'
(cw3sv4yk is a randomly generated name)
Has anyone bumped into this issue before, and if so - any hints to what the solution would be?
Thanks,
Przemek
EDIT:
I've just noticed that I'm also getting this exception occasionally:
RazorEngine.Templating.TemplateCompilationException: Unable to compile
template. Metadata file
'c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll'
could not be opened -- 'The process cannot access the file because it
is being used by another process.'\n\nOther compilation errors may
have occurred. Check the Errors property for more information.
EDIT_2:
One more exception that's being thrown every now and then:
System.ArgumentException: Class name is required
Using an overloaded version of Razor.Parse method which caches templates solved the issue for us:
/// <summary>
/// Parses and returns the result of the specified string template.
/// </summary>
/// <typeparam name="T">The model type.</typeparam>
/// <param name="razorTemplate">The string template.</param>
/// <param name="model">The model instance.</param>
/// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
/// <returns>The string result of the template.</returns>
public static string Parse<T>(string razorTemplate, T model, string cacheName)
I'm using the current version of Sandcastle from Codeplex that is integrated with VS.NET 2012 to build a .cmh help file. The help file is being created, but I can't seem to ever get any of my <code> blocks to emit in the help file. I have the following easy example I keep working with:
/// <summary>
/// This is the summary
/// </summary>
/// <code>var s;</code>
public string SomeValue { get; set; }
When I look at the output .chm file, the var s; code is not present anywhere. I have done the following:
Added reference to Code Block Component in the Sandcastle project properties.
Tried making tag <code lang="C#">var s;</code> and <code language="C#">var s;</code> but neither made a difference.
Read documentation on the following sites detailing this process but to no avail:
https://www.simple-talk.com/dotnet/.net-tools/taming-sandcastle-a-.net-programmers-guide-to-documenting-your-code/
http://www.ewoodruff.us/shfbdocs/
The example is obviously a simplified version, but I'm just trying to get the basics work here. What am I doing incorrectly or missing?
I don't think the code tag is allowed to be by itself, try putting it inside an <example> tag, like <example><code>var s;</code></example>. So this should work:
/// <summary>
/// This is the summary
/// </summary>
/// <example>
/// <code>var s;</code>
/// </example>
public string SomeValue { get; set; }
The following test works fine with .Net 3.5 + NUnit 2.4.8. But the same tests does not work using .Net 4.0 + Nunit 2.5.7.10213.
/// <summary>
/// This test fails with unexpected exception:
/// System.InvalidCastException : Unable to cast object of type
/// 'System.Security.Principal.GenericPrincipal' to type
/// 'System.Security.Principal.WindowsPrincipal'.
/// </summary>
[Test]
public void GiventATest_WhenSettingDomainPrincipal_AccessingThreadcurrentPrincipalWorks()
{
AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal currentUserWindowsPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
}
The wierd thing is that after the test has failed once, I can run the tests again and it works until I reload the test assembly. And then, it fails again on the first attempt.
add this before your test:
NUnit.Core.TestContext.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
You will need to add a reference to NUnit.Core.dll if you do not have it already. Be aware that there are two classes TestContext, one in NUnit.Framework namespace and one in NUnit.Core namespace
Would you write xml-doc for a namespace? And if yes, how and where?
I would think, if it is possible, maybe an almost empty file like this:
/// <summary>
/// This namespace contains stuff
/// </summary>
namespace Some.Namespace
{
}
But will that work? Since you... "declare", or at least use the namespace in all the other files as well... and what would happen if you wrote an xml-documentation thing somewhere else on the same namespace? Would one be gone? Or would they be merged somehow?
NDoc supports this by recognising a special NamespaceDoc class located in each namespace, and using the documentation from that. I haven't tried it, but Sandcastle appears to support the same trick.
Edit:
For example:
namespace Some.Namespace
{
/// <summary>
/// This namespace contains stuff
/// </summary>
public static class NamespaceDoc
{
}
}
Sandcastle does not support the NamespaceDoc directly, but if you use Sandcastle Help File Builder you can use the NamespaceDoc class mentioned by Tim.
namespace Example
{
/// <summary>
/// <para>
/// Summary
/// </para>
/// </summary>
/// <include file='_Namespace.xml' path='Documentation/*' />
internal class NamespaceDoc
{
}
}
SCHB also extends the syntax slightly and allows embedding code examples straight from code files. An example _Namespace.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Documentation>
<summary>
<h1 class="heading">Example Namespace</h1>
<para>
This namespace is used in the following way:
</para>
<code source="Examples\Class.cs" lang="cs"></code>
<code source="Examples\Class.vb" lang="vbnet"></code>
<para>
Hopefully this helps!
</para>
</summary>
</Documentation>
Including documentation in XML file allows you to write short summary in code and larger description in a separate XML file for the help file. This way the code isn't cluttered with all the details and remains easily readable.
Sandcastle Help File Builder supports comments on namespaces. Open your Sandcastle project. In Project Properties window navigate to Summaries and click on the Edit Namespace Summaries button.
You can do it in doxygen using:
/// <summary>
/// description
/// </summary>
namespace name{};
Also, it's a good practice to declare your namespaces in a NameSpaces.cs file, and comment them only in this file.
If you use Sandcastle and its "Help File Builder" you can document namespaces and Namespace-Groups using the following Code in your Projects:
namespace Company.Product.Widgets
{
/// <summary>
/// These are the namespace comments for <c>Company.Product.Widgets</c>.
/// </summary>
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
class NamespaceDoc
{
}
}
If the project has namespace grouping enabled, you can also maintain the namespace group comments using a NamespaceGroupDoc class in a similar fashion. The following is an example:
namespace Company.Product
{
/// <summary>
/// These are the group comments for namespaces in <c>Company.Product</c>.
/// </summary>
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
class NamespaceGroupDoc
{
}
}
To keep the NamespaceDoc class from appearing in the help file, leave off the public keyword and mark it with a CompilerGenerated attribute.
For Reference see here: https://ewsoftware.github.io/SHFB/html/48f5a893-acde-4e50-8c17-72b83d9c3f9d.htm
It is not possible to put comments on namespaces.
UseNamespaceDocSummaries on http://ndoc.sourceforge.net/content/documenters.htm
If using Mono's mdoc documentation system, you can document namespace members by editing the ns-*.xml documentation files.
See the mdoc file format documentation for more details.