Can Visual Studio use a 'Block Body' when using 'Generate Method', but still prefer 'Expression Body' otherwise? (VS2019) - editor

I use 'Generate Method' a lot (when typing a missing method call, Visual Studio offers to generate it), but when the options are set to prefer an Expression Body, it generates an Expression Body like this:
private void Blah() => throw new NotImplementedException();
I then have to convert it to a block body because most methods aren't one line. Is there any way to get Visual Studio to generate block body methods but still suggest expression body methods?

I then have to convert it to a block body because most methods aren't
one line. Is there any way to get Visual Studio to generate block body
methods but still suggest expression body methods?
Solution
Please change this:
Tools-->Options-->Text Editor-->C#-->Code Style-->Expression Preferences-->
change Preference of Use expression body for methods to Never
Hope it could help you.

Related

How do you use concordion:run with parameters?

I would like to run a Concordion spec using a parameter. What I'd like to do is execute the spec using concordion:run. A little research pointed me to the existence of a concordion:params attribute, but I cannot find any documentation or examples.
I'm not sure how these two commands fit together; should the params element be nested inside the run element or outside? What is the value to fill in concordion:params="?" Where do I specify the param values themselves--in a concordion:set call?
concordion:params is an attribute to be used on the same element as the concordion:run attribute.
For example, in MyIndex.html:
<a concordion:run="concordion" concordion:params="foo=5" href="MySpec.html">My Spec</a>
with the fixture class:
#RunWith(ConcordionRunner.class)
#FullOGNL
public class MyIndex {
public void setFoo(Integer foo) {
System.out.println("foo = " + foo);
}
}
Note that the #FullOGNL attribute is required to allow the syntax foo=5 in the expression that wouldn't otherwise be allowed.
NOTE:
Tim Wright has pointed out an issue with this approach:
The issue I see is that the same specification might be run from two
different specifications (or run twice from a single specification)
with different parameters as well as from jUnit with no parameters. As
we only create one HTML file, the behaviour might not be what the user
expects. It also means that using concordion:run will create a
different specification from running the spec directly as a jUnit test
- which is something we've tried hard to avoid.
The current behaviour (with the concordion run cache) is that the
first one to be called will create the HTML file - and the second one
will return a run results from the cache thus ignoring the parameter.
This may mean that we deprecate concordion:params and remove it in 2.0.

syncfusion error render chart convert void to object

This is my first time use syncfusion for asp mvc 5 razor
I want to create a chart, in my learning i found error in my first.
#(Html.EJ().Chart("container").Render())
that is my code in cshtml and this is my error :
Cannot implicitly convert type 'void' to 'object'
how to solve this?
This happens because of specifying the “.Render()”
This structure was followed in Syncfusion Essential studio version 12.1.0.36. But it was changed in the future release.
Please find the below code snippet for initializing a chart control.
[CSHTML]
#(Html.EJ().Chart("container"))
This standard is followed from Syncfusion Essential studio version 12.2.0.36 to current versions.
Thanks,
The parenthesis used in Html helper (#(Html.EJ) defines an explicit expression and the curly brackets(#{Html.EJ) defines a regular C# code block. The difference is that the explicit expression submits its output directly as a part of the HTML mark up and the code block doesn't.
And so if you want to use Render then use your code within the code block ({}).
#{ Html.EJ()
…
.Render()}

JSLint Weird assignment, required for closure compiler

I'm using the closure compiler to minify and speed up my code but I'm running into some issues with JSLint when I try to export my functions.
Basically, I have an object, foo{} with a function, foo.bar() that gets called via an external file as. In order for this function to be called externally I need to add some declarations to my script before it gets compiled:
window['foo'] = foo;
window['foo']['bar'] = foo.bar;
This works great, but—as ever—JSLint thinks I'm mental for even attempting this. I've managed to suppress the dot notation error by declaring, /*jslint sub: true */ just before these two lines but I still get the following error:
"window['foo']['bar'] = foo.bar;" - Weird assignment
It's not wrong, it is a weird assignment out of context, but I need it in there in order for my code to work.
The way I see it, I have three possible options:
Tell JSLint not to bother even looking at them two lines.
Suppress the Weird assignment error.
Find another way to make my code work with closure compiler.
The problem is, I have no idea how to go about doing any of them.
You can export names using goog.exportSymbol instead of bracket notation: https://github.com/google/closure-library/blob/master/closure/goog/base.js#L1532
The Closure Compiler understands what goog.exportSymbol is so it'll remove the explicit exportSymbol call and add foo and bar directly to the window for you.

Does Rascal Java method AST also contain super() Expression for calls to super with arguments?

When I look at Java method AST declaration in Rascal, I see under Expression \super() node.
However in Java, you can also call super() with parameters. So, I expected to see something like : \super(list[Expression] arguments), but I do not see it.
Is it traced via \methodCall() or in some other way?
I could not try it myself because I get an error when I try to build an AST from a constructor with getMethodASTEclipse() method. I already opened an issue about this getMethodASTEclipse() error in the GitHub.

Get methods params type parsing wsdl file in a rails/ruby application

I have a question about ruby and wsdl soap.
I couldn't find a way to get each method's params and their type.
For example, if I found out that a soap has a methods called "get_user_information" (using wsdlDriver) is there a way to know if this method requires some params and what type of params does it require (int, string, complex type, ecc..)?
I'd like to be able to build html forms from a remote wsdl for each method...
Sorry for my horrible English :D
Are you using soapr4?
Soap4r comes with a command line client to build proxies for accessing web services via SOAP. This is preferable to using the wsdlDriver which has to build the proxy dynamically every time it runs.
To build a "permanent" proxy then you need to run the following command
wsdl2ruby.rb --type client --wsdl http://some/path/to/the/wsdl
When this command runs then you should end up with a bunch of ruby files one of which (probably default.rb) will call each method in turn and document the necessary inputs and outputs.
Alternatively you may find the Wsdl Analyser useful. This will allow you to enter the URL for a WSDL which it will then analyse and list all of the operations and (sometimes) the paramaters required
Thank you for the very quick response!
I'll try to explain myself a little better :D
I've tried soap4r, and I'm able to get soap's methods with something like this:
require "soap/wsdlDriver"
client = SOAP::WSDLDriverFactory.new(my-wsdl-url).create_rpc_driver
puts client.singleton_methods
What I'd like to know is:
If, for example, my soap has a method called "get_some_params_and_sum_them", is there a way to know how many params it takes and which type they should be?
Something like
puts client.method("get_some_params_and_sum_them").params
Wsdl Analyser does it, and I'd like to know if this is possible also in a ruby script without tons of code lines :D

Resources