Skip to content

Commit

Permalink
Ensure we init IEnvironment before SessionManager (#1167)
Browse files Browse the repository at this point in the history
Ensure we have an instance of IEnvironment before we pass it to the
SessionManager contructor.

Also add some null guards to catch this problem earlier in the future.
  • Loading branch information
mjcheetham committed Mar 27, 2023
2 parents 784e7c7 + e040cdf commit de1ff8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/shared/Core/CommandContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public CommandContext()
else if (PlatformUtils.IsMacOS())
{
FileSystem = new MacOSFileSystem();
SessionManager = new MacOSSessionManager(Environment, FileSystem);
Environment = new MacOSEnvironment(FileSystem);
SessionManager = new MacOSSessionManager(Environment, FileSystem);
ProcessManager = new ProcessManager(Trace2);
Terminal = new MacOSTerminal(Trace, Trace2);
string gitPath = GetGitPath(Environment, FileSystem, Trace);
Expand All @@ -136,8 +136,8 @@ public CommandContext()
else if (PlatformUtils.IsLinux())
{
FileSystem = new LinuxFileSystem();
SessionManager = new LinuxSessionManager(Environment, FileSystem);
Environment = new PosixEnvironment(FileSystem);
SessionManager = new LinuxSessionManager(Environment, FileSystem);
ProcessManager = new ProcessManager(Trace2);
Terminal = new LinuxTerminal(Trace, Trace2);
string gitPath = GetGitPath(Environment, FileSystem, Trace);
Expand Down
3 changes: 3 additions & 0 deletions src/shared/Core/ISessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public abstract class SessionManager : ISessionManager

protected SessionManager(IEnvironment env, IFileSystem fs)
{
EnsureArgument.NotNull(env, nameof(env));
EnsureArgument.NotNull(fs, nameof(fs));

Environment = env;
FileSystem = fs;
}
Expand Down

0 comments on commit de1ff8b

Please sign in to comment.