Skip to content
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

Metadata as Source completely breaks with tab indentation #4019

Closed
SLaks opened this issue Jul 21, 2015 · 26 comments
Closed

Metadata as Source completely breaks with tab indentation #4019

SLaks opened this issue Jul 21, 2015 · 26 comments
Assignees
Milestone

Comments

@SLaks
Copy link
Contributor

SLaks commented Jul 21, 2015

Running the RTM build:

MAS completely fails on Microsoft.VisualStudio.Settings.SettingsStore.

F12 shows an AggregateException message in a dialog. Peek just hangs. Attaching a debugger shows an ArgumentOutRange complaining the start is less than end from the following stack:

>   Microsoft.CodeAnalysis.Text.TextSpan.FromBounds(int start, int end) Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.TriviaDataFactory.ComplexTrivia.ShouldFormat(Microsoft.CodeAnalysis.Formatting.FormattingContext context)  Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.TriviaDataFactory.ComplexTrivia.Format(Microsoft.CodeAnalysis.Formatting.FormattingContext context, Microsoft.CodeAnalysis.Formatting.ChainedFormattingRules formattingRules, System.Action<int, Microsoft.CodeAnalysis.Formatting.TriviaData> formattingResultApplier, System.Threading.CancellationToken cancellationToken, int tokenPairIndex)  Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.ApplyEndOfTreeTriviaOperation(Microsoft.CodeAnalysis.Formatting.FormattingContext context, Microsoft.CodeAnalysis.Formatting.TokenStream tokenStream, System.Threading.CancellationToken cancellationToken)  Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.Format(System.Threading.CancellationToken cancellationToken) Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.CSharpStructuredTriviaFormatEngine.Format(Microsoft.CodeAnalysis.SyntaxTrivia trivia, int initialColumn, Microsoft.CodeAnalysis.Options.OptionSet optionSet, Microsoft.CodeAnalysis.Formatting.ChainedFormattingRules formattingRules, System.Threading.CancellationToken cancellationToken)   Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.CSharpTriviaFormatter.FormatStructuredTrivia(Microsoft.CodeAnalysis.Formatting.LineColumn lineColumn, Microsoft.CodeAnalysis.SyntaxTrivia trivia, System.Collections.Generic.List<Microsoft.CodeAnalysis.Text.TextChange> changes, System.Threading.CancellationToken cancellationToken)   Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.CSharpTriviaFormatter.Format(Microsoft.CodeAnalysis.Formatting.LineColumn lineColumn, Microsoft.CodeAnalysis.SyntaxTrivia commonTrivia, System.Collections.Generic.List<Microsoft.CodeAnalysis.Text.TextChange> changes, System.Threading.CancellationToken cancellationToken) Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractTriviaFormatter<Microsoft.CodeAnalysis.SyntaxTrivia>.FormatFirstTriviaAndWhitespaceAfter<Microsoft.CodeAnalysis.Text.TextChange>(Microsoft.CodeAnalysis.Formatting.LineColumn lineColumnBeforeTrivia1, Microsoft.CodeAnalysis.SyntaxTrivia trivia1, Microsoft.CodeAnalysis.Formatting.LineColumnDelta existingWhitespaceBetween, Microsoft.CodeAnalysis.SyntaxTrivia trivia2, Microsoft.CodeAnalysis.Formatting.AbstractTriviaFormatter<Microsoft.CodeAnalysis.SyntaxTrivia>.Formatter<Microsoft.CodeAnalysis.Text.TextChange> format, Microsoft.CodeAnalysis.Formatting.AbstractTriviaFormatter<Microsoft.CodeAnalysis.SyntaxTrivia>.WhitespaceAppender<Microsoft.CodeAnalysis.Text.TextChange> addWhitespaceTrivia, System.Collections.Generic.List<Microsoft.CodeAnalysis.Text.TextChange> changes, bool implicitLineBreak, System.Threading.CancellationToken cancellationToken)  Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractTriviaFormatter<Microsoft.CodeAnalysis.SyntaxTrivia>.FormatTrivia<Microsoft.CodeAnalysis.Text.TextChange>(Microsoft.CodeAnalysis.Formatting.AbstractTriviaFormatter<Microsoft.CodeAnalysis.SyntaxTrivia>.Formatter<Microsoft.CodeAnalysis.Text.TextChange> formatter, Microsoft.CodeAnalysis.Formatting.AbstractTriviaFormatter<Microsoft.CodeAnalysis.SyntaxTrivia>.WhitespaceAppender<Microsoft.CodeAnalysis.Text.TextChange> whitespaceAdder, System.Collections.Generic.List<Microsoft.CodeAnalysis.Text.TextChange> changes, System.Threading.CancellationToken cancellationToken)   Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractTriviaFormatter<Microsoft.CodeAnalysis.SyntaxTrivia>.FormatToTextChanges(System.Threading.CancellationToken cancellationToken)    Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.TriviaDataFactory.FormattedComplexTrivia.FormattedComplexTrivia(Microsoft.CodeAnalysis.Formatting.FormattingContext context, Microsoft.CodeAnalysis.Formatting.ChainedFormattingRules formattingRules, Microsoft.CodeAnalysis.SyntaxToken token1, Microsoft.CodeAnalysis.SyntaxToken token2, int lineBreaks, int spaces, string originalString, System.Threading.CancellationToken cancellationToken)  Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.TriviaDataFactory.ComplexTrivia.Format(Microsoft.CodeAnalysis.Formatting.FormattingContext context, Microsoft.CodeAnalysis.Formatting.ChainedFormattingRules formattingRules, int lines, int spaces, System.Threading.CancellationToken cancellationToken) Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.TriviaDataFactory.ComplexTrivia.Format(Microsoft.CodeAnalysis.Formatting.FormattingContext context, Microsoft.CodeAnalysis.Formatting.ChainedFormattingRules formattingRules, System.Action<int, Microsoft.CodeAnalysis.Formatting.TriviaData> formattingResultApplier, System.Threading.CancellationToken cancellationToken, int tokenPairIndex)  Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.ApplyBeginningOfTreeTriviaOperation(Microsoft.CodeAnalysis.Formatting.FormattingContext context, Microsoft.CodeAnalysis.Formatting.TokenStream tokenStream, System.Threading.CancellationToken cancellationToken)    Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.Format(System.Threading.CancellationToken cancellationToken) Unknown
    Microsoft.CodeAnalysis.CSharp.Formatting.CSharpSyntaxFormattingService.Format(Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.Options.OptionSet optionSet, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Formatting.Rules.IFormattingRule> formattingRules, Microsoft.CodeAnalysis.SyntaxToken token1, Microsoft.CodeAnalysis.SyntaxToken token2, System.Threading.CancellationToken cancellationToken)  Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractSyntaxFormattingService.FormatIndividually(Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.Options.OptionSet options, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Formatting.Rules.IFormattingRule> rules, System.Collections.Generic.IList<Microsoft.CodeAnalysis.Text.TextSpan> spansToFormat, System.Threading.CancellationToken cancellationToken)   Unknown
    Microsoft.CodeAnalysis.Formatting.AbstractSyntaxFormattingService.Format(Microsoft.CodeAnalysis.SyntaxNode node, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Text.TextSpan> spans, Microsoft.CodeAnalysis.Options.OptionSet options, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Formatting.Rules.IFormattingRule> rules, System.Threading.CancellationToken cancellationToken) Unknown
    Microsoft.CodeAnalysis.Formatting.Formatter.Format(Microsoft.CodeAnalysis.SyntaxNode node, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Text.TextSpan> spans, Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Options.OptionSet options, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Formatting.Rules.IFormattingRule> rules, System.Threading.CancellationToken cancellationToken)   Unknown
    Microsoft.CodeAnalysis.Formatting.Formatter.FormatAsync(Microsoft.CodeAnalysis.Document document, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Text.TextSpan> spans, Microsoft.CodeAnalysis.Options.OptionSet options, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Formatting.Rules.IFormattingRule> rules, System.Threading.CancellationToken cancellationToken)    Unknown

The debugger reveals that the tokens being formatted are

#region Assembly Microsoft.VisualStudio.Shell.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Users\SSL\Development\Open Source\Mine\C#\VSEmbed\References\v11.0\Microsoft.VisualStudio.Shell.11.0.dll
#endregion

usingSystem;usingSystem.Collections.Generic;usingSystem.IO;namespaceMicrosoft.VisualStudio.Settings{publicabstractclassSettingsStore{protectedSettingsStore();publicabstractSystem.BooleanCollectionExists(System.StringcollectionPath);publicabstractSystem.BooleanGetBoolean(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.BooleanGetBoolean(System.StringcollectionPath,System.StringpropertyName,System.BooleandefaultValue);publicabstractSystem.Int32GetInt32(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.Int32GetInt32(System.StringcollectionPath,System.StringpropertyName,System.Int32defaultValue);publicabstractSystem.Int64GetInt64(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.Int64GetInt64(System.StringcollectionPath,System.StringpropertyName,System.Int64defaultValue);publicabstractglobal::System.DateTimeGetLastWriteTime(System.StringcollectionPath);publicabstractglobal::System.IO.MemoryStreamGetMemoryStream(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.Int32GetPropertyCount(System.StringcollectionPath);publicabstractglobal::System.Collections.Generic.IEnumerable<System.String>GetPropertyNames(System.StringcollectionPath);publicabstractglobal::Microsoft.VisualStudio.Settings.SettingsTypeGetPropertyType(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.StringGetString(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.StringGetString(System.StringcollectionPath,System.StringpropertyName,System.StringdefaultValue);publicabstractSystem.Int32GetSubCollectionCount(System.StringcollectionPath);publicabstractglobal::System.Collections.Generic.IEnumerable<System.String>GetSubCollectionNames(System.StringcollectionPath);publicabstractSystem.UInt32GetUInt32(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.UInt32GetUInt32(System.StringcollectionPath,System.StringpropertyName,System.UInt32defaultValue);publicabstractSystem.UInt64GetUInt64(System.StringcollectionPath,System.StringpropertyName);publicabstractSystem.UInt64GetUInt64(System.StringcollectionPath,System.StringpropertyName,System.UInt64defaultValue);publicabstractSystem.BooleanPropertyExists(System.StringcollectionPath,System.StringpropertyName);}}

It looks like the error comes when trying to format the #endregion

@SLaks SLaks changed the title Metadata as Source formatting failure for weird COMmy type Metadata as Source completely breaks with tab indentation Jul 21, 2015
@SLaks
Copy link
Contributor Author

SLaks commented Jul 21, 2015

Exploring even further, it looks like setting indentation to use tabs instead of whitespace completely breaks all of MAS.

@Pilchie Pilchie added this to the 1.1 milestone Jul 24, 2015
@Pilchie Pilchie added the Bug label Jul 24, 2015
@anfomin
Copy link

anfomin commented Jul 29, 2015

It there any news when this bug will be resolved? We use tabs in our code agreements so it's very uncomfortable to switch tabs=>spaces=>tabs each time we need Go to definition.

@basoundr
Copy link
Contributor

@anfomin The fix is ready for this issue. I will be sending a PR in few minutes. Writing a good testcase was a little tricky here. Sorry for the inconvenience.

basoundr added a commit to basoundr/roslyn that referenced this issue Jul 29, 2015
Fixes dotnet#4019 While formatting a complextrivia that falls as a end_of_tree
trivia of a tree that is being formatted, adjust the span of the
ComplexTrivia for formatting purposes
basoundr added a commit to basoundr/roslyn that referenced this issue Jul 30, 2015
Fixes dotnet#4019 While formatting a complextrivia that falls as a end_of_tree
trivia of a tree that is being formatted, adjust the span of the
ComplexTrivia for formatting purposes
@anfomin
Copy link

anfomin commented Jul 31, 2015

Is there any way to install this update to VS2015 RTM?

@Pilchie
Copy link
Member

Pilchie commented Jul 31, 2015

Not at the moment. The current plan is that the fix will be part of VS2015 Update 1.

@anfomin
Copy link

anfomin commented Jul 31, 2015

@Pilchie oh... may be there is approximate release date for this update? It is very inconvenient to switch to spaces indentation when code agreements says to use tabs 👎 Thank you.

@solidstock
Copy link

So this is fixed but can't be one can't download the latest and update VS2015? What was all that talk about packages this and different release schedules that and components this. Wow I thought VS2015 and Roslyn was like RTM, should have know it would be useless until the first update to VS2015.

@breyed
Copy link

breyed commented Aug 14, 2015

There is a not-so-great workaround, but it would not be at all fun to have to put up with it for months before a fix comes out.

@solidstock
Copy link

Thanks, yes I'm aware that Rosyln was made for developers that use spaces instead of tabs but given we have 8 years of dev on our source code using tabs we aren't really ready to mix tabs with spaces just to use an unfinished, untested product that was rushed to release.

@Dessix
Copy link

Dessix commented Aug 24, 2015

@solidstock While the anger is probably justified, given VS's minimal handling of spacing as indentation (See any editors which treat spaces as tabs when navigating) and their lack of testing on this feature, it is likely that it won't actually assist in development.

For now, I'm switching to spaces for my projects using TabSanity to assist in alleviating my seething hatred for such navigation issues. Smudge Filtration can be performed on working copies for git to allow you to work with spaces for the meantime while not screwing up and polluting your repository's version of the source. You'll lose the capability to analyse some situations with git's tools, but they should be compensated for by VS actually working correctly.

If you're using submodules, the filters will likely mess with them, so you can apply to specific paths (.gitignore style) to ensure that only the targetted files get filtered. For example, my Dependency directory contains third-party submodules, but my source is under project-named directories. I use the attribute ProjectName/*.cs instead of just *.cs to compensate for this situation, and submodules do not get unnecessarily confused. If you get the issue wherein a branch's files were not able to be refiltered upon checkout using the command they specify, you can use this:

git checkout HEAD -- "$(git rev-parse --show-toplevel)"

Which will properly select only paths which exist in your index, ignoring those that are under .gitignore or not checked in.

A note on usage:

Sadly, I've found several flaws with this method that lead to issues... Git's extension for visual studio seems to create commits without applying the smudge filters, so command line or Tortoisegit are your only routes for committing when using this hack if you don't want to fill your repository with the wrong type of whitespace upon doing so. I've hence moved back to tabs, despite the pain, but it may be worth trying this method if you're willing to tolerate the edge case issues.

@MaceWindu
Copy link

@Pilchie : The current plan is that the fix will be part of VS2015 Update 1.

Sounds great!
just great

@Dessix
Copy link

Dessix commented Aug 29, 2015

@MaceWindu Yeah, I really wish bugfixes could be hotpatched over their extension system or something...

@xfreshy
Copy link

xfreshy commented Aug 29, 2015

@Pilchie : The current plan is that the fix will be part of VS2015 Update 1.

This is such a generic statement. Can you be more specific like, oh you can use the new VS 2015 in December when we integrate this fix.

@MaceWindu
Copy link

@Dessix
Copy link

Dessix commented Aug 29, 2015

@MaceWindu Holy crap, thank you!

@Pilchie
Copy link
Member

Pilchie commented Aug 29, 2015

We are working on being able to ship hot fixes via extensions. Unfortunately, doing so requires changes to core VS components that are also being worked on for Update 1 😦

@Dessix
Copy link

Dessix commented Aug 29, 2015

Any chance of a date estimate for when we can get back to real work, as @MaceWindu asked?

@Pilchie
Copy link
Member

Pilchie commented Aug 29, 2015

I'm not allowed to talk about projected ship dates, but if you look back at the last 9 VS updates that have been released, you might be able to make a guess.

@Dessix
Copy link

Dessix commented Aug 29, 2015

Well, that's inspiring me to make a few extensions to help with the formatting issues as they arise...

@breyed
Copy link

breyed commented Aug 29, 2015

I thought patching apps like Visual Studio was a solved problem, as old as the computing hills. For example, here's a random hotfix for VS2010. Patching has been baked into Windows Installer since the beginning and is quite mature now.

There is a cost for Microsoft to issue a hotfix. They need to build, test, and support it, and account for its presence or absence when supporting Visual Studio in general. It's not clear how shipping a hotfix as an extension simplifies any of this, if they're going to stand behind it.

You'd think for a pinpoint bug fix like this, a hotfix would be low enough risk and cost that it would be worth it, especially if developer happiness is at stake.

@Spongman
Copy link

pathetic. get a QA team already.

@NN---
Copy link

NN--- commented Oct 6, 2015

@MaceWindu Thanks !

@Pilchie
Copy link
Member

Pilchie commented Oct 8, 2015

FYI that this issue should be fixed in today's release of VS 2015 Update 1 CTP at http://blogs.msdn.com/b/visualstudio/archive/2015/10/08/visual-studio-2015-update-1-ctp.aspx.

@NightElfik
Copy link

This is somewhat embarrassing and sad at the same time. Please write some tests for "Go To Definition" so similar situation will never happen again.

Downloaded VS15 yesterday and still have this issue...

@craig-wagner
Copy link

I hope I have the privilege of someday working with all of you as after a 30-year career I have yet to work with a developer who has never introduced a silly bug into their code. I'm in awe how you all can write perfect code on the first try and have never shipped anything with a bug in it. My hats off to you gentlemen for such a stunning feat!

  1. I don't work for Microsoft.
  2. The above is sarcasm.
  3. I find this bug as annoying as you do, but I recognize that bugs happen and taking a haughty approach like I'm somehow above making mistakes would just make me look like an arrogant a**hole.

@NightElfik
Copy link

Oh, don't get me wrong. Bugs of course happen. What I find embarrassing is not the bug itself, but rather the fact that this particular bug was reported here on Jul 20 (release day), was fixed on Jul 29 and now we are here Oct 22 - nearly three months later - and the bug is still present in the newest version. I just think this is embarrassing and sad. Also, I have hit this bug the first five minutes of usage of VS and keep hitting it multiple times a day.

I did not intend to blame any individual, and I am sorry if I did - you guys are doing great job! When I buy software for $500 I just expect something more than this from MS.

This being said, VS could use some better/faster update mechanism to prevent things like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests