Skip to content

Commit 4ba8ddd

Browse files
Merge pull request #769 from codecadwallader/dev
v11.2 (branch renames)
2 parents 50d84a7 + e9a8f09 commit 4ba8ddd

10 files changed

+95
-80
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
# Changelog
22

3-
## vNext (11.2)
3+
## vNext (11.3)
44

55
These changes have not been released to the Visual Studio marketplace, but (if checked) are available in preview within the [CI build](http://vsixgallery.com/extension/4c82e17d-927e-42d2-8460-b473ac7df316/).
66

77
- [ ] Features
8+
89
- [ ] Fixes
910

1011
## Previous Releases
1112

1213
These are the changes to each version that has been released to the Visual Studio marketplace.
1314

15+
## 11.2
16+
17+
**2021-01-02**
18+
19+
- [x] Features
20+
- [x] [#692](https://github.com/codecadwallader/codemaid/pull/692) - Remove and sort namespaces now supports XAML - thanks [Apflkuacha](https://github.com/Apflkuacha)!
21+
22+
- [x] Fixes
23+
- [x] [#727](https://github.com/codecadwallader/codemaid/pull/727) - Remove and sort usings fixes - thanks [kyleruddbiz](https://github.com/kyleruddbiz)!
24+
1425
## 11.1
1526

1627
**2019-11-03**

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Guidelines for bug reports:
3838
reported.
3939

4040
2. **Check if the issue has been fixed** — try to reproduce it using the
41-
latest `master` or development branch in the repository.
41+
latest `dev` or development branch in the repository.
4242

4343
3. **Isolate the problem** — ideally create an
4444
[SSCCE](http://www.sscce.org/) and a live example.
@@ -113,8 +113,8 @@ included in the project:
113113
2. If you cloned a while ago, get the latest changes from upstream:
114114

115115
```bash
116-
git checkout master
117-
git pull upstream master
116+
git checkout dev
117+
git pull upstream dev
118118
```
119119

120120
3. Create a new topic branch (off the main project development branch) to
@@ -134,7 +134,7 @@ included in the project:
134134
5. Locally merge (or rebase) the upstream development branch into your topic branch:
135135

136136
```bash
137-
git pull [--rebase] upstream master
137+
git pull [--rebase] upstream dev
138138
```
139139

140140
6. Push your topic branch up to your fork:
@@ -144,7 +144,7 @@ included in the project:
144144
```
145145

146146
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
147-
with a clear title and description against the `master` branch.
147+
with a clear title and description against the `dev` branch.
148148

149149

150150
## Code guidelines

CodeMaid/Integration/Images/about.png

615 Bytes
Loading

CodeMaid/Integration/Images/about.xcf

198 Bytes
Binary file not shown.

CodeMaid/Logic/Cleaning/CodeCleanupManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@ private void RunCodeCleanupMarkup(Document document)
478478
var textDocument = document.GetTextDocument();
479479

480480
RunExternalFormatting(textDocument);
481+
if (!document.IsExternal())
482+
{
483+
_usingStatementCleanupLogic.RemoveAndSortUsingStatements(textDocument);
484+
}
481485

482486
// Perform file header cleanup.
483487
_fileHeaderLogic.UpdateFileHeader(textDocument);

CodeMaid/Logic/Cleaning/UsingStatementCleanupLogic.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,9 @@ public void RemoveAndSortUsingStatements(TextDocument textDocument)
7373
// Capture all existing using statements that should be re-inserted if removed.
7474
const string patternFormat = @"^[ \t]*{0}[ \t]*\r?\n";
7575

76-
var points = (from usingStatement in _usingStatementsToReinsertWhenRemoved.Value
77-
from editPoint in TextDocumentHelper.FindMatches(textDocument, string.Format(patternFormat, usingStatement))
78-
select new { editPoint, text = editPoint.GetLine() }).Reverse().ToList();
79-
80-
// Shift every captured point one character to the right so they will auto-advance
81-
// during new insertions at the start of the line.
82-
foreach (var point in points)
83-
{
84-
point.editPoint.CharRight();
85-
}
76+
var usingStatementsToReinsert = _usingStatementsToReinsertWhenRemoved.Value
77+
.Where(usingStatement => TextDocumentHelper.FirstOrDefaultMatch(textDocument, string.Format(patternFormat, usingStatement)) != null)
78+
.ToList();
8679

8780
if (_package.IDEVersion >= 15)
8881
{
@@ -91,19 +84,26 @@ from editPoint in TextDocumentHelper.FindMatches(textDocument, string.Format(pat
9184
else
9285
{
9386
_commandHelper.ExecuteCommand(textDocument, "Edit.RemoveUnusedUsings");
94-
_commandHelper.ExecuteCommand(textDocument, "Edit.SortUsings");
9587
}
9688

97-
// Check each using statement point and re-insert it if removed.
98-
foreach (var point in points)
89+
// Ignore any using statements that are still referenced
90+
usingStatementsToReinsert = usingStatementsToReinsert
91+
.Where(usingStatement => TextDocumentHelper.FirstOrDefaultMatch(textDocument, string.Format(patternFormat, usingStatement)) == null)
92+
.ToList();
93+
94+
if (usingStatementsToReinsert.Count > 0)
9995
{
100-
string text = point.editPoint.GetLine();
101-
if (text != point.text)
96+
var point = textDocument.StartPoint.CreateEditPoint();
97+
98+
foreach (string usingStatement in usingStatementsToReinsert)
10299
{
103-
point.editPoint.StartOfLine();
104-
point.editPoint.Insert(point.text);
105-
point.editPoint.Insert(Environment.NewLine);
100+
point.StartOfLine();
101+
point.Insert(usingStatement);
102+
point.Insert(Environment.NewLine);
106103
}
104+
105+
// Now sort without removing to ensure correct ordering.
106+
_commandHelper.ExecuteCommand(textDocument, "Edit.SortUsings");
107107
}
108108
}
109109

CodeMaid/source.extension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static class Vsix
66
public const string Name = "CodeMaid";
77
public const string Description = "CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.";
88
public const string Language = "en-US";
9-
public const string Version = "11.1";
9+
public const string Version = "11.2";
1010
public const string Author = "Steve Cadwallader";
1111
public const string Tags = "build, code, c#, beautify, cleanup, cleaning, digging, reorganizing, formatting";
1212
}
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
3-
<Metadata>
4-
<Identity Publisher="Steve Cadwallader" Version="11.1" Id="4c82e17d-927e-42d2-8460-b473ac7df316" Language="en-US" />
5-
<DisplayName>CodeMaid</DisplayName>
6-
<Description xml:space="preserve">CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.</Description>
7-
<MoreInfo>http://www.codemaid.net/</MoreInfo>
8-
<License>LICENSE.txt</License>
9-
<Icon>CodeMaid.png</Icon>
10-
<PreviewImage>CodeMaid_Large.png</PreviewImage>
11-
<Tags>build, code, c#, beautify, cleanup, cleaning, digging, reorganizing, formatting</Tags>
12-
</Metadata>
13-
<Installation>
14-
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0, 17.0)" />
15-
</Installation>
16-
<Dependencies>
17-
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.7.2,)" />
18-
</Dependencies>
19-
<Prerequisites>
20-
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />
21-
</Prerequisites>
22-
<Assets>
23-
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
24-
</Assets>
3+
<Metadata>
4+
<Identity Publisher="Steve Cadwallader" Version="11.2" Id="4c82e17d-927e-42d2-8460-b473ac7df316" Language="en-US" />
5+
<DisplayName>CodeMaid</DisplayName>
6+
<Description xml:space="preserve">CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.</Description>
7+
<MoreInfo>http://www.codemaid.net/</MoreInfo>
8+
<License>LICENSE.txt</License>
9+
<Icon>CodeMaid.png</Icon>
10+
<PreviewImage>CodeMaid_Large.png</PreviewImage>
11+
<Tags>build, code, c#, beautify, cleanup, cleaning, digging, reorganizing, formatting</Tags>
12+
</Metadata>
13+
<Installation>
14+
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0, 17.0)" />
15+
</Installation>
16+
<Dependencies>
17+
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.7.2,)" />
18+
</Dependencies>
19+
<Prerequisites>
20+
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />
21+
</Prerequisites>
22+
<Assets>
23+
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
24+
</Assets>
2525
</PackageManifest>

0 commit comments

Comments
 (0)