Can I edit specflow's feature.cs file? - specflow

I am trying to create a constructor for Feature.cs file in specflow. But the behaviour is abnormal when I try to debug. Is there a way to create constructor for this feature.cs file? Or we cannot edit this file?

There's no point in editing this file since it will be overwritten everytime that you modify the xxx.feature.
However the class in xxx.feature.cs is declared as partial so you can add xxx.anythingYouLike.cs to your solution with a similar partial class declaration e.g. public partial class xxxFeature and add whatever code you like there.
I'm not suggesting this is good practice, but it can be useful.

Related

swagger-inflector and its use of x-swagger-router-controller and x-swagger-router-model

I am using swagger-inflector to design an API. I am trying to use x-swagger-router-controller and x-swagger-router-model as specified in the docs, but it is not working as specified.
The way I read the docs, these vendor extensions are supposed to create the class if it does not exist and then create a method named with the "operationId". However, they do not work as specified. (I looked at the code that I think is supposed to process this vendor extension, and it looks like the extension should be processed, but the classes are not created as expected. Well, the x-swagger-router-model generates the desired class name, but not the desired package).
If I use the inflector.yaml file and specify modelPackage and controllerPackage, the classes get created in those packages, but I need more granular control over what package is used for the generated classes.
Am i doing something wrong, or is this broken?
Here is an example:
definitions:
SomeObject:
type: object
x-swagger-router-model: com.example.api.dto.SomeObjectDTO
...
paths:
/mypath:
x-swagger-router-controller: com.example.api.controller.subpkg1.MyController
get:
...
From the above example
I do not get a model class named SomeObjectDTO created in com/example/api/dto. If no modelPackage is specified in inflector.yaml, I get a model class named SomeObject created in the default package (io/swagger/...). The model class name that is generated in either case is SomeObject.java
I do not get a controller class named MyController created in com/example/api/controller/subpkg1. If no controllerPackage is specified in inflector.yaml, I get a controller class named "MyPathController" created in the default package (io/swagger/...). The controller class that is generated in either case is MyPathController.java.
It looks like this is a bug, or that I am missing something really obvious. Any pointers here?
the swagger-inflector code will not generate models for you--it will attempt to connect the routing information (via x-swagger-router-model) or via modelPackage + schema name. If that model cannot be loaded in the class loader, it will treat this model as a jackson JsonNode for all input (put/post) methods.

ZF2 override framework classes via autoloader classmap

Is it possible to override the class file location of a framework class via classmap and autoloader? If yes, then how?
Example: I want to override Zend\Form\Fieldset, so that everywhere in the framework where Zend\Form\Fieldset is referenced, I want it to use my own class file instead of the original.
Motivation: When updating the framework, I want to keep my modifications safe from getting overwritten.
Known alternative: Modify the code in the framework.
Disadvantage: Modification gets lost when updating the framework.
writing the same class (FQCN) at another location is generally a bad idea. This causes two classes which are equally named to live in two separate locations. It's a much better idea to create your own Fielset in your own namespace. Say, Application\Form\Fieldset.
You can extend the ZF2 fieldset by your own. Then reference this new fieldset class and its all much more maintainable.
The downside of this method is you don't automatically use the new fieldset class. You have to reference the Application\Form namespace in every form you use. On the other hand, this makes it much more clear to other users of you code what exactly happens: there are no unexpected consequences using ZF2 code.
The only remark I have to make here is, for what do you need another fieldset? If you think you need that for view helpers, that's not true. You can modify the view helper to render fieldsets without modifying the Fieldset form class itself.

How to use DropCreateDatabaseIfModelChanges in VB.net

How can I use DropCreateDatabaseIfModelChanges in a VB.NET application in an early development state where the model changes quite often. I know I have to add those lines to Global.asax - but I only found examples using C# - could someone please give me a hand?
You should define a class which will be used to initialise your database. I usually call mine DatabaseContextIntializer. This needs to inherit from DropCreateDatabaseIfModelChanges
The DatabaseContextIntializer class needs to implement the method Seed(YourDataContextClassNameHere context) and you can use this to populate your database when it is initially created.
Got it: global.asax.vb
Imports System.Data.Entity
...
Database.SetInitializer(New DropCreateDatabaseIfModelChanges(Of <ENTITYNAME>)())

Unable to open designer on form in C# 2010

I have generated a solution in C# 2010 by way of the Artinsoft conversion from VB6.
When I open the new solution in C# I right-click on the forms but there is no "View Designer" option. I assume this is because something is failing to compile. What could be the problem and how should I fix it?
Try a clean and rebuild
Make sure you have proper designer.cs file
Make sure the initialize method is called from the constructor of your Forms.
Make sure if there are any custom dlls they are in right places.
Better create a new app in Windows forms and check how the things are arranged. so that you can compare the conversion.
I would not expect that from a failure to compile, but rather a failure to convert properly. Even if the class doesn't compile, if it's a form you shouldbe able to see and edit the form portion.
The reason should be marked in the error list if it's failing to compile. It's more likely that it's created it as just a class (that doesn't inherit from Form).
Check that there's a MyForm.Designer.cs (where your form name is MyForm) and also check that the declaration of the class in MyForm.cs inherits from form
public partial class MyForm : Form
If this isn't the case, it hasn't converted properly, so you may have to inherit from form, drop on the UI controls again and hook them up to any events
Have you tried running Visual Studio as Administrator (elevated rights)?
Can you try Shift+F7 key combination?

Ambiguity with class and model

I'm trying to define a "Product"-class for my model (.edmx), and I have it in the same folder as the model.
I get: Ambiguity between 'MVCTest.Models.Product.ProductID' and 'MVCTest.Models.Product.ProductID' error
What's needed to do so I can define my classes correctly?
/M
Have you tried using "Partial class"? Only really appropriate if it's an extension of the product class I guess.
If this is not what you were looking for then let us know with more information or even code snippets.
You could always separate out by namespace. Have one class in one namespace. Although having the same class with the same properties is a bit unusual, and suggests that you need to refactor and create some form of inheritance as griegs suggested.

Resources