diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09c112c8f..5018a26d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ These changes have not been released to the Visual Studio marketplace, but (if c
- [ ] Features
- [ ] Fixes
+ - [x] [#854](https://github.com/codecadwallader/codemaid/pull/854) - Translate new resource to Chinese, simplify build outputs and fix for prompt to clean external files when another dialog is already open - thanks [heku](https://github.com/heku)!
+ - [x] [#877](https://github.com/codecadwallader/codemaid/pull/877) - Recognize WebForms in VS2022 (API change)
+ - [x] [#882](https://github.com/codecadwallader/codemaid/pull/882) - Fixed multiple bugs on file headers update - thanks [lflender](https://github.com/lflender)!
+ - [x] [#885](https://github.com/codecadwallader/codemaid/pull/885) - Recognize Razor in VS2022 (API change)
+ - [x] [#905](https://github.com/codecadwallader/codemaid/pull/905) - Fix issue causing keyword modifiers to be swapped - thanks [BlythMeister](https://github.com/BlythMeister)!
+ - [x] [#929](https://github.com/codecadwallader/codemaid/pull/929) - Add some UI padding
## Previous Releases
@@ -26,7 +32,6 @@ These are the changes to each version that has been released to the Visual Studi
- [x] Fixes
- [x] [#800](https://github.com/codecadwallader/codemaid/pull/800) - Reorganizing: Fix dialog showing literal newline characters
-
## 11.2
**2021-01-02**
@@ -80,7 +85,7 @@ These are the changes to each version that has been released to the Visual Studi
- [x] [#519](https://github.com/codecadwallader/codemaid/pull/519) - Simplify the code by removing unnecessary guids - thanks [heku](https://github.com/heku)!
- [x] [#525](https://github.com/codecadwallader/codemaid/pull/525) - Make all features switchable - thanks [heku](https://github.com/heku)!
- [x] [#545](https://github.com/codecadwallader/codemaid/pull/545) - Ignore comment lines starting with certain prefixes - thanks [willemduncan](https://github.com/willemduncan)!
-
+
- [x] Fixes
- [x] [#479](https://github.com/codecadwallader/codemaid/pull/479) - Update XAML Styler integration mappings - thanks [grochocki](https://github.com/grochocki)!
- [x] [#496](https://github.com/codecadwallader/codemaid/pull/496) - Fix the .NET Framework minimum required version (which is v4.6)
@@ -181,4 +186,4 @@ These are the changes to each version that has been released to the Visual Studi
- [x] #193 - Added undo transaction to insert region command (thanks Matthias Reitinger!)
- [x] Remove multithread operations performance option that was root of problems like #212
-### CHANGELOG started with v0.9.1, see [Blog](http://www.codemaid.net/news/) for deeper history
+### CHANGELOG started with v0.9.1, see [Blog](http://www.codemaid.net/news/) for deeper history
\ No newline at end of file
diff --git a/CodeMaid.UnitTests/CodeMaid.UnitTests.csproj b/CodeMaid.UnitTests/CodeMaid.UnitTests.csproj
index 9faa2cbb3..23fc90cc9 100644
--- a/CodeMaid.UnitTests/CodeMaid.UnitTests.csproj
+++ b/CodeMaid.UnitTests/CodeMaid.UnitTests.csproj
@@ -80,6 +80,9 @@
+
+ 16.10.31321.278
+
17.0.0
diff --git a/CodeMaid.UnitTests/Helpers/FileHeaderHelperTests.cs b/CodeMaid.UnitTests/Helpers/FileHeaderHelperTests.cs
index cfd4d0933..d904f2610 100644
--- a/CodeMaid.UnitTests/Helpers/FileHeaderHelperTests.cs
+++ b/CodeMaid.UnitTests/Helpers/FileHeaderHelperTests.cs
@@ -1,4 +1,4 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using SteveCadwallader.CodeMaid.Helpers;
using System;
@@ -152,8 +152,8 @@ public void GetHeaderLengthMultiSingleLine(string tag, string text)
Assert.IsTrue(headerLength == expectedLength, $"Expecting {expectedLength}, found {headerLength}");
}
- [TestCase("//", "using System;\r\n// header\r\n", 11)]
- [TestCase("//", "using System;\r\n// header I\r\n// header II\r\n", 26)]
+ [TestCase("//", "using System;\r\n// header\r\nnamespace ", 11)]
+ [TestCase("//", "using System;\r\n// header I\r\n// header II\r\nnamespace ", 26)]
public void GetHeaderLengthMultiSingleLineSkipUsings(string tag, string text, int expectedLength)
{
var headerLength = FileHeaderHelper.GetHeaderLength(text, tag, true);
@@ -174,7 +174,7 @@ public void GetHeaderLengthMultiSingleLineWithCode(string tag, string text, int
[TestCase("//", "using System;\r\n\r\n// header \r\nnamespace System.Windows;\r\npublic class Test\r\n", 13)]
[TestCase("//", "using EnvDTE;\r\nusing System;\r\nusing SteveCadwallader.CodeMaid.Helpers;\r\n\r\n\r\n// header \r\n// more header \r\nnamespace SteveCadwallader.CodeMaid;\r\n", 29)]
- [TestCase("//", "using System;\r\n\r\n// header \r\n[assembly: AssemblyTitle(\"SteveCadwallader.CodeMaid.UnitTests\")]\r\n", 13)]
+ [TestCase("//", "using System;\r\n\r\n// header \r\n[assembly: AssemblyTitle(\"SteveCadwallader.CodeMaid.UnitTests\")]\r\nnamespace ", 13)]
public void GetHeaderLengthMultiSingleLineWithCodeSkipUsings(string tag, string text, int expectedLength)
{
var headerLength = FileHeaderHelper.GetHeaderLength(text, tag, true);
@@ -193,7 +193,7 @@ public void GetHeaderLengthMultiSingleLineWithEmptyLines(string tag, string text
Assert.IsTrue(headerLength == expectedLength, $"Expecting {expectedLength}, found {headerLength}");
}
- [TestCase("//", "using System;\r\n\r\n\r\n// header \r\n// header\r\nnamespace\r\n//not header\r\n public class Test\r\n", 23)]
+ [TestCase("//", "using System;\r\n\r\n\r\n// header \r\n// header\r\nnamespace \r\n//not header\r\n public class Test\r\n", 23)]
[TestCase("//", "using EnvDTE;\r\nusing System;\r\nusing SteveCadwallader.CodeMaid.Helpers;\r\n// header \r\n// more header \r\n namespace System.Text;\r\n{\r\n", 29)]
public void GetHeaderLengthMultiSingleLineWithEmptyLinesSkipUsings(string tag, string text, int expectedLength)
{
diff --git a/CodeMaid.VS2022/CodeMaid.VS2022.csproj b/CodeMaid.VS2022/CodeMaid.VS2022.csproj
index bd38845e9..10e8a1cc0 100644
--- a/CodeMaid.VS2022/CodeMaid.VS2022.csproj
+++ b/CodeMaid.VS2022/CodeMaid.VS2022.csproj
@@ -723,21 +723,14 @@
17.0.0-previews-2-31512-422
+ runtime
+ all
17.0.3177-preview3
runtime; build; native; contentfiles; analyzers
all
-
- 13.0.1
-
-
- 5.0.0
-
-
- 4.5.0
-
diff --git a/CodeMaid.VS2022/source.extension.vsixmanifest b/CodeMaid.VS2022/source.extension.vsixmanifest
index d0d5b8ad2..b89cf865a 100644
--- a/CodeMaid.VS2022/source.extension.vsixmanifest
+++ b/CodeMaid.VS2022/source.extension.vsixmanifest
@@ -11,7 +11,7 @@
build, code, c#, beautify, cleanup, cleaning, digging, reorganizing, formatting
-
@@ -19,7 +19,7 @@
-
+
diff --git a/CodeMaid/CodeMaid.csproj b/CodeMaid/CodeMaid.csproj
index 8b156e102..e0ea74656 100644
--- a/CodeMaid/CodeMaid.csproj
+++ b/CodeMaid/CodeMaid.csproj
@@ -341,21 +341,14 @@
16.10.31321.278
+ runtime
+ all
16.11.35
runtime; build; native; contentfiles; analyzers
all
-
- 13.0.1
-
-
- 5.0.0
-
-
- 4.5.0
-
diff --git a/CodeMaidShared/CodeMaidShared.projitems b/CodeMaidShared/CodeMaidShared.projitems
index 0b2472de6..a9033ee27 100644
--- a/CodeMaidShared/CodeMaidShared.projitems
+++ b/CodeMaidShared/CodeMaidShared.projitems
@@ -42,6 +42,7 @@
+
@@ -158,6 +159,7 @@
True
+
diff --git a/CodeMaidShared/Helpers/CodeElementHelper.cs b/CodeMaidShared/Helpers/CodeElementHelper.cs
index 2a07405ec..11d6a353b 100644
--- a/CodeMaidShared/Helpers/CodeElementHelper.cs
+++ b/CodeMaidShared/Helpers/CodeElementHelper.cs
@@ -184,7 +184,7 @@ internal static string GetPropertyDeclaration(CodeProperty codeProperty)
? codeProperty.GetEndPoint(vsCMPart.vsCMPartAttributesWithDelimiter)
: codeProperty.StartPoint;
- return TextDocumentHelper.GetTextToFirstMatch(startPoint, @"\{");
+ return TextDocumentHelper.GetTextToFirstMatch(startPoint, @"[\{;]");
}
///
@@ -197,7 +197,7 @@ internal static string GetStructDeclaration(CodeStruct codeStruct)
// Get the start point after the attributes.
var startPoint = codeStruct.GetStartPoint(vsCMPart.vsCMPartHeader);
- return TextDocumentHelper.GetTextToFirstMatch(startPoint, @"\{");
+ return TextDocumentHelper.GetTextToFirstMatch(startPoint, @"[\{;]");
}
}
}
\ No newline at end of file
diff --git a/CodeMaidShared/Helpers/CodeLanguageHelper.cs b/CodeMaidShared/Helpers/CodeLanguageHelper.cs
index df35a1598..3c3abfa2c 100644
--- a/CodeMaidShared/Helpers/CodeLanguageHelper.cs
+++ b/CodeMaidShared/Helpers/CodeLanguageHelper.cs
@@ -14,27 +14,62 @@ internal static CodeLanguage GetCodeLanguage(string language)
{
switch (language)
{
- case "Basic": return CodeLanguage.VisualBasic;
- case "CSharp": return CodeLanguage.CSharp;
+ case "Basic":
+ return CodeLanguage.VisualBasic;
+
+ case "CSharp":
+ return CodeLanguage.CSharp;
+
case "C/C++":
- case "C/C++ (VisualGDB)": return CodeLanguage.CPlusPlus;
- case "CSS": return CodeLanguage.CSS;
- case "F#": return CodeLanguage.FSharp;
+ case "C/C++ (VisualGDB)":
+ return CodeLanguage.CPlusPlus;
+
+ case "CSS":
+ return CodeLanguage.CSS;
+
+ case "F#":
+ return CodeLanguage.FSharp;
+
case "HTML":
- case "HTMLX": return CodeLanguage.HTML;
+ case "HTMLX":
+ case "Razor":
+ case "WebForms":
+ return CodeLanguage.HTML;
+
case "JavaScript":
case "JScript":
- case "Node.js": return CodeLanguage.JavaScript;
- case "JSON": return CodeLanguage.JSON;
- case "LESS": return CodeLanguage.LESS;
- case "PHP": return CodeLanguage.PHP;
- case "PowerShell": return CodeLanguage.PowerShell;
- case "R": return CodeLanguage.R;
- case "SCSS": return CodeLanguage.SCSS;
- case "TypeScript": return CodeLanguage.TypeScript;
- case "XAML": return CodeLanguage.XAML;
- case "XML": return CodeLanguage.XML;
- default: return CodeLanguage.Unknown;
+ case "Node.js":
+ return CodeLanguage.JavaScript;
+
+ case "JSON":
+ return CodeLanguage.JSON;
+
+ case "LESS":
+ return CodeLanguage.LESS;
+
+ case "PHP":
+ return CodeLanguage.PHP;
+
+ case "PowerShell":
+ return CodeLanguage.PowerShell;
+
+ case "R":
+ return CodeLanguage.R;
+
+ case "SCSS":
+ return CodeLanguage.SCSS;
+
+ case "TypeScript":
+ return CodeLanguage.TypeScript;
+
+ case "XAML":
+ return CodeLanguage.XAML;
+
+ case "XML":
+ return CodeLanguage.XML;
+
+ default:
+ return CodeLanguage.Unknown;
}
}
}
diff --git a/CodeMaidShared/Helpers/FileHeaderHelper.cs b/CodeMaidShared/Helpers/FileHeaderHelper.cs
index 7efe3bada..aa0a57b6d 100644
--- a/CodeMaidShared/Helpers/FileHeaderHelper.cs
+++ b/CodeMaidShared/Helpers/FileHeaderHelper.cs
@@ -1,4 +1,4 @@
-using EnvDTE;
+using EnvDTE;
using SteveCadwallader.CodeMaid.Properties;
using SteveCadwallader.CodeMaid.UI.Enumerations;
using System;
@@ -182,6 +182,12 @@ private static int GetHeaderLength(string text, string commentSyntax)
header.AddRange(GetLinesStartingWith(commentSyntax, lines, header.Count));
var nbChar = 0;
+
+ if (header.Count() == 0)
+ {
+ return 0;
+ }
+
header.ToList().ForEach(x => nbChar += x.Length + 1);
return nbChar;
@@ -218,6 +224,12 @@ private static int GetHeaderLength(string text, string commentSyntaxStart, strin
}
var nbChar = 0;
+
+ if (header.Count() == 0)
+ {
+ return 0;
+ }
+
header.ToList().ForEach(x => nbChar += x.Length + 1);
return nbChar;
@@ -234,7 +246,7 @@ private static int GetHeaderLengthSkipUsings(string text, string commentSyntax)
var nbChar = 0;
header.ToList().ForEach(x => nbChar += x.Length + 1);
- return nbChar + 1;
+ return nbChar == 0 ? 0 : nbChar + 1;
}
private static int GetHeaderLengthSkipUsings(string text, string commentSyntaxStart, string commentSyntaxEnd)
@@ -251,6 +263,12 @@ private static int GetHeaderLengthSkipUsings(string text, string commentSyntaxSt
var header = text.Substring(startIndex, endIndex - startIndex);
var nbNewLines = Regex.Matches(header, Environment.NewLine).Count;
+
+ if (header.Length == 0 && nbNewLines == 0)
+ {
+ return 0;
+ }
+
return header.Length + commentSyntaxEnd.Length - nbNewLines + 1;
}
@@ -307,13 +325,24 @@ private static string SkipUsings(string document)
var startIndex = 0;
var lastUsingIndex = 0;
- while (startIndex < namespaceIndex && startIndex++ != -1)
+ while (startIndex < namespaceIndex)
{
lastUsingIndex = startIndex;
startIndex = document.IndexOf("using ", startIndex);
+
+ if (startIndex++ == -1)
+ {
+ break;
+ }
+ }
+
+ var afterUsingIndex = 0;
+
+ if (lastUsingIndex > 0)
+ {
+ afterUsingIndex = document.IndexOf($"{Environment.NewLine}", lastUsingIndex) + 1;
}
- var afterUsingIndex = document.IndexOf($"{Environment.NewLine}", lastUsingIndex) + 1;
return document.Substring(afterUsingIndex).TrimStart();
}
diff --git a/CodeMaidShared/Helpers/TextDocumentHelper.cs b/CodeMaidShared/Helpers/TextDocumentHelper.cs
index 0706f4f8f..03abb05c2 100644
--- a/CodeMaidShared/Helpers/TextDocumentHelper.cs
+++ b/CodeMaidShared/Helpers/TextDocumentHelper.cs
@@ -42,7 +42,7 @@ internal static class TextDocumentHelper
internal static IEnumerable FindMatches(TextDocument textDocument, string patternString)
{
var matches = new List();
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
@@ -69,7 +69,7 @@ internal static IEnumerable FindMatches(TextDocument textDocument, st
internal static IEnumerable FindMatches(TextSelection textSelection, string patternString)
{
var matches = new List();
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
if (TryGetTextBufferAt(textSelection.Parent.Parent.FullName, out ITextBuffer textBuffer))
@@ -95,7 +95,7 @@ internal static IEnumerable FindMatches(TextSelection textSelection,
internal static EditPoint FirstOrDefaultMatch(TextDocument textDocument, string patternString)
{
EditPoint result = null;
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
@@ -125,7 +125,7 @@ internal static bool TryFindNextMatch(EditPoint startPoint, ref EditPoint endPoi
bool result = false;
EditPoint resultEndPoint = null;
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
@@ -154,16 +154,16 @@ internal static bool TryFindNextMatch(EditPoint startPoint, ref EditPoint endPoi
internal static string GetTextToFirstMatch(TextPoint startPoint, string matchString)
{
string result = null;
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
if (TryGetTextBufferAt(startPoint.Parent.Parent.FullName, out ITextBuffer textBuffer))
{
IFinder finder = GetFinder(matchString, textBuffer);
- if (finder.TryFind(out Span match))
+ if (finder.TryFind(GetSnapshotPositionForTextPoint(textBuffer.CurrentSnapshot, startPoint), out Span match))
{
- result = textBuffer.CurrentSnapshot.GetText(match);
+ result = textBuffer.CurrentSnapshot.GetText(startPoint.AbsoluteCharOffset, match.Start - startPoint.AbsoluteCharOffset);
}
}
});
@@ -299,7 +299,7 @@ internal static void SelectCodeItem(Document document, BaseCodeItem codeItem)
/// The replacement string.
internal static void SubstituteAllStringMatches(TextDocument textDocument, string patternString, string replacementString)
{
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
@@ -320,7 +320,7 @@ internal static void SubstituteAllStringMatches(TextDocument textDocument, strin
/// The replacement string.
internal static void SubstituteAllStringMatches(TextSelection textSelection, string patternString, string replacementString)
{
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
@@ -342,7 +342,7 @@ internal static void SubstituteAllStringMatches(TextSelection textSelection, str
/// The replacement string.
internal static void SubstituteAllStringMatches(EditPoint startPoint, EditPoint endPoint, string patternString, string replacementString)
{
- RunOnUIThread(() =>
+ UIThread.Run(() =>
{
ThreadHelper.ThrowIfNotOnUIThread();
@@ -404,7 +404,7 @@ private static int GetSnapshotPositionForTextPoint(ITextSnapshot textSnapshot, T
ThreadHelper.ThrowIfNotOnUIThread();
var textSnapshotLine = textSnapshot.GetLineFromLineNumber(textPoint.Line - 1);
- return textSnapshotLine.Start.Position + textPoint.LineCharOffset;
+ return textSnapshotLine.Start.Position + textPoint.LineCharOffset - 1;
}
private static Span GetSnapshotSpanForExtent(ITextSnapshot textSnapshot, EditPoint startPoint, EditPoint endPoint)
@@ -440,15 +440,6 @@ private static void ReplaceAll(ITextBuffer textBuffer, IEnumerable
- {
- await CodeMaidPackage.Instance.JoinableTaskFactory.SwitchToMainThreadAsync();
- action();
- });
- }
-
private static bool TryGetTextBufferAt(string filePath, out ITextBuffer textBuffer)
{
IVsWindowFrame windowFrame;
diff --git a/CodeMaidShared/Helpers/UIThread.cs b/CodeMaidShared/Helpers/UIThread.cs
new file mode 100644
index 000000000..df45539e7
--- /dev/null
+++ b/CodeMaidShared/Helpers/UIThread.cs
@@ -0,0 +1,37 @@
+using Microsoft.VisualStudio.Shell;
+using System;
+
+namespace SteveCadwallader.CodeMaid.Helpers
+{
+ internal static class UIThread
+ {
+ public static void Run(Action action)
+ {
+ if (ThreadHelper.CheckAccess())
+ {
+ action();
+ }
+ else
+ {
+ ThreadHelper.JoinableTaskFactory.Run(async () =>
+ {
+ await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
+ action();
+ });
+ }
+ }
+
+ public static T Run(Func func)
+ {
+ if (ThreadHelper.CheckAccess())
+ {
+ return func();
+ }
+ return ThreadHelper.JoinableTaskFactory.Run(async () =>
+ {
+ await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
+ return func();
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/CodeMaidShared/Logic/Cleaning/CodeCleanupAvailabilityLogic.cs b/CodeMaidShared/Logic/Cleaning/CodeCleanupAvailabilityLogic.cs
index 4f9f4b54c..21af739b1 100644
--- a/CodeMaidShared/Logic/Cleaning/CodeCleanupAvailabilityLogic.cs
+++ b/CodeMaidShared/Logic/Cleaning/CodeCleanupAvailabilityLogic.cs
@@ -464,8 +464,11 @@ private static bool PromptUserAboutCleaningExternalFiles(Document document)
CanRemember = true
};
- var window = new YesNoPromptWindow { DataContext = viewModel };
- var response = window.ShowModal();
+ var response = UIThread.Run(() =>
+ {
+ var window = new YesNoPromptWindow { DataContext = viewModel };
+ return window.ShowDialog();
+ });
if (!response.HasValue)
{
diff --git a/CodeMaidShared/Logic/Cleaning/FileHeaderLogic.cs b/CodeMaidShared/Logic/Cleaning/FileHeaderLogic.cs
index eed68ebd3..c9d19992c 100644
--- a/CodeMaidShared/Logic/Cleaning/FileHeaderLogic.cs
+++ b/CodeMaidShared/Logic/Cleaning/FileHeaderLogic.cs
@@ -144,9 +144,8 @@ private void InsertFileHeaderAfterUsings(TextDocument textDocument, string setti
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
var currentHeader = GetCurrentHeader(textDocument, true).Trim();
- var newHeader = settingsFileHeader.Trim();
- if (string.Equals(currentHeader, newHeader))
+ if (currentHeader.StartsWith(settingsFileHeader.Trim()))
{
return;
}
@@ -156,6 +155,11 @@ private void InsertFileHeaderAfterUsings(TextDocument textDocument, string setti
headerBlockStart.MoveToLineAndOffset(nbLinesToSkip + 1, 1);
+ if (!settingsFileHeader.StartsWith(Environment.NewLine))
+ {
+ settingsFileHeader = Environment.NewLine + settingsFileHeader;
+ }
+
headerBlockStart.Insert(settingsFileHeader);
}
@@ -166,7 +170,7 @@ private void InsertFileHeaderDocumentStart(TextDocument textDocument, string set
var cursor = textDocument.StartPoint.CreateEditPoint();
var existingFileHeader = cursor.GetText(settingsFileHeader.Length);
- if (!existingFileHeader.StartsWith(settingsFileHeader.TrimStart()))
+ if (!existingFileHeader.StartsWith(settingsFileHeader.Trim()))
{
cursor.Insert(settingsFileHeader);
}
@@ -192,10 +196,12 @@ private void ReplaceFileHeader(TextDocument textDocument, string settingsFileHea
switch (FileHeaderHelper.GetFileHeaderPositionFromSettings(textDocument))
{
case HeaderPosition.DocumentStart:
+ ReplaceFileHeaderAfterUsings(textDocument, string.Empty); // Removes header after usings if present
ReplaceFileHeaderDocumentStart(textDocument, settingsFileHeader);
return;
case HeaderPosition.AfterUsings:
+ ReplaceFileHeaderDocumentStart(textDocument, string.Empty); // Removes header at document start if present
ReplaceFileHeaderAfterUsings(textDocument, settingsFileHeader);
return;
@@ -229,6 +235,11 @@ private void ReplaceFileHeaderAfterUsings(TextDocument textDocument, string sett
var currentHeaderLength = GetHeaderLength(textDocument, true);
+ if (!settingsFileHeader.StartsWith(Environment.NewLine))
+ {
+ settingsFileHeader = Environment.NewLine + settingsFileHeader;
+ }
+
headerBlockStart.ReplaceText(currentHeaderLength, settingsFileHeader, (int)vsEPReplaceTextOptions.vsEPReplaceTextKeepMarkers);
}
diff --git a/CodeMaidShared/Logic/Reorganizing/CodeReorganizationAvailabilityLogic.cs b/CodeMaidShared/Logic/Reorganizing/CodeReorganizationAvailabilityLogic.cs
index 7cb53f57b..35976e8dd 100644
--- a/CodeMaidShared/Logic/Reorganizing/CodeReorganizationAvailabilityLogic.cs
+++ b/CodeMaidShared/Logic/Reorganizing/CodeReorganizationAvailabilityLogic.cs
@@ -173,8 +173,11 @@ private static bool PromptUserAboutReorganizingPreprocessorConditionals(Document
CanRemember = true
};
- var window = new YesNoPromptWindow { DataContext = viewModel };
- var response = window.ShowModal();
+ var response = UIThread.Run(() =>
+ {
+ var window = new YesNoPromptWindow { DataContext = viewModel };
+ return window.ShowDialog();
+ });
if (!response.HasValue)
{
diff --git a/CodeMaidShared/Model/CodeItems/BaseCodeItemElement.cs b/CodeMaidShared/Model/CodeItems/BaseCodeItemElement.cs
index c2b0459b5..595e40810 100644
--- a/CodeMaidShared/Model/CodeItems/BaseCodeItemElement.cs
+++ b/CodeMaidShared/Model/CodeItems/BaseCodeItemElement.cs
@@ -1,6 +1,7 @@
using EnvDTE;
using SteveCadwallader.CodeMaid.Helpers;
using System;
+using System.Threading;
namespace SteveCadwallader.CodeMaid.Model.CodeItems
{
@@ -122,7 +123,7 @@ public override void RefreshCachedPositionAndName()
/// A lazy initializer for the specified function.
protected static Lazy LazyTryDefault(Func func)
{
- return new Lazy(() => TryDefault(func));
+ return new Lazy(() => TryDefault(func), LazyThreadSafetyMode.PublicationOnly);
}
///
diff --git a/CodeMaidShared/Properties/Resources.zh-Hans.resx b/CodeMaidShared/Properties/Resources.zh-Hans.resx
index c1b416796..f5c15d439 100644
--- a/CodeMaidShared/Properties/Resources.zh-Hans.resx
+++ b/CodeMaidShared/Properties/Resources.zh-Hans.resx
@@ -925,6 +925,6 @@
您有挂起的更改。 是否要在继续之前保存它们?
- Only for methods (TBT)
+ 仅应用于方法
\ No newline at end of file
diff --git a/CodeMaidShared/UI/Converters/BooleanAndConverter.cs b/CodeMaidShared/UI/Converters/BooleanAndConverter.cs
new file mode 100644
index 000000000..d1aef97a8
--- /dev/null
+++ b/CodeMaidShared/UI/Converters/BooleanAndConverter.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Globalization;
+using System.Linq;
+using System.Windows.Data;
+
+namespace SteveCadwallader.CodeMaid.UI.Converters
+{
+ ///
+ /// A converter that performs a logical AND on all values.
+ ///
+ public class BooleanAndConverter : IMultiValueConverter
+ {
+ ///
+ /// The default .
+ ///
+ public static BooleanAndConverter Default = new BooleanAndConverter();
+
+ ///
+ /// Converts source values to a value for the binding target. The data binding engine calls
+ /// this method when it propagates the values from source bindings to the binding target.
+ ///
+ ///
+ /// The array of values that the source bindings in the produces. The value indicates that the source
+ /// binding has no value to provide for conversion.
+ ///
+ /// The type of the binding target property.
+ /// The converter parameter to use.
+ /// The culture to use in the converter.
+ ///
+ /// A converted value.If the method returns null, the valid null value is used.A return
+ /// value of . indicates that the converter
+ /// did not produce a value, and that the binding will use the if it is available, or else
+ /// will use the default value.A return value of . indicates that the binding
+ /// does not transfer the value or use the or the default value.
+ ///
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values == null || values.Length < 1) return null;
+
+ return values.All(x => (bool)x);
+ }
+
+ ///
+ /// Converts a binding target value to the source binding values.
+ ///
+ /// The value that the binding target produces.
+ ///
+ /// The array of types to convert to. The array length indicates the number and types of
+ /// values that are suggested for the method to return.
+ ///
+ /// The converter parameter to use.
+ /// The culture to use in the converter.
+ ///
+ /// An array of values that have been converted from the target value back to the source values.
+ ///
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/CodeMaidShared/UI/Dialogs/CleanupProgress/CleanupProgressWindow.xaml b/CodeMaidShared/UI/Dialogs/CleanupProgress/CleanupProgressWindow.xaml
index 1d6333413..77a4c8aab 100644
--- a/CodeMaidShared/UI/Dialogs/CleanupProgress/CleanupProgressWindow.xaml
+++ b/CodeMaidShared/UI/Dialogs/CleanupProgress/CleanupProgressWindow.xaml
@@ -10,7 +10,7 @@
d:DataContext="{d:DesignInstance local:CleanupProgressViewModel, IsDesignTimeCreatable=False}"
Icon="/source.extension.ico" Title="{x:Static p:Resources.CodeMaidCleanupProgress}"
TextElement.FontFamily="{Binding General_Font, Source={x:Static p:Settings.Default}}"
- Height="180" Width="400" ShowInTaskbar="False" WindowStartupLocation="CenterScreen"
+ Height="190" Width="400" ShowInTaskbar="False" WindowStartupLocation="CenterScreen"
ui:WindowAttachedProperties.DialogResult="{Binding DialogResult}" Closing="OnClosing"
FocusManager.FocusedElement="{Binding ElementName=cancelButton}">
diff --git a/CodeMaidShared/UI/Dialogs/Prompts/YesNoPromptWindow.xaml b/CodeMaidShared/UI/Dialogs/Prompts/YesNoPromptWindow.xaml
index 8a9d0f7bb..50cc7f7e7 100644
--- a/CodeMaidShared/UI/Dialogs/Prompts/YesNoPromptWindow.xaml
+++ b/CodeMaidShared/UI/Dialogs/Prompts/YesNoPromptWindow.xaml
@@ -11,7 +11,7 @@
d:DataContext="{d:DesignInstance local:YesNoPromptViewModel, IsDesignTimeCreatable=False}"
Icon="/source.extension.ico" Title="{Binding Title}"
TextElement.FontFamily="{Binding General_Font, Source={x:Static p:Settings.Default}}"
- Height="180" Width="400" ShowInTaskbar="False" WindowStartupLocation="CenterScreen"
+ Height="190" Width="400" ShowInTaskbar="False" WindowStartupLocation="CenterScreen"
ui:WindowAttachedProperties.DialogResult="{Binding DialogResult}"
FocusManager.FocusedElement="{Binding ElementName=noButton}">
diff --git a/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml b/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml
index aa6efaa4c..8d60c732f 100644
--- a/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml
+++ b/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml
@@ -1,10 +1,10 @@
@@ -13,8 +13,13 @@
-
+
+
+
+
+
+
+