Skip to content

Commit

Permalink
[C#] fix IDisposable using statements
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall committed Jan 20, 2017
1 parent d694a0b commit a106926
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion C#/C#.sublime-syntax
Expand Up @@ -207,7 +207,7 @@ contexts:
2: meta.path.cs
3: keyword.operator.assignment.cs
push: using_namespace
- match: '\b(using)(?:\s+(static))?\b'
- match: '\b(using)(?!\s*\()(?:\s+(static))?\b'
captures:
1: keyword.control.import.cs
2: keyword.control.import.cs
Expand Down
28 changes: 28 additions & 0 deletions C#/tests/syntax_test_Using.cs
Expand Up @@ -110,3 +110,31 @@ internal sealed partial class Test : global::System.Configuration.ApplicationSet
}
}
}

class Bar {
public void Main ()
{
using(var reader = SomeCodeThatGetsAnIDisposable())
/// ^^^^^ keyword.control.using.cs
/// ^ punctuation.section.group.begin.cs
/// ^^^ storage.type.variable.cs
/// ^ punctuation.section.group.end.cs
{
foreach(var line in reader)
{
DoStuff(line);
}
}
using (var reader = SomeCodeThatGetsAnIDisposable())
/// ^^^^^ keyword.control.using.cs
/// ^ punctuation.section.group.begin.cs
/// ^^^ storage.type.variable.cs
/// ^ punctuation.section.group.end.cs
{
foreach (var line in reader)
{
DoStuff(line);
}
}
}
}

0 comments on commit a106926

Please sign in to comment.