-
Notifications
You must be signed in to change notification settings - Fork 416
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 #1003 from DustinCampbell/package-restore
Reload and update MSBuild projects in response to dotnet restore
- Loading branch information
Showing
38 changed files
with
1,480 additions
and
1,131 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.../Models/v1/FilesChanged/FileChangeType.cs → ...stractions/FileWatching/FileChangeType.cs
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,4 +1,4 @@ | ||
namespace OmniSharp.Models.FilesChanged | ||
namespace OmniSharp.FileWatching | ||
{ | ||
public enum FileChangeType | ||
{ | ||
|
14 changes: 14 additions & 0 deletions
14
src/OmniSharp.Abstractions/FileWatching/IFileSystemNotifier.cs
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,14 @@ | ||
using OmniSharp.Models.FilesChanged; | ||
|
||
namespace OmniSharp.FileWatching | ||
{ | ||
public interface IFileSystemNotifier | ||
{ | ||
/// <summary> | ||
/// Notifiers any relevant file system watchers when a file is created, changed, or deleted. | ||
/// </summary> | ||
/// <param name="filePath">The path to the file that was changed.</param> | ||
/// <param name="changeType">The type of change. Hosts are not required to pass a change type.</param> | ||
void Notify(string filePath, FileChangeType changeType = FileChangeType.Unspecified); | ||
} | ||
} |
18 changes: 7 additions & 11 deletions
18
src/OmniSharp.Abstractions/FileWatching/IFileSystemWatcher.cs
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,20 +1,16 @@ | ||
using System; | ||
using OmniSharp.Models.FilesChanged; | ||
using OmniSharp.Models.FilesChanged; | ||
|
||
namespace OmniSharp.FileWatching | ||
{ | ||
// TODO: Flesh out this API more | ||
public delegate void FileSystemNotificationCallback(string filePath, FileChangeType changeType); | ||
|
||
public interface IFileSystemWatcher | ||
{ | ||
void Watch(string path, Action<string, FileChangeType> callback); | ||
|
||
/// <summary> | ||
/// Called when a file is created, changed, or deleted. | ||
/// Call to watch a file or directory path for changes. | ||
/// </summary> | ||
/// <param name="path">The path to the file</param> | ||
/// <param name="changeType">The type of change. Hosts are not required to pass a change type</param> | ||
void TriggerChange(string path, FileChangeType changeType); | ||
|
||
void WatchDirectory(string path, Action<string, FileChangeType> callback); | ||
/// <param name="fileOrDirectoryPath">The file or directory path to watch.</param> | ||
/// <param name="callback">The callback that will be invoked when a change occurs in the watched file or directory.</param> | ||
void Watch(string fileOrDirectoryPath, FileSystemNotificationCallback callback); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/OmniSharp.Abstractions/Models/v1/FilesChanged/FilesChangedRequest.cs
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace OmniSharp.MSBuild.Logging | ||
{ | ||
public class MSBuildDiagnostic | ||
{ | ||
public MSBuildDiagnosticSeverity Severity { get; } | ||
public string Message { get; } | ||
public string File { get; } | ||
public string ProjectFile { get; } | ||
public string Subcategory { get; } | ||
public string Code { get; } | ||
public int LineNumber { get; } | ||
public int ColumnNumber { get; } | ||
public int EndLineNumber { get; } | ||
public int EndColumnNumber { get; } | ||
|
||
private MSBuildDiagnostic( | ||
MSBuildDiagnosticSeverity severity, | ||
string message, string file, string projectFile, string subcategory, string code, | ||
int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber) | ||
{ | ||
Severity = severity; | ||
Message = message; | ||
File = file; | ||
ProjectFile = projectFile; | ||
Subcategory = subcategory; | ||
Code = code; | ||
LineNumber = lineNumber; | ||
ColumnNumber = columnNumber; | ||
EndLineNumber = endLineNumber; | ||
EndColumnNumber = endColumnNumber; | ||
} | ||
|
||
public static MSBuildDiagnostic CreateFrom(Microsoft.Build.Framework.BuildErrorEventArgs args) | ||
=> new MSBuildDiagnostic(MSBuildDiagnosticSeverity.Error, | ||
args.Message, args.File, args.ProjectFile, args.Subcategory, args.Code, | ||
args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber); | ||
|
||
public static MSBuildDiagnostic CreateFrom(Microsoft.Build.Framework.BuildWarningEventArgs args) | ||
=> new MSBuildDiagnostic(MSBuildDiagnosticSeverity.Error, | ||
args.Message, args.File, args.ProjectFile, args.Subcategory, args.Code, | ||
args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber); | ||
} | ||
} |
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,8 @@ | ||
namespace OmniSharp.MSBuild.Logging | ||
{ | ||
public enum MSBuildDiagnosticSeverity | ||
{ | ||
Error, | ||
Warning | ||
} | ||
} |
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,39 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace OmniSharp.MSBuild.Logging | ||
{ | ||
internal class MSBuildLogger : Microsoft.Build.Utilities.Logger | ||
{ | ||
private readonly ILogger _logger; | ||
private readonly List<MSBuildDiagnostic> _diagnostics; | ||
|
||
public MSBuildLogger(ILogger logger) | ||
{ | ||
_logger = logger; | ||
_diagnostics = new List<MSBuildDiagnostic>(); | ||
} | ||
|
||
public override void Initialize(Microsoft.Build.Framework.IEventSource eventSource) | ||
{ | ||
eventSource.ErrorRaised += OnError; | ||
eventSource.WarningRaised += OnWarning; | ||
} | ||
|
||
public ImmutableArray<MSBuildDiagnostic> GetDiagnostics() => | ||
_diagnostics.ToImmutableArray(); | ||
|
||
private void OnError(object sender, Microsoft.Build.Framework.BuildErrorEventArgs args) | ||
{ | ||
_logger.LogError(args.Message); | ||
_diagnostics.Add(MSBuildDiagnostic.CreateFrom(args)); | ||
} | ||
|
||
private void OnWarning(object sender, Microsoft.Build.Framework.BuildWarningEventArgs args) | ||
{ | ||
_logger.LogWarning(args.Message); | ||
_diagnostics.Add(MSBuildDiagnostic.CreateFrom(args)); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.