-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pmahend1/Dev
msbuild changes
- Loading branch information
Showing
9 changed files
with
138 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Target Name="PackageAddin" AfterTargets="Build"></Target> | ||
<PropertyGroup> | ||
<TargetFramework>net471</TargetFramework> | ||
<TargetFramework>net48</TargetFramework> | ||
<IsAddin>True</IsAddin> | ||
<CreatePackage>True</CreatePackage> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="MonoDevelop.Addins" Version="0.4.7" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="XmlFormatter"> | ||
<HintPath>lib\XmlFormatter.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Manifest.addin.xml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="logo.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace PrettyXML.VSMac | ||
{ | ||
public enum PrettyXMLCommands | ||
{ | ||
FormatXML | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
PrettyXML.VSMac/PrettyXML.VSMac/Properties/Manifest.addin.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ExtensionModel> | ||
<Runtime> | ||
<Import assembly="XmlFormatter.dll" /> | ||
</Runtime> | ||
<Extension path="/MonoDevelop/Ide/Commands/Edit"> | ||
<Command id="PrettyXML.VSMac.PrettyXMLCommands.FormatXML" | ||
_label="Prettify XML" | ||
defaultHandler="PrettyXML.VSMac.XMLFormatter" | ||
macShortcut="Meta+K|J Meta+K|Meta+J" | ||
shortcut="Control+K|J Control+K|Control+J" | ||
description="Formats XML just like Visual Studio" /> | ||
</Extension> | ||
<Extension path="/MonoDevelop/Ide/MainMenu/Edit"> | ||
<CommandItem id="PrettyXML.VSMac.PrettyXMLCommands.FormatXML" /> | ||
</Extension> | ||
</ExtensionModel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## ReleaseNotes | ||
|
||
### 0.0.7 2020-09-16 | ||
- First version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis.Text; | ||
using Microsoft.VisualStudio.Text; | ||
using Microsoft.VisualStudio.Text.Editor; | ||
using MonoDevelop.Components.Commands; | ||
using MonoDevelop.Ide; | ||
using XmlFormatter; | ||
|
||
namespace PrettyXML.VSMac | ||
{ | ||
public class XMLFormatter : CommandHandler | ||
{ | ||
|
||
protected override void Run(object dataItem) | ||
{ | ||
base.Run(dataItem); | ||
var textBuffer = IdeApp.Workbench.ActiveDocument?.GetContent<ITextBuffer>(); | ||
var textview = IdeApp.Workbench.ActiveDocument.GetContent<ITextView>(); | ||
|
||
|
||
var textdocument = textBuffer?.Properties?.PropertyList?.FirstOrDefault(x =>x.Key is ITextDocument || x.Value is ITextDocument); | ||
var documentvalue = textdocument?.Value as ITextDocument; | ||
|
||
var ext = documentvalue?.FilePath?.Substring(documentvalue?.FilePath?.LastIndexOf(".")??0); | ||
|
||
var contentType = textBuffer?.ContentType; | ||
var currentDocumentText = textBuffer?.CurrentSnapshot?.AsText()?.ToString(); | ||
var formatter = new Formatter(); | ||
|
||
|
||
var contentTypeDisplayName = contentType?.DisplayName?.ToLower() ?? string.Empty; | ||
if (contentTypeDisplayName.EndsWith("xml") || | ||
contentTypeDisplayName.EndsWith("resx") || | ||
contentTypeDisplayName.EndsWith("xsd") || | ||
contentTypeDisplayName.EndsWith("xaml")) | ||
{ | ||
if (currentDocumentText != null) | ||
{ | ||
var formattedText = formatter.Format(currentDocumentText); | ||
var span = new Span(0, textBuffer.CurrentSnapshot.Length); | ||
textBuffer.Replace(span, formattedText); | ||
} | ||
else | ||
{ | ||
Debug.WriteLine("Editor text is null"); | ||
} | ||
|
||
} | ||
else | ||
{ | ||
if(ext.EndsWith("csproj") || | ||
ext.EndsWith("config") || | ||
ext.EndsWith("mobileconfig") || | ||
ext.EndsWith("xsd") || | ||
ext.EndsWith("xml") || | ||
ext.EndsWith("xsl") || | ||
ext.EndsWith("xaml") || | ||
ext.EndsWith("axml")|| | ||
ext.EndsWith("resx")) | ||
{ | ||
|
||
var formattedText = formatter.Format(currentDocumentText); | ||
var span = new Span(0, textBuffer.CurrentSnapshot.Length); | ||
textBuffer.Replace(span, formattedText); | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
protected override void Update(CommandInfo info) | ||
{ | ||
|
||
var textBuffer = IdeApp.Workbench.ActiveDocument.GetContent<ITextBuffer>(); | ||
if (textBuffer != null && textBuffer.AsTextContainer() is SourceTextContainer container) | ||
{ | ||
var document = container.GetTextBuffer(); | ||
info.Enabled = document != null; | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.