When I declare or call a C# method with multi-line parameters like this:
public void DoSomething(
p1,
p2,
p3);
Then I would like ReSharper to format that code to like this:
public void DoSomething(
p1,
p2,
p3
);
Is there a setting that enables this behavior?
This feature is only available beginning with ReSharper 2018.1.
Those settings are located here:
Code Editing -> C# -> Formatting Style -> Line Breaks and Wrapping
-> Arrangement of Method Signatures -> Prefer wrap before ")" in declaration
-> Arrangement of Invocations -> Prefer wrap before ")" in invocation
Related
I'm new to F# and trying to recreate some simple apps that I've built in the past with C# or Powershell. I'm trying to get multiple properties for a web.
In F#, I can get a single property, but I'm not sure the syntax that would work for getting multiple properties at once.
As an example:
// F# Example
context.Load(web |> fun w->w.Lists)
context.Load(web |> fun w->w.AssociatedOwnerGroup)
context.ExecuteQuery()
Is there a way in F# to combine that into a single line?
In C# I'd call it like so:
// C# Example
context.Load(web, w => w.Lists, w => w.AssociatedOwnerGroup);
context.ExecuteQuery();
It looks like the function you're calling is ClientRuntimeContext.Load<T>, which has the following C# signature:
public void Load<T>(
T clientObject,
params Expression<Func<T, Object>>[] retrievals
)
where T : ClientObject
There are two issues here that make this function difficult to call from F#: the params array, and the automatic conversion to LINQ expressions. F# supports these separately, but it looks like the automatic conversion doesn't work when you have multiple parameters. Instead, I think you have to do it manually, something like this:
// automatically quotes a function
type Expr =
static member Quote<'t>(f : Expression<Func<'t, obj>>) = f
// quote the functions
let funcs =
[|
fun (w : SPWeb) -> w.Lists
fun (w : SPWeb) -> w.AssociatedOwnerGroup
|] |> Array.map Expr.Quote
// call the Load function
context.Load(web, funcs)
Sorry, I know that's ugly. There may be a better way to do it, but I don't know what it is.
Is there any easy way to select/change/delete an argument in kakoune?
For example, if I have
int foo(int arg1, int arg2)
and I would like to select int arg1. In spacemacs I can do this with via. How do I do this in kakoune?
You can use the u text-object.
So, while inside the parens type <a-i>u.
If you do <a-a>u instead, it will also select the following comma and space.
I have expression like this in Kotlin:
fun getSomething() = create()
How to check in IntelliJ IDEA (Android Studio) during debug what value does function return?
If I just put breakpoint it does not show expression result.
UPD. I understand that if I rewrite code using a temporary variable I could debug it:
fun getSomething() {
var tmp = create()
return tmp
}
But how to do it without rewriting code?
Put the breakpoint after the line which calls the function / assigns the return value like this:
fun getSomething(i: Int) = 5 * i
fun main(args: Array<String>) {
val x = getSomething(5) // (1)
println(x) // (2)
}
(1) If you put the breakpoint here, x won't be assigned yet
(2) if you want to know the value of x, put the breakpoint on a line after the assignment (println is just used as an example here)
If you want to test what getSomething returns for different values of i,
highlight it and right-click in the editor window when the debugger stops at the breakpoint and choose "Evaluate Expression" (or hit Alt+Shift+8 on Windows or Linux)
In the window that opens you can evaluate any code which is in scope.
I have made a program that plots a slope field for a given function.
It works correct if I plug in the function in the source code.
But I wan to turn this vb6 project into an exe file.
Because I knew this will happen before, I previously made a field for inputting the function. The function will be inputted in a special form. inspired by the language used in some add on in AutoCAD, I made this language and named it DiffSol.
So what the user is gonna do is to write a function in the field using DiffSol language.
The problem is that It needs to be a real mathematical function in vb to be evaluated for different x and y's. but I cannot find a strategy to turn that language into a vb math function which can be evaluated.
All I am gonna do is to evaluate the inputted function for 15*31 times.
The job looks like making a compiler. It seems a really hard job for me.
Any ideas?
Simple way is to transpile it in to VBScript or JScript.
Create a class containing your functions written in VB:
' +(a,b)
public function ADD(a as double, b as double) as double
add = a + b
end function
'/(a,b)
public function DIV(a as double, b as double) as double
div = a / b
end function
Add a reference to the Microsoft Script Control then:
Dim scr As ScriptControl: Set scr = New ScriptControl
scr.Language = "VBScript"
'// allow the script access to the class with the functions
scr.AddObject "DS", new diffsolClass
expr = " +(200, c(/(+(2,6), 2))) "
'//parse with simple substitution
parsed = expr
parsed = Replace$(parsed, "/", "DS.DIV")
parsed = Replace$(parsed, "+", "DS.ADD")
parsed = Replace$(parsed, "c", "cos") '//built in already
'//for some valid VB: DS.ADD(200, cos(DS.DIV(DS.ADD(2,6), 2)))
'//run it
MsgBox scr.Eval(parsed)
returns 199.346356379136
Resharper is giving me this:
new MyObject {Prop1 = prop1, Prop2 = prop2}
But I want:
new MyObject { Prop1 = prop1, Prop2 = prop2 }
Currently it's breaking my StyleCop rules.
I think this is the setting you are looking for.
http://screencast.com/t/nEXMHo6Ko Dead link
--Edit--
In case of a dead link, The setting is under C# -> Formatting Style -> Spaces -> Within single-line initializer braces. Check the box next to it and you'll be all set.
you can get resharper to match stylecop here by putting these lines in .editorconfig
resharper_space_within_empty_braces = true
resharper_space_within_single_line_array_initializer_braces = true