My visual studio 2017 auto formats following c# code:
while (source[--start] != '\"');
into:
while (source[--start] != '\"')
;
I haven't found any related settings which would be related to this rule.
Why does it add new line and tab before semicolon in this case?
Thank you.
Related
After I type if (view=="") { and press Enter, VS formats and indents the curly braces to this:
if (view == "")
{
}
How can I change the settings in Visual Studio 2019 to just have it like this
if (view == "")
{
}
I've been looking and trying different combinations and can't seem to find the setting.
If you want to get the format you need, you can refer to the parameters of this option:
Tools>Options>Text Editor>C#>Code Style>Formatting>Indentation, uncheck the option ”Indent open and close braces”.
I have the following C# Code (I reduced it to the bare minimum to simplify it). Visual Studio 2019, .NET Framework 4.7.2.
public void Demo()
{
ReportStart();
var success = false;
try
{
int no = 1;
switch (no)
{
case 1:
default:
break;
}
DoSomething();
success = true;
}
finally
{
ReportEnd(success);
}
}
From my understanding, there is nothing wrong about it. The function may fail (I don't want to catch it) but before leaving, it will report successful execution to another method. When debugging, it does exactly what it should.
Interestingly, Visual Studio 2019 will report the following:
When I follow the suggestion by choosing "Remove redundant assignment", it will remove the line success = true;, effectively changing the outcome!
Now what is the switch/case for, you'd ask? When removing it, the recommendation disappears:
Is there any reason for that, or is it a bug in Visual Studio?
It seems to be a known issue with Roslyn and Visual Studio 2019 16.4, please refer to the GitHub issues #39755 and #39344.
The milestone is set to the version 16.5 Preview 2, so it was already fixed and you can try the preview 2 of 16.5 version or wait for stable one (personally, I'm not using a Preview versions)
I'm having trouble with automerge i Visual Studio 2017.
When i try to add or remove a line break in my code, git sometimes refuses to automerge the file and I have to accept every single added or removed line break.
Old code:
if (someThing != null)
{
if (presentation)
{
New code:
if (someThing != null)
{
if (presentation)
{
I am trying to write C# code in MonoDevelop for Ubuntu Linux, but the editor will not format the braces. It used to format them nicely, like so:
void Method()
{
if (condition)
{
//...
}
}
Then one time as I reopened MonoDevelop, the editor started leaving the left brace hanging:
void Method() {
//cursor left here after pressing Enter, no right brace
After I went to Edit > Preferences > Text Editor > Behavior > Checked "Insert matching brace", the editor started appending a } to the end of the block. However, the problem is that now my code is formatted Eclipse/Java-style, which I definitely don't want. See below:
void Method() {
if (condition) {
//...
}
}
For some reason, going to Edit > Preferences > Source Code > Code Formatting > C# > Setting policy to "Microsoft Visual Studio" doesn't help with this. "Enable on the fly code formatting" is checked off, too. Edit > Format > Document works perfectly though, so I don't know what's wrong.
Edit > Preferences > Source Code > Code Formatting are IDE settings which are used when creating new solutions/projects. You should go into your solution settings(double click on solution in SolutionPad) and change settings under "Source Code->Code Formatting->C# source code".
MonoDevelop supports per project(or solution if project has "inherit" policy set).
I'm trying to run a .js file with PostBuildEvent in Visual Studio 2010 and fail when i build the solution with the error code
Error 2 'PostBuildEvent' failed with error code '1' 'Error no especificado'
I already check the names of the files, the path, and the code in my project and js file, and everything seems right...
the js file contain this
// http://blogs.msdn.com/b/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx
var msiOpenDatabaseModeTransact = 1;
var msiViewModifyUpdate = 2
var filespec = WScript.Arguments(0);
var projdir = WScript.Arguments(1);
var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);
// Update the Binary table...
var sql = "SELECT `Name`,`Data` FROM `Binary` where `Binary`.`Name` = 'InstallUtil'";
var view = database.OpenView(sql);
view.Execute();
var record = view.Fetch();
record.SetStream(2, projdir + "InstallUtilLib.dll");
view.Modify(msiViewModifyUpdate, record);
view.Close();
database.Commit();
Anyone already solve a problem like this??
Any help, please...
Since you are using Visual Studio Installer, location of JS File is also important. Your js file should be in the same directory as the .vdproj file for your setup project.
This should be of some help to you
http://blogs.msdn.com/b/astebner/archive/2006/08/12/696833.aspx
In a desperate attempt to solve the problem, I found the solution.
After checking everything else, i move my project to another folder, and I discovered that the path was too long.
The path of my project, despite having less than 255 characters, as indicated by the Microsoft site, cause the Visual Studio 2010 give back this error.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
But attention, being a little explanatory error may result from other errors in other cases. In my case solved the problem.