New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to convert type to same type or one of base types with StepArgumentTransformation #1110
Allow to convert type to same type or one of base types with StepArgumentTransformation #1110
Conversation
@gasparnagy This is your PR to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with this generally, except the two smaller comment I made.
|
||
var stepTransformation = GetMatchingStepTransformation(value, typeToConvertTo, false); | ||
if (stepTransformation != null) | ||
return true; | ||
|
||
var convertToType = Type.GetType(typeToConvertTo.FullName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like above...
var stepTransformation = GetMatchingStepTransformation(value, typeToConvertTo, true); | ||
if (stepTransformation != null) | ||
return DoTransform(stepTransformation, value, cultureInfo); | ||
|
||
var convertToType = Type.GetType(typeToConvertTo.FullName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using Type.GetType, please try to safely cast typeToConvertTo
into RuntimeBindingType
and if the cast is valid, get the runtime type from there.
(Type.GetType only works reliably if you pass an assembly-qualified type name to it.)
Thanks, code by your remarks was added |
@ChernyavskiyAlex one small request from me: could you add an entry into the changelog? Thanks! |
done |
@gasparnagy are you agree with changes i made? |
@ChernyavskiyAlex Thx! |
…mentTransformation (SpecFlowOSS#1110) * Type to same or derived type conversion added * Tests added * Tests fixing * Fixed by gasparnagy remartks * Changelog updated
One of the key needs is to create keywords as "example" or "table" value and resolve it in runtime.
As example:
Suppose wit ha some scenario outline with example block like that:
Examples:
|date|
|#{uniq_id}|
and binding:
[StepArgumentTransformation]
public string KeywordTransformation(string value){
if (value == #{uniq_id})
return Guid.NewGuid.ToString();
}
as a result in test we get the transformed value.