-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed VisualStudioDevelopmentEnvironment to WIndowsDevelopmentEnvir…
…oment Just less classes to manage and also moves the logic for selecting the correct one to the class assembly itself.
- Loading branch information
1 parent
4f595b1
commit fa6e353
Showing
5 changed files
with
70 additions
and
55 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/Plugins/SourceGenerator.Foundations.Windows/EnvironmentType.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,10 @@ | ||
namespace SGF | ||
{ | ||
internal enum EnvironmentType | ||
{ | ||
Unknown, | ||
VisualStudio, | ||
VSCode, | ||
Rider | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
src/Plugins/SourceGenerator.Foundations.Windows/VSCodeEnvironment.cs
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/Plugins/SourceGenerator.Foundations.Windows/VisualStudioEnvironment.cs
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/Plugins/SourceGenerator.Foundations.Windows/WindowsDevelopmentEnvironment.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,51 @@ | ||
using Serilog.Core; | ||
using SGF.Interop.VisualStudio; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace SGF | ||
{ | ||
|
||
/// <summary> | ||
/// Represents a enviroment where the user is authoring code in Visual Studio | ||
/// </summary> | ||
internal class WindowsDevelopmentEnvironment : IDevelopmentEnviroment | ||
{ | ||
public EnvironmentType Type { get; } | ||
|
||
|
||
public WindowsDevelopmentEnvironment() | ||
{ | ||
Type = EnvironmentType.VisualStudio; | ||
|
||
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("VisualStudioVersion"))) | ||
{ | ||
Type = EnvironmentType.VisualStudio; | ||
} | ||
} | ||
|
||
/// <inheritdoc cref="IDevelopmentEnviroment"/> | ||
public bool AttachDebugger(int processId) | ||
{ | ||
switch (Type) | ||
{ | ||
case EnvironmentType.VisualStudio: | ||
VisualStudioInterop.AttachDebugger(); | ||
break; | ||
} | ||
return true; | ||
} | ||
|
||
/// <inheritdoc cref="IDevelopmentEnviroment"/> | ||
public IEnumerable<ILogEventSink> GetLogSinks() | ||
{ | ||
switch (Type) | ||
{ | ||
case EnvironmentType.VisualStudio: | ||
yield return new VisualStudioLogEventSink(); | ||
break; | ||
} | ||
} | ||
} | ||
} |
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