Repository: microsoft/ptvsd

Issue:
Remote debugging broken when remote is Windows and local is Linux
* Remote host = Windows
* Local host = Linux

In this scenario, paths returned by PTVSD are all normcased

This is because the `os_id` initialized in `on_initialize` is incorrect.
We need to send the OS of the IDE not that of the current OS.
```python
    @async_handler
    def on_initialize(self, request, args):
        # TODO: docstring
        cmd = pydevd_comm.CMD_VERSION
        os_id = 'WINDOWS' if platform.system() == 'Windows' else 'UNIX'
        msg = '1.1\t{}\tID'.format(os_id)
        yield self.pydevd_request(cmd, msg)
```

**Solution:** 
We'll need to pass an OS identifier from VS/VSC to PTVSD via the `launch` request.



Discussion:

Resolving patch:
diff --git a/ptvsd/wrapper.py b/ptvsd/wrapper.py
--- a/ptvsd/wrapper.py
+++ b/ptvsd/wrapper.py
@@ -896,7 +896,7 @@ def build_debug_options(self, debug_options):
             'Jinja': 'FLASK_DEBUG=True',
             'FixFilePathCase': 'FIX_FILE_PATH_CASE=True',
             'DebugStdLib': 'DEBUG_STD_LIB=True',
-            'FilePathIsCaseSensitive': 'FILE_PATH_IS_CASE_SENSITIVE=True',
+            'WindowsClient': 'WINDOWS_CLIENT=True',
         }
         return ';'.join(debug_option_mapping[option]
                         for option in debug_options
@@ -911,9 +911,11 @@ def _parse_debug_options(self, debug_options):
             INTERPRETER_OPTIONS=string
             WEB_BROWSER_URL=string url
             DJANGO_DEBUG=True|False
-            FILE_PATH_IS_CASE_SENSITIVE=True|False
+            WINDOWS_CLIENT=True|False
         """
-        bool_parser = lambda str: str in ("True", "true", "1")
+        def bool_parser(str):
+            return str in ("True", "true", "1")
+
         DEBUG_OPTIONS_PARSER = {
             'WAIT_ON_ABNORMAL_EXIT': bool_parser,
             'WAIT_ON_NORMAL_EXIT': bool_parser,
@@ -924,7 +926,7 @@ def _parse_debug_options(self, debug_options):
             'DJANGO_DEBUG': bool_parser,
             'FLASK_DEBUG': bool_parser,
             'FIX_FILE_PATH_CASE': bool_parser,
-            'FILE_PATH_IS_CASE_SENSITIVE': bool_parser,
+            'WINDOWS_CLIENT': bool_parser,
         }
 
         options = {}
@@ -935,9 +937,8 @@ def _parse_debug_options(self, debug_options):
                 continue
             options[key] = DEBUG_OPTIONS_PARSER[key](value)
 
-        if 'FILE_PATH_IS_CASE_SENSITIVE' not in options:
-            file_path_is_case_sensitive = platform.system() != 'Windows'
-            options['FILE_PATH_IS_CASE_SENSITIVE'] = file_path_is_case_sensitive # noqa
+        if 'WINDOWS_CLIENT' not in options:
+            options['WINDOWS_CLIENT'] = platform.system() == 'Windows' # noqa
 
         return options
 
@@ -952,12 +953,12 @@ def _initialize_path_maps(self, args):
         if len(pathMaps) > 0:
             pydevd_file_utils.setup_client_server_paths(pathMaps)
 
-    def _send_cmd_version_command(self, file_path_is_case_sensitive):
+    def _send_cmd_version_command(self, windows_client):
         cmd = pydevd_comm.CMD_VERSION
-        os_id = 'UNIX' if file_path_is_case_sensitive else 'WINDOWS'
+        os_id = 'WINDOWS' if windows_client else 'UNIX'
         msg = '1.1\t{}\tID'.format(os_id)
         return self.pydevd_request(cmd, msg)
-        
+
     @async_handler
     def on_attach(self, request, args):
         # TODO: docstring
@@ -966,8 +967,8 @@ def on_attach(self, request, args):
         options = self.build_debug_options(args.get('debugOptions', []))
         self.debug_options = self._parse_debug_options(
             args.get('options', options))
-        file_path_is_case_sensitive = self.debug_options.get('FILE_PATH_IS_CASE_SENSITIVE', False)
-        yield self._send_cmd_version_command(file_path_is_case_sensitive)
+        windows_client = self.debug_options.get('WINDOWS_CLIENT', False)
+        yield self._send_cmd_version_command(windows_client)
         self.send_response(request)
 
     @async_handler
@@ -977,8 +978,8 @@ def on_launch(self, request, args):
         options = self.build_debug_options(args.get('debugOptions', []))
         self.debug_options = self._parse_debug_options(
             args.get('options', options))
-        file_path_is_case_sensitive = platform.system() != 'Windows'
-        yield self._send_cmd_version_command(file_path_is_case_sensitive)
+        windows_client = platform.system() == 'Windows'
+        yield self._send_cmd_version_command(windows_client)
         self.send_response(request)
 
     def on_disconnect(self, request, args):


Test patch:
diff --git a/tests/highlevel/test_lifecycle.py b/tests/highlevel/test_lifecycle.py
--- a/tests/highlevel/test_lifecycle.py
+++ b/tests/highlevel/test_lifecycle.py
@@ -111,11 +111,11 @@ def test_attach(self):
         self.attach(expected_os_id=OS_ID, attach_args={})
 
     def test_attach_from_unix_os(self):
-        attach_args = {'options':'FILE_PATH_IS_CASE_SENSITIVE=True'}
+        attach_args = {'options': 'WINDOWS_CLIENT=False'}
         self.attach(expected_os_id='UNIX', attach_args=attach_args)
 
     def test_attach_from_windows_os(self):
-        attach_args = {'options': 'FILE_PATH_IS_CASE_SENSITIVE=False'}
+        attach_args = {'options': 'WINDOWS_CLIENT=True'}
         self.attach(expected_os_id='WINDOWS', attach_args=attach_args)
 
     def test_launch(self):
diff --git a/tests/highlevel/test_messages.py b/tests/highlevel/test_messages.py
--- a/tests/highlevel/test_messages.py
+++ b/tests/highlevel/test_messages.py
@@ -28,11 +28,10 @@
     CMD_THREAD_KILL,
     CMD_THREAD_RUN,
     CMD_THREAD_SUSPEND,
-    CMD_VERSION,
     CMD_WRITE_TO_CONSOLE,
 )
 
-from . import OS_ID, RunningTest
+from . import RunningTest
 from ptvsd.wrapper import UnsupportedPyDevdCommandError