Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs54
-rw-r--r--main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs66
m---------main/external/nuget-binary0
-rw-r--r--main/src/addins/CSharpBinding/CSharpBinding.csproj1
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CSharpEditorFormattingService.cs108
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/SmartTokenFormatter.cs163
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs38
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs25
-rw-r--r--main/src/addins/MacPlatform/MacExternalConsoleProcess.cs6
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTests.cs25
-rw-r--r--main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs3
-rw-r--r--main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingNuGetProject.cs17
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs16
-rw-r--r--main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorOptions.cs5
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs46
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/DropDownBoxListWindow.cs19
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/xml/syntaxes/xml.json1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextStylePolicy.cs37
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs5
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs28
-rw-r--r--main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/OnTheFlyFormatterTests.cs137
-rw-r--r--main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildGlobTests.cs196
-rw-r--r--main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildTests.cs4
-rw-r--r--main/tests/test-projects/dotnetcore-pcl/NetCore11/NetCore11.csproj7
-rw-r--r--main/tests/test-projects/dotnetcore-pcl/NetStandard14/NetStandard14.csproj7
-rw-r--r--main/tests/test-projects/dotnetcore-pcl/PclProfile111/PclProfile111.csproj34
-rw-r--r--main/tests/test-projects/dotnetcore-pcl/dotnetcore-pcl.sln29
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-remove-saved2.csproj39
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-remove-saved3.csproj41
-rw-r--r--main/tests/test-projects/msbuild-glob-tests/glob-remove-test2.csproj41
-rwxr-xr-xversion-checks2
31 files changed, 813 insertions, 387 deletions
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs
index 3b6ed03d19..a41aa87767 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs
@@ -1,23 +1,33 @@
namespace MonoDevelopTests
open NUnit.Framework
+open Microsoft.FSharp.Compiler.SourceCodeServices
open MonoDevelop.FSharp
open MonoDevelop.FSharp.MonoDevelop
open FsUnit
[<TestFixture>]
module TypeSignatureHelp =
+ let isFSharp (symbolUse: FSharpSymbolUse)=
+ match symbolUse with
+ | SymbolUse.MemberFunctionOrValue mfv ->
+ signatureHelp.isFSharp mfv
+ | _ -> failwith "Not a function"
+
let getSignatureHelp (source: string) =
let offset = source.IndexOf("$")
let source = source.Replace("$", "")
-
let doc = TestHelpers.createDoc source ""
let line, col, lineStr = doc.Editor.GetLineInfoFromOffset offset
- let res = doc.Ast.GetToolTip(line,col,lineStr) |> Async.RunSynchronously
- match res with
- | None -> failwith "did not find tooltip"
- | Some (tooltip, _) ->
- signatureHelp.extractSignature tooltip
+ let symbolUse = doc.Ast.GetSymbolAtLocation(line, col - 1, lineStr) |> Async.RunSynchronously
+ match symbolUse with
+ | Some symbolUse' ->
+ let res = doc.Ast.GetToolTip(line,col,lineStr) |> Async.RunSynchronously
+ match res with
+ | None -> failwith "did not find tooltip"
+ | Some (tooltip, _) ->
+ signatureHelp.extractSignature tooltip (isFSharp symbolUse')
+ | None -> failwith "No symbol found at location"
[<Test>]
let ``Function signature without parameters``() =
@@ -81,6 +91,19 @@ module TypeSignatureHelp =
|> getSignatureHelp |> should equal "(disposing: bool) -> unit"
[<Test>]
+ let ``Override BCL method with multiple parameters``() =
+ """
+ open System.IO
+ open System.Threading
+ open System.Threading.Tasks
+
+ type someType() =
+ inherit Stream()
+ override this.Cop$yToAsync(dest, bufferSize, token) = Task.FromResult 1
+ """
+ |> getSignatureHelp |> should equal "(destination: Stream, bufferSize: int, cancellationToken: CancellationToken) -> Task"
+
+ [<Test>]
let ``Tuple argument``() =
"let so$mefunc(x:int, y:int) = ()"
|> getSignatureHelp |> should equal "x:int * y:int -> unit"
@@ -88,4 +111,21 @@ module TypeSignatureHelp =
[<Test>]
let ``Tuple return``() =
"let so$mefunc(x:int, y:int) = x, y"
- |> getSignatureHelp |> should equal "x:int * y:int -> int * int" \ No newline at end of file
+ |> getSignatureHelp |> should equal "x:int * y:int -> int * int"
+
+ [<Test>]
+ let ``Double backticked function``() =
+ """
+ let ``double b$ackticked function``() = ()
+ """
+ |> getSignatureHelp
+ |> should equal "unit -> unit"
+
+ [<Test>]
+ let ``Nested function``() =
+ """
+ let someFunc() =
+ let nested$Func() = ()
+ """
+ |> getSignatureHelp
+ |> should equal "(unit -> unit)"
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs
index d5a7c34bf5..d31c0d1622 100644
--- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs
+++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs
@@ -13,7 +13,7 @@ open MonoDevelop.Ide.Editor.Extension
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.SourceCodeServices
-type SignatureHelpMarker(document, text, font, line) =
+type SignatureHelpMarker(document, text, font, line, isFromFSharpType) =
inherit TextLineMarker()
let mutable text' = text
let mutable font' = font
@@ -22,6 +22,7 @@ type SignatureHelpMarker(document, text, font, line) =
member x.Text with get() = text' and set(value) = text' <- value
// Font size can increase with zoom
member x.Font with get() = font' and set(value) = font' <- value
+ member x.IsFromFSharpType = isFromFSharpType
interface ITextLineMarker with
member x.Line with get() = line
@@ -56,18 +57,22 @@ module signatureHelp =
|> List.iter(fun m -> Runtime.RunInMainThread(fun() -> editor.RemoveMarker m) |> ignore)
markers.Length > 0
- let extractSignature (FSharpToolTipText tips) =
+ let extractSignature (FSharpToolTipText tips) isFromFSharpType =
let getSignature (str: string) =
let nlpos = str.IndexOfAny [|'\r';'\n'|]
let nlpos = if nlpos > 0 then nlpos else str.Length
- let parensPos = str.IndexOf '('
- if parensPos > 0 then
- // BCL tupled arguments method
- let str =
- str.[parensPos .. nlpos-1]
- |> String.replace "()" "unit"
- let lastColon = str.LastIndexOf ':'
- sprintf "%s->%s" str.[0 .. lastColon-1] str.[lastColon+1 .. str.Length-1]
+ if not isFromFSharpType then
+ let parensPos = str.IndexOf '('
+ if parensPos > 0 then
+ // BCL tupled arguments method
+ let str =
+ str.[parensPos .. nlpos-1]
+ |> String.replace "()" "unit"
+ let lastColon = str.LastIndexOf ':'
+ sprintf "%s->%s" str.[0 .. lastColon-1] str.[lastColon+1 .. str.Length-1]
+ else
+ let index = str.IndexOf ": "
+ str.[index+2 .. nlpos-1]
else
let index = str.IndexOf ": "
str.[index+2 .. nlpos-1]
@@ -82,6 +87,32 @@ module signatureHelp =
|> Option.map getSignature
|> Option.fill ""
+ let isFSharp (mfv: FSharpMemberOrFunctionOrValue) =
+ match mfv.IsOverrideOrExplicitInterfaceImplementation with
+ | true ->
+ match mfv.EnclosingEntity with
+ | Some ent ->
+ match ent.BaseType with
+ | Some baseType ->
+ match baseType.HasTypeDefinition with
+ | true -> baseType.TypeDefinition.IsFSharp
+ | false -> true
+ | None -> false
+ | None -> true
+ | false ->
+ match mfv.EnclosingEntity with
+ | Some ent -> ent.IsFSharp
+ | None -> true
+
+ let getFunctionInformation (symbolUse:FSharpSymbolUse) =
+ match symbolUse with
+ | SymbolUse.MemberFunctionOrValue mfv when symbolUse.IsFromDefinition ->
+ match mfv.FullTypeSafe with
+ | Some t when t.IsFunctionType ->
+ Some (symbolUse.RangeAlternate.StartLine, (symbolUse, isFSharp mfv))
+ | _ -> None
+ | _ -> None
+
let displaySignatures (context:DocumentContext) (editor:TextEditor) recalculate =
let data = editor.GetContent<ITextEditorDataProvider>().GetTextEditorData()
let editorFont = data.Options.Font
@@ -106,10 +137,7 @@ module signatureHelp =
let funs =
symbols
- |> List.filter(fun s -> match s with
- | SymbolUse.MemberFunctionOrValue mfv when s.IsFromDefinition -> mfv.FullType.IsFunctionType
- | _ -> false)
- |> List.map(fun f -> f.RangeAlternate.StartLine, f)
+ |> List.choose getFunctionInformation
|> Map.ofList
// remove any markers that are in the wrong positions
@@ -125,12 +153,12 @@ module signatureHelp =
if removedAny then
runInMainThread (fun() -> document.CommitMultipleLineUpdate(topVisibleLine, bottomVisibleLine))
- let addMarker text (lineNr:int) line =
- let newMarker = SignatureHelpMarker(document, text, font, line)
+ let addMarker text (lineNr:int) line isFromFSharpType =
+ let newMarker = SignatureHelpMarker(document, text, font, line, isFromFSharpType)
runInMainThread(fun() -> document.AddMarker(lineNr, newMarker))
newMarker
- funs |> Map.iter(fun _l f ->
+ funs |> Map.iter(fun _l (f, isFSharp) ->
let range = f.RangeAlternate
let lineOption = editor.GetLine range.StartLine |> Option.ofObj
@@ -140,13 +168,13 @@ module signatureHelp =
match marker, recalculate with
| Some marker', false when marker'.Text <> "" -> ()
| _ ->
- let marker = marker |> Option.getOrElse(fun() -> addMarker "" range.StartLine line)
+ let marker = marker |> Option.getOrElse(fun() -> addMarker "" range.StartLine line isFSharp)
if range.StartLine >= topVisibleLine && range.EndLine <= bottomVisibleLine then
async {
let lineText = editor.GetLineText(range.StartLine)
let! tooltip = ast.GetToolTip(range.StartLine, range.StartColumn, lineText)
tooltip |> Option.iter(fun (tooltip, lineNr) ->
- let text = extractSignature tooltip
+ let text = extractSignature tooltip marker.IsFromFSharpType
marker.Text <- text
marker.Font <- font
runInMainThread (fun() -> document.CommitLineUpdate lineNr))
diff --git a/main/external/nuget-binary b/main/external/nuget-binary
-Subproject ed064aeb537eaa60614b1f664b8054e33bc823c
+Subproject ebedbf8b90e2f138fa9bc120807abced307fbfb
diff --git a/main/src/addins/CSharpBinding/CSharpBinding.csproj b/main/src/addins/CSharpBinding/CSharpBinding.csproj
index a46b2df442..3e96de55c6 100644
--- a/main/src/addins/CSharpBinding/CSharpBinding.csproj
+++ b/main/src/addins/CSharpBinding/CSharpBinding.csproj
@@ -430,7 +430,6 @@
<Compile Include="MonoDevelop.CSharp.Features\GotoDefinition\GotoDefinitionHelpers.cs" />
<Compile Include="MonoDevelop.CSharp.Features\GotoDefinition\GotoDefinitionService.cs" />
<Compile Include="Util\PortingExtensions.cs" />
- <Compile Include="MonoDevelop.CSharp.Features\Formatter\SmartTokenFormatter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CSharpEditorFormattingService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CSharpEditorFormattingService.cs
index 42cd28f7ec..0ff246db8a 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CSharpEditorFormattingService.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/CSharpEditorFormattingService.cs
@@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory6.CSharp
public CSharpEditorFormattingService()
{
- _autoFormattingTriggerChars = ImmutableHashSet.CreateRange<char>(";}#ntef");
+ _autoFormattingTriggerChars = ImmutableHashSet.CreateRange<char>(";}#nte");
// add all auto formatting trigger to supported char
_supportedChars = _autoFormattingTriggerChars.Union("{}#nte:)");
@@ -185,56 +185,56 @@ namespace ICSharpCode.NRefactory6.CSharp
return token;
}
- public static async Task<IList<TextChange>> FormatTokenAsync(Document document, SyntaxToken token, IEnumerable<IFormattingRule> formattingRules, CancellationToken cancellationToken)
- {
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var formatter = CreateSmartTokenFormatter(document.Project.Solution.Workspace.Options, formattingRules, root);
- var changes = await formatter.FormatTokenAsync(document.Project.Solution.Workspace, token, cancellationToken);
- return changes;
- }
-
- static SmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable<IFormattingRule> formattingRules, SyntaxNode root)
- {
- return new SmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root);
- }
-
- public static async Task<IList<TextChange>> FormatRangeAsync(
- Document document, SyntaxToken endToken, IEnumerable<IFormattingRule> formattingRules,
- CancellationToken cancellationToken)
- {
- if (!IsEndToken(endToken))
- {
- return SpecializedCollections.EmptyList<TextChange>();
- }
-
- var tokenRange = FormattingRangeHelper.FindAppropriateRange(endToken);
- if (tokenRange == null || tokenRange.Value.Item1.Equals(tokenRange.Value.Item2))
- {
- return SpecializedCollections.EmptyList<TextChange>();
- }
-
- if (IsInvalidTokenKind(tokenRange.Value.Item1) || IsInvalidTokenKind(tokenRange.Value.Item2))
- {
- return SpecializedCollections.EmptyList<TextChange>();
- }
-
- var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var formatter = new SmartTokenFormatter(document.Project.Solution.Workspace.Options, formattingRules, (CompilationUnitSyntax)root);
-
- var changes = formatter.FormatRange(document.Project.Solution.Workspace, tokenRange.Value.Item1, tokenRange.Value.Item2, cancellationToken);
- return changes;
- }
-
- static bool IsEndToken(SyntaxToken endToken)
- {
- if (endToken.IsKind(SyntaxKind.OpenBraceToken))
- {
- return false;
- }
-
- return true;
- }
-
+ // private async Task<IList<TextChange>> FormatTokenAsync(Document document, SyntaxToken token, IEnumerable<IFormattingRule> formattingRules, CancellationToken cancellationToken)
+ // {
+ // var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
+ // var formatter = CreateSmartTokenFormatter(document.Project.Solution.Workspace.Options, formattingRules, root);
+ // var changes = formatter.FormatToken(document.Project.Solution.Workspace, token, cancellationToken);
+ // return changes;
+ // }
+ //
+ // private ISmartTokenFormatter CreateSmartTokenFormatter(OptionSet optionSet, IEnumerable<IFormattingRule> formattingRules, SyntaxNode root)
+ // {
+ // return new SmartTokenFormatter(optionSet, formattingRules, (CompilationUnitSyntax)root);
+ // }
+ //
+ // private async Task<IList<TextChange>> FormatRangeAsync(
+ // Document document, SyntaxToken endToken, IEnumerable<IFormattingRule> formattingRules,
+ // CancellationToken cancellationToken)
+ // {
+ // if (!IsEndToken(endToken))
+ // {
+ // return SpecializedCollections.EmptyList<TextChange>();
+ // }
+ //
+ // var tokenRange = FormattingRangeHelper.FindAppropriateRange(endToken);
+ // if (tokenRange == null || tokenRange.Value.Item1.Equals(tokenRange.Value.Item2))
+ // {
+ // return SpecializedCollections.EmptyList<TextChange>();
+ // }
+ //
+ // if (IsInvalidTokenKind(tokenRange.Value.Item1) || IsInvalidTokenKind(tokenRange.Value.Item2))
+ // {
+ // return SpecializedCollections.EmptyList<TextChange>();
+ // }
+ //
+ // var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
+ // var formatter = new SmartTokenFormatter(document.Project.Solution.Workspace.Options, formattingRules, (CompilationUnitSyntax)root);
+ //
+ // var changes = formatter.FormatRange(document.Project.Solution.Workspace, tokenRange.Value.Item1, tokenRange.Value.Item2, cancellationToken);
+ // return changes;
+ // }
+ //
+ // private bool IsEndToken(SyntaxToken endToken)
+ // {
+ // if (endToken.IsKind(SyntaxKind.OpenBraceToken))
+ // {
+ // return false;
+ // }
+ //
+ // return true;
+ // }
+ //
public bool ValidSingleOrMultiCharactersTokenKind(char typedChar, SyntaxKind kind)
{
ImmutableHashSet<SyntaxKind> set;
@@ -247,7 +247,7 @@ namespace ICSharpCode.NRefactory6.CSharp
return set.Contains(kind);
}
- public static bool IsInvalidToken(char typedChar, SyntaxToken token)
+ public bool IsInvalidToken(char typedChar, SyntaxToken token)
{
string text = null;
if (IsInvalidToken(token, ref text))
@@ -258,7 +258,7 @@ namespace ICSharpCode.NRefactory6.CSharp
return text[0] != typedChar;
}
- public static bool IsInvalidToken(SyntaxToken token, ref string text)
+ public bool IsInvalidToken(SyntaxToken token, ref string text)
{
if (IsInvalidTokenKind(token))
{
@@ -274,7 +274,7 @@ namespace ICSharpCode.NRefactory6.CSharp
return false;
}
- static bool IsInvalidTokenKind(SyntaxToken token)
+ private bool IsInvalidTokenKind(SyntaxToken token)
{
// invalid token to be formatted
return token.IsKind(SyntaxKind.None) ||
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/SmartTokenFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/SmartTokenFormatter.cs
deleted file mode 100644
index f7c2bf793b..0000000000
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Formatter/SmartTokenFormatter.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Formatting;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Formatting;
-using Microsoft.CodeAnalysis.Formatting.Rules;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
-
-namespace ICSharpCode.NRefactory6.CSharp
-{
- internal class SmartTokenFormatter
- {
- private readonly OptionSet _optionSet;
- private readonly IEnumerable<IFormattingRule> _formattingRules;
-
- private readonly CompilationUnitSyntax _root;
-
- public SmartTokenFormatter(
- OptionSet optionSet,
- IEnumerable<IFormattingRule> formattingRules,
- CompilationUnitSyntax root)
- {
- Contract.ThrowIfNull(optionSet);
- Contract.ThrowIfNull(formattingRules);
- Contract.ThrowIfNull(root);
-
- _optionSet = optionSet;
- _formattingRules = formattingRules;
-
- _root = root;
- }
-
- public IList<TextChange> FormatRange(
- Workspace workspace, SyntaxToken startToken, SyntaxToken endToken, CancellationToken cancellationToken)
- {
- Contract.ThrowIfTrue(startToken.Kind() == SyntaxKind.None || startToken.Kind() == SyntaxKind.EndOfFileToken);
- Contract.ThrowIfTrue(endToken.Kind() == SyntaxKind.None || endToken.Kind() == SyntaxKind.EndOfFileToken);
-
- var smartTokenformattingRules = _formattingRules;
- var common = startToken.GetCommonRoot(endToken);
-
- // if there are errors, do not touch lines
- // Exception 1: In the case of try-catch-finally block, a try block without a catch/finally block is considered incomplete
- // but we would like to apply line operation in a completed try block even if there is no catch/finally block
- // Exception 2: Similar behavior for do-while
- if (common.ContainsDiagnostics && !CloseBraceOfTryOrDoBlock(endToken))
- {
- smartTokenformattingRules = (new NoLineChangeFormattingRule()).Concat(_formattingRules);
- }
-
- return Formatter.GetFormattedTextChanges(_root, new TextSpan[] { TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End) }, workspace, _optionSet, smartTokenformattingRules, cancellationToken);
- }
-
- private bool CloseBraceOfTryOrDoBlock(SyntaxToken endToken)
- {
- return endToken.IsKind(SyntaxKind.CloseBraceToken) &&
- endToken.Parent.IsKind(SyntaxKind.Block) &&
- (endToken.Parent.IsParentKind(SyntaxKind.TryStatement) || endToken.Parent.IsParentKind(SyntaxKind.DoStatement));
- }
-
- public async Task<IList<TextChange>> FormatTokenAsync(
- Workspace workspace, SyntaxToken token, CancellationToken cancellationToken)
- {
- Contract.ThrowIfTrue(token.Kind() == SyntaxKind.None || token.Kind() == SyntaxKind.EndOfFileToken);
-
- // get previous token
- var previousToken = token.GetPreviousToken(includeZeroWidth: true);
- if (previousToken.Kind() == SyntaxKind.None)
- {
- // no previous token. nothing to format
- return SpecializedCollections.EmptyList<TextChange>();
- }
-
- // This is a heuristic to prevent brace completion from breaking user expectation/muscle memory in common scenarios (see Devdiv:823958).
- // Formatter uses FindToken on the position, which returns token to left, if there is nothing to the right and returns token to the right
- // if there exists one. If the shape is "{|}", we're including '}' in the formatting range. Avoid doing that to improve verbatim typing
- // in the following special scenarios.
- int adjustedEndPosition = token.Span.End;
- if (token.IsKind(SyntaxKind.OpenBraceToken) &&
- (token.Parent.IsInitializerForArrayOrCollectionCreationExpression() ||
- token.Parent is AnonymousObjectCreationExpressionSyntax))
- {
- var nextToken = token.GetNextToken(includeZeroWidth: true);
- if (nextToken.IsKind(SyntaxKind.CloseBraceToken))
- {
- // Format upto '{' and exclude '}'
- adjustedEndPosition = token.SpanStart;
- }
- }
-
- var smartTokenformattingRules = (new SmartTokenFormattingRule()).Concat(_formattingRules);
- var adjustedStartPosition = previousToken.SpanStart;
- var indentStyle = _optionSet.GetOption(FormattingOptions.SmartIndent, LanguageNames.CSharp);
- if (token.IsKind(SyntaxKind.OpenBraceToken) &&
- indentStyle != FormattingOptions.IndentStyle.Smart)
- {
- var text = await token.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
- if (token.IsFirstTokenOnLine(text))
- {
- adjustedStartPosition = token.SpanStart;
- }
- }
-
- return await Formatter.GetFormattedTextChangesAsync(_root,
- new TextSpan[] { TextSpan.FromBounds(adjustedStartPosition, adjustedEndPosition) },
- workspace, _optionSet, smartTokenformattingRules, cancellationToken).ConfigureAwait(false);
- }
-
- private class NoLineChangeFormattingRule : AbstractFormattingRule
- {
- public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken previousToken, SyntaxToken currentToken, OptionSet optionSet, NextOperation<AdjustNewLinesOperation> nextOperation)
- {
- // no line operation. no line changes what so ever
- var lineOperation = base.GetAdjustNewLinesOperation(previousToken, currentToken, optionSet, nextOperation);
- if (lineOperation != null)
- {
- // ignore force if same line option
- if (lineOperation.Option == AdjustNewLinesOption.ForceLinesIfOnSingleLine)
- {
- return null;
- }
-
- // basically means don't ever put new line if there isn't already one, but do
- // indentation.
- return FormattingOperations.CreateAdjustNewLinesOperation(line: 0, option: AdjustNewLinesOption.PreserveLines);
- }
-
- return null;
- }
- }
-
- private class SmartTokenFormattingRule : NoLineChangeFormattingRule
- {
- public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, SyntaxToken lastToken, OptionSet optionSet, NextAction<SuppressOperation> nextOperation)
- {
- // don't suppress anything
- }
-
- public override AdjustSpacesOperation GetAdjustSpacesOperation(SyntaxToken previousToken, SyntaxToken currentToken, OptionSet optionSet, NextOperation<AdjustSpacesOperation> nextOperation)
- {
- var spaceOperation = base.GetAdjustSpacesOperation(previousToken, currentToken, optionSet, nextOperation);
-
- // if there is force space operation, convert it to ForceSpaceIfSingleLine operation.
- // (force space basically means remove all line breaks)
- if (spaceOperation != null && spaceOperation.Option == AdjustSpacesOption.ForceSpaces)
- {
- return FormattingOperations.CreateAdjustSpacesOperation(spaceOperation.Space, AdjustSpacesOption.ForceSpacesIfOnSingleLine);
- }
-
- return spaceOperation;
- }
- }
- }
-}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
index 8085f90997..e85128bbe7 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
@@ -13,10 +13,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -45,7 +45,6 @@ using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Options;
using MonoDevelop.Refactoring;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace MonoDevelop.CSharp.Formatting
{
@@ -191,7 +190,7 @@ namespace MonoDevelop.CSharp.Formatting
}
IdeApp.Workspace.ActiveConfigurationChanged -= HandleTextOptionsChanged;
CompletionWindowManager.WindowClosed -= CompletionWindowManager_WindowClosed;
-
+
stateTracker = null;
base.Dispose ();
}
@@ -414,7 +413,7 @@ namespace MonoDevelop.CSharp.Formatting
}
return retval;
}
-
+
if (descriptor.SpecialKey == SpecialKey.Tab && descriptor.ModifierKeys == ModifierKeys.None && !CompletionWindowManager.IsVisible) {
SafeUpdateIndentEngine (Editor.CaretOffset);
if (stateTracker.IsInsideStringLiteral && !Editor.IsSomethingSelected) {
@@ -463,9 +462,9 @@ namespace MonoDevelop.CSharp.Formatting
bool returnBetweenBraces =
- descriptor.SpecialKey == SpecialKey.Return &&
- descriptor.ModifierKeys == ModifierKeys.None &&
- Editor.CaretOffset > 0 && Editor.CaretOffset < Editor.Length &&
+ descriptor.SpecialKey == SpecialKey.Return &&
+ descriptor.ModifierKeys == ModifierKeys.None &&
+ Editor.CaretOffset > 0 && Editor.CaretOffset < Editor.Length &&
Editor.GetCharAt (Editor.CaretOffset - 1) == '{' && Editor.GetCharAt (Editor.CaretOffset) == '}' && !stateTracker.IsInsideOrdinaryCommentOrString;
bool automaticReindent;
@@ -485,7 +484,7 @@ namespace MonoDevelop.CSharp.Formatting
//handle inserted characters
if (Editor.CaretOffset <= 0 || Editor.IsSomethingSelected)
return retval;
-
+
lastCharInserted = TranslateKeyCharForIndenter (descriptor.SpecialKey, descriptor.KeyChar, Editor.GetCharAt (Editor.CaretOffset - 1));
if (lastCharInserted == '\0')
return retval;
@@ -510,7 +509,7 @@ namespace MonoDevelop.CSharp.Formatting
}
}
//reindent the line after the insertion, if needed
- //N.B. if the engine says we need to reindent, make sure that it's because a char was
+ //N.B. if the engine says we need to reindent, make sure that it's because a char was
//inserted rather than just updating the stack due to moving around
SafeUpdateIndentEngine (Editor.CaretOffset);
@@ -558,7 +557,7 @@ namespace MonoDevelop.CSharp.Formatting
CheckXmlCommentCloseTag (descriptor.KeyChar);
HandleOnTheFlyFormatting (descriptor);
-
+
return result;
}
@@ -584,12 +583,7 @@ namespace MonoDevelop.CSharp.Formatting
using (var undo = Editor.OpenUndoGroup ()) {
if (OnTheFlyFormatting && Editor != null && Editor.EditMode == EditMode.Edit) {
var oldVersion = Editor.Version;
- int start = token.SpanStart;
- var parentStatement = token.Parent.AncestorsAndSelf().OfType<StatementSyntax>().FirstOrDefault();
- if (parentStatement != null)
- start = parentStatement.SpanStart;
- OnTheFlyFormatter.Format(Editor, DocumentContext, start, Editor.CaretOffset, exact:true, optionSet: optionSet);
- //OnTheFlyFormatter.FormatStatmentAt (Editor, DocumentContext, Editor.CaretLocation, optionSet: optionSet);
+ OnTheFlyFormatter.FormatStatmentAt (Editor, DocumentContext, Editor.CaretLocation, optionSet: optionSet);
if (oldVersion.CompareAge (Editor.Version) != 0)
CompletionWindowManager.HideWindow ();
}
@@ -617,7 +611,7 @@ namespace MonoDevelop.CSharp.Formatting
var tokenRange = Microsoft.CodeAnalysis.CSharp.Utilities.FormattingRangeHelper.FindAppropriateRange (token);
if (tokenRange == null || !tokenRange.HasValue || tokenRange.Value.Item1.Equals (tokenRange.Value.Item2))
return;
-
+
var value = tokenRange.Value;
using (var undo = Editor.OpenUndoGroup ()) {
OnTheFlyFormatter.Format (Editor, DocumentContext, value.Item1.SpanStart, value.Item2.Span.End, optionSet: optionSet);
@@ -635,7 +629,7 @@ namespace MonoDevelop.CSharp.Formatting
return;
string text = null;
- if (CSharpEditorFormattingService.IsInvalidToken (token, ref text))
+ if (service.IsInvalidToken (token, ref text))
return;
// Check to see if the token is ')' and also the parent is a using statement. If not, bail
if (CSharpEditorFormattingService.TokenShouldNotFormatOnReturn (token))
@@ -700,7 +694,7 @@ namespace MonoDevelop.CSharp.Formatting
lastNonWsChar = ch;
}
return false;
- });
+ });
// if the line ends with ';' the line end is not the correct place for a new semicolon.
if (lastNonWsChar == ';')
return false;
@@ -782,7 +776,7 @@ namespace MonoDevelop.CSharp.Formatting
reIndent = true;
break;
case '\n':
- if (completionWindowWasVisible) // \n is handled by an open completion window
+ if (completionWindowWasVisible) // \n is handled by an open completion window
return;
if (FixLineStart (Editor, stateTracker, Editor.OffsetToLineNumber (stateTracker.Offset)))
return;
@@ -887,7 +881,7 @@ namespace MonoDevelop.CSharp.Formatting
} catch (Exception e) {
LoggingService.LogError ("Exception during indentation", e);
}
-
+
int pos = line.Offset;
string curIndent = line.GetIndentation (Editor);
int nlwsp = curIndent.Length;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs
index a99fadc5bf..74c1e980dd 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs
@@ -26,11 +26,7 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Threading;
-using ICSharpCode.NRefactory6.CSharp;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
@@ -81,10 +77,8 @@ namespace MonoDevelop.CSharp.Formatting
try {
var syntaxTree = await analysisDocument.GetSyntaxTreeAsync ();
var root = syntaxTree.GetRoot ();
- bool smartIndentOnly = false;
- var token = root.FindToken(endOffset);
- smartIndentOnly = token.IsKind(SyntaxKind.CloseBraceToken);
if (formatLastStatementOnly) {
+ var token = root.FindToken (endOffset);
var tokens = Microsoft.CodeAnalysis.CSharp.Utilities.FormattingRangeHelper.FindAppropriateRange (token);
if (tokens.HasValue) {
span = new TextSpan (tokens.Value.Item1.SpanStart, editor.CaretOffset - tokens.Value.Item1.SpanStart);
@@ -101,21 +95,8 @@ namespace MonoDevelop.CSharp.Formatting
optionSet = policy.CreateOptions (textPolicy);
}
var rules = Formatter.GetDefaultFormattingRules (analysisDocument);
- IList<TextChange> changes;
-
- if (smartIndentOnly) {
- // if we're only doing smart indent, then ignore all edits to this token that occur before
- // the span of the token. They're irrelevant and may screw up other code the user doesn't
- // want touched.
- var tokenEdits = await CSharpEditorFormattingService.FormatTokenAsync(analysisDocument, token, rules, default(CancellationToken)).ConfigureAwait(false);
- changes = tokenEdits.Where(t => t.Span.Start >= token.FullSpan.Start).ToList();
- } else {
- changes = await CSharpEditorFormattingService.FormatRangeAsync(analysisDocument, token, rules, default(CancellationToken)).ConfigureAwait(false);
- if (changes.Count == 0)
- changes = await CSharpEditorFormattingService.FormatTokenAsync(analysisDocument, token, rules, default(CancellationToken)).ConfigureAwait(false);
- }
-
- editor.ApplyTextChanges(changes);
+ var changes = Formatter.GetFormattedTextChanges (root, SpecializedCollections.SingletonEnumerable (span), context.RoslynWorkspace, optionSet, rules, default(CancellationToken));
+ editor.ApplyTextChanges (changes);
} catch (Exception e) {
LoggingService.LogError ("Error in on the fly formatter", e);
}
diff --git a/main/src/addins/MacPlatform/MacExternalConsoleProcess.cs b/main/src/addins/MacPlatform/MacExternalConsoleProcess.cs
index a089a5dc61..3fd6f0b506 100644
--- a/main/src/addins/MacPlatform/MacExternalConsoleProcess.cs
+++ b/main/src/addins/MacPlatform/MacExternalConsoleProcess.cs
@@ -145,12 +145,14 @@ bash pause on exit trick
};
if (pauseWhenFinished)
- sb.Append ("; echo; read -p 'Press any key to continue...' -n1");
+ sb.Append ("; echo; read -p \"Press any key to continue...\" -n1");
sb.Append ("; exit");
}
//run the command in Terminal.app and extract tab and window IDs
- var ret = AppleScript.Run ("tell app \"{0}\" to do script \"{1}\"", TERMINAL_APP, Escape (sb.ToString ()));
+ // run the command inside Bash because we do echo $? and that is a bash extension and breaks when people
+ // use other shells such as zsh or fish. https://bugzilla.xamarin.com/show_bug.cgi?id=56053
+ var ret = AppleScript.Run ("tell app \"{0}\" to do script \"bash -c '{1}'; exit\"", TERMINAL_APP, Escape (sb.ToString ()));
int i = ret.IndexOf ("of", StringComparison.Ordinal);
tabId = ret.Substring (0, i -1);
windowId = ret.Substring (i + 3);
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTests.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTests.cs
index 6722455f78..ed75ec4dd2 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTests.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Tests/MonoDevelop.DotNetCore.Tests/DotNetCoreProjectTests.cs
@@ -190,5 +190,30 @@ namespace MonoDevelop.DotNetCore.Tests
Assert.IsNotNull (jsonNetReferenceLibB);
Assert.IsNotNull (jsonNetReferenceLibC);
}
+
+ /// <summary>
+ /// Mirror Visual Studio on Windows behaviour where a .NET Standard project or a .NET Core
+ /// project can add a reference to any PCL project.
+ /// </summary>
+ [Test]
+ public async Task CanReference_PortableClassLibrary_FromNetStandardOrNetCoreAppProject ()
+ {
+ string solutionFileName = Util.GetSampleProject ("dotnetcore-pcl", "dotnetcore-pcl.sln");
+ var solution = (Solution) await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solutionFileName);
+ var pclProject = solution.FindProjectByName ("PclProfile111") as DotNetProject;
+ var netStandardProject = solution.FindProjectByName ("NetStandard14") as DotNetProject;
+ var netCoreProject = solution.FindProjectByName ("NetCore11") as DotNetProject;
+
+ string reason = null;
+ bool canReferenceFromNetStandard = netStandardProject.CanReferenceProject (pclProject, out reason);
+ bool canReferenceFromNetCore = netCoreProject.CanReferenceProject (pclProject, out reason);
+ bool canReferenceNetCoreFromNetStandard = netStandardProject.CanReferenceProject (netCoreProject, out reason);
+ bool canReferenceNetStandardFromNetCore = netCoreProject.CanReferenceProject (netStandardProject, out reason);
+
+ Assert.IsTrue (canReferenceFromNetStandard);
+ Assert.IsTrue (canReferenceFromNetCore);
+ Assert.IsFalse (canReferenceNetCoreFromNetStandard);
+ Assert.IsTrue (canReferenceNetStandardFromNetCore);
+ }
}
} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
index c62b4595f5..b981c5f589 100644
--- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
+++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreProjectExtension.cs
@@ -98,6 +98,9 @@ namespace MonoDevelop.DotNetCore
bool CanReferenceProject (DotNetProject targetProject)
{
+ if (targetProject.IsPortableLibrary)
+ return true;
+
if (!targetProject.TargetFramework.IsNetStandard ())
return false;
diff --git a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingNuGetProject.cs b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingNuGetProject.cs
index 34d7a274bf..2db0f33801 100644
--- a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingNuGetProject.cs
+++ b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingNuGetProject.cs
@@ -55,14 +55,17 @@ namespace MonoDevelop.Packaging
InternalMetadata.Add (NuGetProjectMetadataKeys.UniqueName, project.Name);
}
- public override async Task<IEnumerable<NuGet.Packaging.PackageReference>> GetInstalledPackagesAsync (CancellationToken token)
+ public override Task<IEnumerable<NuGet.Packaging.PackageReference>> GetInstalledPackagesAsync (CancellationToken token)
{
- return await Runtime.RunInMainThread (() => {
- return project
- .PackageReferences
- .Select (packageReference => packageReference.ToNuGetPackageReference ())
- .ToList ();
- });
+ return Task.FromResult (GetPackageReferences ());
+ }
+
+ IEnumerable<NuGet.Packaging.PackageReference> GetPackageReferences ()
+ {
+ return project
+ .PackageReferences
+ .Select (packageReference => packageReference.ToNuGetPackageReference ())
+ .ToList ();
}
public override async Task<bool> InstallPackageAsync (
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
index 07c7c3f684..73588a7786 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
@@ -400,6 +400,7 @@ namespace MonoDevelop.SourceEditor
if (extension is TopLevelWidgetExtension) {
var widgetExtension = (TopLevelWidgetExtension)extension;
Widget w = widgetExtension.CreateWidget ();
+ w.SizeAllocated += (o, args) => UpdateWidgetPosition(widgetExtension, w);
int x, y;
if (!CalcWidgetPosition (widgetExtension, w, out x, out y)) {
w.Destroy ();
@@ -466,14 +467,19 @@ namespace MonoDevelop.SourceEditor
void UpdateWidgetPositions ()
{
foreach (var e in widgetExtensions) {
- int x,y;
- if (CalcWidgetPosition ((TopLevelWidgetExtension)e.Key, e.Value, out x, out y))
- widget.TextEditor.TextArea.MoveTopLevelWidget (e.Value, x, y);
- else
- e.Value.Hide ();
+ UpdateWidgetPosition (e.Key, e.Value);
}
}
+ void UpdateWidgetPosition (TopLevelWidgetExtension widgetExtension, Widget w)
+ {
+ int x, y;
+ if (CalcWidgetPosition(widgetExtension, w, out x, out y))
+ widget.TextEditor.TextArea.MoveTopLevelWidget(w, x, y);
+ else
+ w.Hide();
+ }
+
bool CalcWidgetPosition (TopLevelWidgetExtension widgetExtension, Widget w, out int x, out int y)
{
DocumentLine line = widget.TextEditor.Document.GetLine (widgetExtension.Line);
diff --git a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorOptions.cs b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorOptions.cs
index b63ccba348..7e9e50ae55 100644
--- a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorOptions.cs
+++ b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorOptions.cs
@@ -28,7 +28,6 @@ using System;
using System.Diagnostics;
using Mono.TextEditor.Highlighting;
using MonoDevelop.Ide.Editor.Highlighting;
-using MonoDevelop.Core;
namespace Mono.TextEditor
{
@@ -397,7 +396,7 @@ namespace Mono.TextEditor
try {
font = Pango.FontDescription.FromString (FontName);
} catch {
- LoggingService.LogError("Could not load text editor font");
+ Console.WriteLine ("Could not load font: {0}", FontName);
}
if (font == null || String.IsNullOrEmpty (font.Family))
font = Pango.FontDescription.FromString (DEFAULT_FONT);
@@ -428,7 +427,7 @@ namespace Mono.TextEditor
if (!string.IsNullOrEmpty (GutterFontName))
gutterFont = Pango.FontDescription.FromString (GutterFontName);
} catch {
- LoggingService.LogError("Error while loading gutter font.");
+ Console.WriteLine ("Could not load gutter font: {0}", GutterFontName);
}
if (gutterFont == null || String.IsNullOrEmpty (gutterFont.Family))
gutterFont = Gtk.Widget.DefaultStyle.FontDescription.Copy ();
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
index d184482d7f..91a3739497 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
@@ -3321,14 +3321,31 @@ namespace MonoDevelop.Projects
if (!it.IsWildcardItem || it.ParentProject == msproject) {
msproject.RemoveItem (it);
- // Remove any "Remove" items that match if the file has been deleted.
- var file = loadedProjectItems.FirstOrDefault (i => i.ItemName == it.Name && i.Include == it.Include) as ProjectFile;
- if (file != null && !File.Exists (file.FilePath)) {
- var toRemove = msproject.GetAllItems ().Where (i => i.Remove == it.Include).ToList ();
- foreach (var item in toRemove) {
- msproject.RemoveItem (item);
+ var file = loadedProjectItems.FirstOrDefault (i => {
+ return i.ItemName == it.Name && (i.Include == it.Include || i.Include == it.Update);
+ }) as ProjectFile;
+ if (file != null) {
+ if (File.Exists (file.FilePath)) {
+ AddRemoveItemIfMissing (msproject, file);
+ } else {
+ // Remove any "Remove" items that match if the file has been deleted.
+ var toRemove = msproject.GetAllItems ().Where (i => i.Remove == it.Include).ToList ();
+ foreach (var item in toRemove) {
+ msproject.RemoveItem (item);
+ }
}
}
+ } else if (it.IsWildcardItem && UseAdvancedGlobSupport) {
+ // Add "Remove" items if the file is not deleted.
+ foreach (var file in loadedProjectItems.Where (i => i.WildcardItem == it).OfType<ProjectFile> ()) {
+ if (File.Exists (file.FilePath)) {
+ AddRemoveItemIfMissing (msproject, file);
+ }
+ // Ensure "Update" items are removed from the project. If there are no
+ // files left in the project for the glob then the "Update" item will
+ // not have been removed.
+ RemoveUpdateItemsForFile (msproject, it, file);
+ }
}
}
loadedItems.Remove (it);
@@ -3463,6 +3480,23 @@ namespace MonoDevelop.Projects
}
}
+ static void AddRemoveItemIfMissing (MSBuildProject msproject, ProjectFile file)
+ {
+ if (!msproject.GetAllItems ().Where (i => i.Remove == file.Include).Any ()) {
+ var removeItem = new MSBuildItem (file.ItemName) { Remove = file.Include };
+ msproject.AddItem (removeItem);
+ }
+ }
+
+ void RemoveUpdateItemsForFile (MSBuildProject msproject, MSBuildItem globItem, ProjectFile file)
+ {
+ foreach (var updateItem in FindUpdateItemsForItem (globItem, file.Include).ToList ()) {
+ if (updateItem.ParentGroup != null) {
+ msproject.RemoveItem (updateItem);
+ }
+ }
+ }
+
void PurgeUpdatePropertiesSetInSourceItems (MSBuildItem buildItem, IEnumerable<MSBuildItem> sourceItems, HashSet<string> propertiesAlreadySet)
{
// When the project item is saved to an Update item, it will write values that were set by the Include item and other Update items defined before this Update item.
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/DropDownBoxListWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/DropDownBoxListWindow.cs
index eb1620c397..0f737e6764 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/DropDownBoxListWindow.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/DropDownBoxListWindow.cs
@@ -244,9 +244,7 @@ namespace MonoDevelop.Components
this.win = win;
this.Events = Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.LeaveNotifyMask;
this.CanFocus = true;
- layout = new Pango.Layout (this.PangoContext);
- CalcRowHeight ();
- CalcVisibleRows ();
+ UpdateStyle ();
CalcAccessibility ();
}
@@ -451,7 +449,7 @@ namespace MonoDevelop.Components
int iconWidth = icon != null ? (int)icon.Width : 0;
layout.Ellipsize = Pango.EllipsizeMode.End;
- layout.Width = (Allocation.Width - xpos - iconWidth - iconTextDistance) * (int)Pango.Scale.PangoScale;
+ layout.Width = (Allocation.Width - xpos - padding - iconWidth - iconTextDistance) * (int)Pango.Scale.PangoScale;
layout.SetMarkup (PathBar.GetFirstLineFromMarkup (text));
int wi, he, typos, iypos;
@@ -537,13 +535,13 @@ namespace MonoDevelop.Components
longest = i;
}
}
- layout.SetMarkup (win.DataProvider.GetMarkup (longest) ?? "&lt;null&gt;");
- Pango.Rectangle inkRec, logRect;
- layout.GetExtents (out inkRec, out logRect);
+ layout.Width = -1;
+ layout.SetMarkup (longestText ?? "&lt;null&gt;");
+ int w, h;
+ layout.GetPixelSize(out w, out h);
var icon = win.DataProvider.GetIcon (longest);
int iconWidth = icon != null ? (int) icon.Width : 24;
- return iconWidth + iconTextDistance + padding * 2 + leftXAlignment +
- (int)(inkRec.Width / Pango.Scale.PangoScale);
+ return iconWidth + iconTextDistance + (padding * 2) + leftXAlignment + w;
}
@@ -580,7 +578,8 @@ namespace MonoDevelop.Components
void UpdateStyle ()
{
- GdkWindow.Background = Style.Base (StateType.Normal);
+ if (IsRealized)
+ GdkWindow.Background = Style.Base (StateType.Normal);
if (layout != null)
layout.Dispose ();
layout = new Pango.Layout (PangoContext);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/xml/syntaxes/xml.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/xml/syntaxes/xml.json
index dd66c8df2b..cc64154b27 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/xml/syntaxes/xml.json
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/xml/syntaxes/xml.json
@@ -51,6 +51,7 @@
"pubxml",
"pubxml.user",
"rdf",
+ "resx",
"rng",
"rss",
"sdf",
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextStylePolicy.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextStylePolicy.cs
index 5ebb54727c..71b51040d2 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextStylePolicy.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextStylePolicy.cs
@@ -51,14 +51,25 @@ namespace MonoDevelop.Ide.Gui.Content
EolMarker = eolMarker;
}
- public TextStylePolicy ()
+ public TextStylePolicy()
{
FileWidth = 120;
TabWidth = 4;
IndentWidth = 4;
RemoveTrailingWhitespace = true;
}
-
+
+ public TextStylePolicy(TextStylePolicy other)
+ {
+ FileWidth = other.FileWidth;
+ TabWidth = other.TabWidth;
+ IndentWidth = other.IndentWidth;
+ TabsToSpaces = other.TabsToSpaces;
+ NoTabsAfterNonTabs = other.NoTabsAfterNonTabs;
+ RemoveTrailingWhitespace = other.RemoveTrailingWhitespace;
+ EolMarker = other.EolMarker;
+ }
+
[ItemProperty]
public int FileWidth { get; private set; }
@@ -79,7 +90,25 @@ namespace MonoDevelop.Ide.Gui.Content
[ItemProperty]
public EolMarker EolMarker { get; private set; }
-
+
+ public TextStylePolicy WithTabsToSpaces(bool tabToSpaces)
+ {
+ if (tabToSpaces == TabsToSpaces)
+ return this;
+ return new TextStylePolicy(this) {
+ TabsToSpaces = tabToSpaces
+ };
+ }
+
+ public TextStylePolicy WithTabWidth(int tabWidth)
+ {
+ if (tabWidth == TabWidth)
+ return this;
+ return new TextStylePolicy(this) {
+ TabWidth = tabWidth
+ };
+ }
+
public static string GetEolMarker (EolMarker eolMarker)
{
switch (eolMarker) {
@@ -107,4 +136,4 @@ namespace MonoDevelop.Ide.Gui.Content
&& other.RemoveTrailingWhitespace == RemoveTrailingWhitespace && other.EolMarker == EolMarker && other.IndentWidth == IndentWidth;
}
}
-}
+} \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
index b887e4d0da..687459bc2f 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
@@ -840,8 +840,11 @@ namespace MonoDevelop.Ide.Gui
protected virtual async Task OnClosing (WorkbenchWindowEventArgs e)
{
if (Closing != null) {
- foreach (var handler in Closing.GetInvocationList ().Cast<WorkbenchWindowAsyncEventHandler> ())
+ foreach (var handler in Closing.GetInvocationList ().Cast<WorkbenchWindowAsyncEventHandler> ()) {
await handler (this, e);
+ if (e.Cancel)
+ break;
+ }
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
index 1e7a7202dc..6da60407f4 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
@@ -860,21 +860,23 @@ namespace MonoDevelop.Ide.Gui
GettextCatalog.GetString ("If you don't save, all changes will be permanently lost."),
AlertButton.CloseWithoutSave, AlertButton.Cancel, viewContent.IsUntitled ? AlertButton.SaveAs : AlertButton.Save);
if (result == AlertButton.Save) {
- args.Cancel = true;
- await FindDocument (window).Save ();
- viewContent.IsDirty = false;
- await window.CloseWindow (true);
- return;
+ var doc = FindDocument (window);
+ await doc.Save ();
+ if (viewContent.IsDirty) {
+ // This may happen if the save operation failed
+ args.Cancel = true;
+ doc.Select ();
+ return;
+ }
} else if (result == AlertButton.SaveAs) {
- args.Cancel = true;
- var resultSaveAs = await FindDocument (window).SaveAs ();
- if (resultSaveAs) {
- viewContent.IsDirty = false;
- await window.CloseWindow (true);
- } else {
- window.SelectWindow ();
+ var doc = FindDocument (window);
+ var resultSaveAs = await doc.SaveAs ();
+ if (!resultSaveAs || viewContent.IsDirty) {
+ // This may happen if the save operation failed or Save As was canceled
+ args.Cancel = true;
+ doc.Select ();
+ return;
}
- return;
} else {
args.Cancel |= result != AlertButton.CloseWithoutSave;
if (!args.Cancel)
diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/OnTheFlyFormatterTests.cs b/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/OnTheFlyFormatterTests.cs
index 09958cb2fc..ee446a4219 100644
--- a/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/OnTheFlyFormatterTests.cs
+++ b/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/OnTheFlyFormatterTests.cs
@@ -38,17 +38,19 @@ using MonoDevelop.Projects;
using MonoDevelop.Core.ProgressMonitoring;
using MonoDevelop.Core;
using System.Threading.Tasks;
+using MonoDevelop.Ide.Gui.Content;
namespace MonoDevelop.CSharpBinding
{
[TestFixture]
- public class OnTheFlyFormatterTests : UnitTests.TestBase
+ class OnTheFlyFormatterTests : ICSharpCode.NRefactory6.TestBase
{
- static async Task Simulate (string input, Action<TestViewContent, CSharpTextEditorIndentation> act)
+ static async Task Simulate(string input, Action<TestViewContent, CSharpTextEditorIndentation> act, CSharpFormattingPolicy formattingPolicy = null)
{
- TestWorkbenchWindow tww = new TestWorkbenchWindow ();
- var content = new TestViewContent ();
- content.Data.Options = new CustomEditorOptions {
+ TestWorkbenchWindow tww = new TestWorkbenchWindow();
+ var content = new TestViewContent();
+ content.Data.Options = new CustomEditorOptions
+ {
IndentStyle = IndentStyle.Auto
};
@@ -56,58 +58,66 @@ namespace MonoDevelop.CSharpBinding
content.ContentName = "/a.cs";
content.Data.MimeType = "text/x-csharp";
- var doc = new Document (tww);
+ var doc = new Document(tww);
- var sb = new StringBuilder ();
+ var sb = new StringBuilder();
int cursorPosition = 0, selectionStart = -1, selectionEnd = -1;
- for (int i = 0; i < input.Length; i++) {
- var ch = input [i];
- switch (ch) {
- case '$':
- cursorPosition = sb.Length;
- break;
- case '<':
- if (i + 1 < input.Length) {
- if (input [i + 1] == '-') {
- selectionStart = sb.Length;
- i++;
- break;
+ for (int i = 0; i < input.Length; i++)
+ {
+ var ch = input[i];
+ switch (ch)
+ {
+ case '$':
+ cursorPosition = sb.Length;
+ break;
+ case '<':
+ if (i + 1 < input.Length)
+ {
+ if (input[i + 1] == '-')
+ {
+ selectionStart = sb.Length;
+ i++;
+ break;
+ }
}
- }
- goto default;
- case '-':
- if (i + 1 < input.Length) {
- var next = input [i + 1];
- if (next == '>') {
- selectionEnd = sb.Length;
- i++;
- break;
+ goto default;
+ case '-':
+ if (i + 1 < input.Length)
+ {
+ var next = input[i + 1];
+ if (next == '>')
+ {
+ selectionEnd = sb.Length;
+ i++;
+ break;
+ }
}
- }
- goto default;
- default:
- sb.Append (ch);
- break;
+ goto default;
+ default:
+ sb.Append(ch);
+ break;
}
}
- content.Text = sb.ToString ();
+ content.Text = sb.ToString();
content.CursorPosition = cursorPosition;
- var project = Services.ProjectService.CreateProject ("C#");
+ var project = Services.ProjectService.CreateProject("C#");
project.Name = "test";
project.FileName = "test.csproj";
- project.Files.Add (new ProjectFile (content.ContentName, BuildAction.Compile));
- project.Policies.Set (Projects.Policies.PolicyService.InvariantPolicies.Get<CSharpFormattingPolicy> (), CSharpFormatter.MimeType);
-
- var solution = new MonoDevelop.Projects.Solution ();
- solution.AddConfiguration ("", true);
- solution.DefaultSolutionFolder.AddItem (project);
- using (var monitor = new ProgressMonitor ())
- await TypeSystemService.Load (solution, monitor);
- content.Project = project;
- doc.SetProject (project);
+ project.Files.Add(new ProjectFile(content.ContentName, BuildAction.Compile));
+ var textStylePolicy = Projects.Policies.PolicyService.InvariantPolicies.Get<TextStylePolicy>().WithTabsToSpaces(true);
+ project.Policies.Set(textStylePolicy, content.Data.MimeType);
+ project.Policies.Set(formattingPolicy ?? Projects.Policies.PolicyService.InvariantPolicies.Get<CSharpFormattingPolicy>(), content.Data.MimeType);
+
+ var solution = new MonoDevelop.Projects.Solution();
+ solution.AddConfiguration("", true);
+ solution.DefaultSolutionFolder.AddItem(project);
+ using (var monitor = new ProgressMonitor())
+ await TypeSystemService.Load(solution, monitor);
+ content.Project = project;
+ doc.SetProject(project);
var compExt = new CSharpCompletionTextEditorExtension ();
compExt.Initialize (doc.Editor, doc);
content.Contents.Add (compExt);
@@ -613,10 +623,10 @@ namespace FormatSelectionTest
IndentStyle = IndentStyle.Virtual,
DefaultEolMarker = "\r\n"
};
- ext.KeyPress (KeyDescriptor.FromGtk ((Gdk.Key)'}', '}', Gdk.ModifierType.None));
+ ext.KeyPress(KeyDescriptor.FromGtk((Gdk.Key)'}', '}', Gdk.ModifierType.None));
var newText = content.Text;
- Assert.AreEqual ("public class Application\r\n{\r\n\tstatic void Main (string[] args)\r\n\t{\r\n\t\t// abcd\r\n\t\t{\r\n\t\t}\r\n", newText);
+ Assert.AreEqual("public class Application\r\n{\r\n\tstatic void Main (string[] args)\r\n\t{\r\n\t\t// abcd\r\n\t\t{\r\n\t\t}\r\n", newText);
});
}
@@ -666,5 +676,38 @@ class MyContext
});
}
+ /// <summary>
+ /// Bug 59287 - [VSFeedback Ticket] #490276 - Automatic Space Inserted in Parenthesis (edit)
+ /// </summary>
+ [Test]
+ public async Task TestBug59287()
+ {
+ var policy = Projects.Policies.PolicyService.InvariantPolicies.Get<CSharpFormattingPolicy>();
+ policy = policy.Clone();
+ policy.SpaceWithinOtherParentheses = true;
+
+ await Simulate(@"
+using System;
+
+class MyContext
+{
+ public static void Main()
+ {
+ if (something == f$)
+ }
+}", (content, ext) => {
+ ext.KeyPress(KeyDescriptor.FromGtk((Gdk.Key)'f', 'f', Gdk.ModifierType.None));
+ Assert.AreEqual(@"
+using System;
+
+class MyContext
+{
+ public static void Main()
+ {
+ if (something == f)
+ }
+}", content.Text);
+ }, policy);
+ }
}
} \ No newline at end of file
diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildGlobTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildGlobTests.cs
index 259d94abd0..aeecfa3f89 100644
--- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildGlobTests.cs
+++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildGlobTests.cs
@@ -695,6 +695,202 @@ namespace MonoDevelop.Projects
p.Dispose ();
}
+ [Test]
+ public async Task RemoveAllFilesFromProject_OneFileNotDeleted_RemoveItemAddedForFileNotDeleted ()
+ {
+ var fn = new CustomItemNode<SupportImportedProjectFilesProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
+
+ try {
+ string projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
+ var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
+
+ Assert.AreEqual (3, p.Files.Count);
+
+ var f2 = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
+ var f3 = p.Files.First (fi => fi.FilePath.FileName == "c3.cs");
+ File.Delete (f2.FilePath);
+ File.Delete (f3.FilePath);
+
+ p.Files.Clear ();
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ string projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-remove-saved2")), projectXml);
+
+ p.Dispose ();
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
+ }
+
+ [Test]
+ public async Task RemoveAllFilesFromProject_NoFilesDeleted_RemoveItemAddedForFiles ()
+ {
+ var fn = new CustomItemNode<SupportImportedProjectFilesProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
+
+ try {
+ string projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
+ var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
+
+ Assert.AreEqual (3, p.Files.Count);
+
+ p.Files.Clear ();
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ string projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-remove-saved3")), projectXml);
+
+ p.Dispose ();
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
+ }
+
+ /// <summary>
+ /// Single .cs file found by the imported file glob. The .cs file has an Update item.
+ /// On removing the file from the project, but not deleting it, was not adding a Remove item
+ /// to the project.
+ /// </summary>
+ [Test]
+ public async Task RemoveAllFilesFromProject_ProjectHasOneFileWithUpdateItem_RemoveItemAddedAndUpdateItemRemoved ()
+ {
+ var fn = new CustomItemNode<SupportImportedProjectFilesProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
+
+ try {
+ string projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-remove-test2.csproj");
+ var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
+
+ Assert.AreEqual (3, p.Files.Count);
+
+ var f2 = p.Files.First (fi => fi.FilePath.FileName == "c2.cs");
+ var f3 = p.Files.First (fi => fi.FilePath.FileName == "c3.cs");
+ File.Delete (f2.FilePath);
+ File.Delete (f3.FilePath);
+
+ p.Files.Remove (f2);
+ p.Files.Remove (f3);
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ // Single c1.cs Update item in project. No other .cs files found by the file glob.
+ // With two or more files the bug does not happen. Also need to reload the project
+ // otherwise the bug does not happen.
+ p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
+
+ Assert.AreEqual (1, p.Files.Count);
+
+ // Remove c1.cs file but do not delete it.
+ p.Files.Clear ();
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ string projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-remove-saved2")), projectXml);
+
+ p.Dispose ();
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
+ }
+
+ /// <summary>
+ /// As above but the Update item is added whilst the project is loaded. If the Update item
+ /// exists when the project is loaded and then the file is removed then the Update item is
+ /// removed correctly.
+ /// </summary>
+ [Test]
+ public async Task RemoveAllFilesFromProject_ProjectHasOneFileWithUpdateItem_RemoveItemAddedAndUpdateItemRemoved2 ()
+ {
+ var fn = new CustomItemNode<SupportImportedProjectFilesProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
+
+ try {
+ FilePath projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
+
+ // Leave only the c1.cs file.
+ var c2File = projFile.ParentDirectory.Combine ("c2.cs");
+ var c3File = projFile.ParentDirectory.Combine ("c3.cs");
+ File.Delete (c2File);
+ File.Delete (c3File);
+
+ var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
+
+ Assert.AreEqual (1, p.Files.Count);
+
+ var c1File = p.Files.First (fi => fi.FilePath.FileName == "c1.cs");
+ c1File.CopyToOutputDirectory = FileCopyMode.Always;
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ // Remove c1.cs file but do not delete it.
+ p.Files.Clear ();
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ string projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (File.ReadAllText (p.FileName.ChangeName ("glob-remove-saved2")), projectXml);
+
+ p.Dispose ();
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
+ }
+
+ /// <summary>
+ /// As above but the file is deleted not just removed from the project. If the Update item
+ /// exists when the project is loaded and then the file is deleted then the Update item is
+ /// removed correctly.
+ /// </summary>
+ [Test]
+ public async Task DeleteAllFilesFromProject_ProjectHasOneFileWithUpdateItem_UpdateItemRemoved ()
+ {
+ var fn = new CustomItemNode<SupportImportedProjectFilesProjectExtension> ();
+ WorkspaceObject.RegisterCustomExtension (fn);
+
+ try {
+ FilePath projFile = Util.GetSampleProject ("msbuild-glob-tests", "glob-import-test.csproj");
+ string expectedProjectXml = File.ReadAllText (projFile);
+
+ // Leave only the c1.cs file.
+ var c2File = projFile.ParentDirectory.Combine ("c2.cs");
+ var c3File = projFile.ParentDirectory.Combine ("c3.cs");
+ File.Delete (c2File);
+ File.Delete (c3File);
+
+ var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
+ p.UseAdvancedGlobSupport = true;
+
+ Assert.AreEqual (1, p.Files.Count);
+
+ var c1File = p.Files.First (fi => fi.FilePath.FileName == "c1.cs");
+ c1File.CopyToOutputDirectory = FileCopyMode.Always;
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ File.Delete (c1File.FilePath);
+ p.Files.Clear ();
+
+ await p.SaveAsync (Util.GetMonitor ());
+
+ string projectXml = File.ReadAllText (p.FileName);
+ Assert.AreEqual (expectedProjectXml, projectXml);
+
+ p.Dispose ();
+ } finally {
+ WorkspaceObject.UnregisterCustomExtension (fn);
+ }
+ }
+
class SupportImportedProjectFilesProjectExtension : DotNetProjectExtension
{
internal protected override bool OnGetSupportsImportedItem (IMSBuildItemEvaluated buildItem)
diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildTests.cs
index 11fca34189..d28ccc3981 100644
--- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildTests.cs
+++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildTests.cs
@@ -1798,6 +1798,10 @@ namespace MonoDevelop.Projects
var mp = (Project)p;
mp.UseAdvancedGlobSupport = true;
+ foreach (var file in mp.Files) {
+ File.Delete (file.FilePath);
+ }
+
mp.Files.Clear ();
await p.SaveAsync (Util.GetMonitor ());
diff --git a/main/tests/test-projects/dotnetcore-pcl/NetCore11/NetCore11.csproj b/main/tests/test-projects/dotnetcore-pcl/NetCore11/NetCore11.csproj
new file mode 100644
index 0000000000..5766db614c
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-pcl/NetCore11/NetCore11.csproj
@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp2.0</TargetFramework>
+ </PropertyGroup>
+
+</Project>
diff --git a/main/tests/test-projects/dotnetcore-pcl/NetStandard14/NetStandard14.csproj b/main/tests/test-projects/dotnetcore-pcl/NetStandard14/NetStandard14.csproj
new file mode 100644
index 0000000000..b290d67fb7
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-pcl/NetStandard14/NetStandard14.csproj
@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netstandard1.4</TargetFramework>
+ </PropertyGroup>
+
+</Project>
diff --git a/main/tests/test-projects/dotnetcore-pcl/PclProfile111/PclProfile111.csproj b/main/tests/test-projects/dotnetcore-pcl/PclProfile111/PclProfile111.csproj
new file mode 100644
index 0000000000..ecbe20056d
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-pcl/PclProfile111/PclProfile111.csproj
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{4D145A54-478E-41FA-BB0F-EEAC578AF234}</ProjectGuid>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <UseMSBuildEngine>true</UseMSBuildEngine>
+ <OutputType>Library</OutputType>
+ <RootNamespace>PclProfile111</RootNamespace>
+ <AssemblyName>PclProfile111</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/dotnetcore-pcl/dotnetcore-pcl.sln b/main/tests/test-projects/dotnetcore-pcl/dotnetcore-pcl.sln
new file mode 100644
index 0000000000..32b23e7b3a
--- /dev/null
+++ b/main/tests/test-projects/dotnetcore-pcl/dotnetcore-pcl.sln
@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetStandard14", "NetStandard14\NetStandard14.csproj", "{87B9046C-04BA-4094-A2AD-BD7AE730592F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PclProfile111", "PclProfile111\PclProfile111.csproj", "{4D145A54-478E-41FA-BB0F-EEAC578AF234}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCore11", "NetCore11\NetCore11.csproj", "{A9AE4F25-13FA-4148-BD8D-8F87F68DAD5A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {87B9046C-04BA-4094-A2AD-BD7AE730592F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {87B9046C-04BA-4094-A2AD-BD7AE730592F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {87B9046C-04BA-4094-A2AD-BD7AE730592F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {87B9046C-04BA-4094-A2AD-BD7AE730592F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4D145A54-478E-41FA-BB0F-EEAC578AF234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4D145A54-478E-41FA-BB0F-EEAC578AF234}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4D145A54-478E-41FA-BB0F-EEAC578AF234}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4D145A54-478E-41FA-BB0F-EEAC578AF234}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A9AE4F25-13FA-4148-BD8D-8F87F68DAD5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A9AE4F25-13FA-4148-BD8D-8F87F68DAD5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A9AE4F25-13FA-4148-BD8D-8F87F68DAD5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A9AE4F25-13FA-4148-BD8D-8F87F68DAD5A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-remove-saved2.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-remove-saved2.csproj
new file mode 100644
index 0000000000..928c025a3f
--- /dev/null
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-remove-saved2.csproj
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="glob-import-test.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProjectGuid>{109A0AFA-67E0-4FF4-A942-78A545367EBD}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>GlobTest</RootNamespace>
+ <AssemblyName>GlobTest</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Remove="c1.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-remove-saved3.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-remove-saved3.csproj
new file mode 100644
index 0000000000..b8b8fded00
--- /dev/null
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-remove-saved3.csproj
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="glob-import-test.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProjectGuid>{109A0AFA-67E0-4FF4-A942-78A545367EBD}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>GlobTest</RootNamespace>
+ <AssemblyName>GlobTest</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Remove="c1.cs" />
+ <Compile Remove="c2.cs" />
+ <Compile Remove="c3.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/main/tests/test-projects/msbuild-glob-tests/glob-remove-test2.csproj b/main/tests/test-projects/msbuild-glob-tests/glob-remove-test2.csproj
new file mode 100644
index 0000000000..3cbb8bfcec
--- /dev/null
+++ b/main/tests/test-projects/msbuild-glob-tests/glob-remove-test2.csproj
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="glob-import-test.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProjectGuid>{109A0AFA-67E0-4FF4-A942-78A545367EBD}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>GlobTest</RootNamespace>
+ <AssemblyName>GlobTest</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ExternalConsole>true</ExternalConsole>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Update="c1.cs">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Compile>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/version-checks b/version-checks
index dda81ab16e..04fc68fa1d 100755
--- a/version-checks
+++ b/version-checks
@@ -17,7 +17,7 @@ DEP[0]=md-addins
DEP_NAME[0]=MDADDINS
DEP_PATH[0]=${top_srcdir}/../md-addins
DEP_MODULE[0]=git@github.com:xamarin/md-addins.git
-DEP_NEEDED_VERSION[0]=3baacc87ecc44da9789bffd54d886cac648609ba
+DEP_NEEDED_VERSION[0]=def3df49f5084a590ba2c325f6ed6a7acf2439f2
DEP_BRANCH_AND_REMOTE[0]="master origin/master"
# heap-shot