VSCode Project creation changes/fixes

Wanted to get people’s thoughts/additions before posting this as an official bug report.

1. Reducing Tag parser (‘Intellisense’) file size

VSCode has two ‘Intellisense’ types. Tag Parser (old) and Default (new). If you don’t specify Tag parser includes, VSCode will automatically add the workspace directories to the Tag Parser includes list that are then parsed recursively.

The UE4 workspace doesn’t have Tag Parser includes specified/disabled so this results in a Tag Parser file size of ~2 Gigabytes.

You can safely disable the UE4 workspace Tag Parser includes. This is because the Project Workspace has all the includes already specified that the Tag Parser needs. The Tag Parser works by combining all Workspaces into one Tag Parser file.

Disabling Tag Parser Includes for the UE4 Workspace results in a Tag Parser file size of ~0.9 Gigabytes.

To disabled the UE4 Workspace Tag Parser includes, go to the UE4 c_cpp_properties.json and specify a blank array for the browse path:

        "browse": {
            "path": []
        },

2. Make use of the ${default} variable for customization, DRY, and backup.

VSCode has a ${default} variable that can carry over settings from different config files. This also allows us to use a list of defines, specified in one place, in both Workspaces.

The config file we would use would be the Project config file, called ‘ProjectName.code-workspace’.
In this file we would use the “C_Cpp.default.defines” setting like so:

"settings": {
	"typescript.tsc.autoDetect": "off",
	"C_Cpp.default.defines": [
		"DEPRECATED_FORGAME=DEPRECATED",
		"UE_DEPRECATED_FORGAME=UE_DEPRECATED",
		"IS_PROGRAM=0",
		"UE_EDITOR=1",
		"ENABLE_PGO_PROFILE=0",
		"USE_VORBIS_FOR_STREAMING=1",
		...
	]
},

Now we can specify defines in both Project and UE4 Workspaces, in their c_cpp_properties.json, like so:

    "defines": [
        "${default}"
    ],

###The “IncludePath” can be done the same way.

This would allow people to make different configurations in their Project Workspace’s c_cpp_properties.json and pull the “IncludePath” setting from ‘ProjectName.code-workspace’.

See #4 for full examples.

3. Fix “files.exclude” in the Project Workspace’s settings.json.

This setting hides the directories listed from appearing in the UI.

Currently all directories listed won’t get hidden because the full path is set.

Also If it did work, there would be include errors. This is because this setting also prevents any include file in the directories listed to not be included.

For this reason, the list must not include the Intermediate directory.

To fix this list, specify the directories like so:

"files.exclude": {
	".vscode": true,
	"Backup": true,
	"Content": true,
	"DerivedDataCache": true,
	"Saved": true
}

There are arguments to be made to leave the .vscode directory as false. People can always change it to whatever they want after generating project files.

4. Examples of #1 and #2

Project Workspace’s c_cpp_properties.json. Shows using ${default} for both ‘includePath’ and ‘defines’. ${default} allows for easy additional custom configurations.

"configurations": [
    {
        "name": "UnrealEngine",
        "includePath": [
            "${default}"
        ],
        "intelliSenseMode": "msvc-x64",
        "defines": [
            "${default}"
        ],
        "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe"
    }
],
"version": 4

Now the UE4 c_cpp_properties.json showing only ${default} for defines. We don’t need it for the “includePath”. It also shows turning off the unneeded Tag Parser’s include list with “path”:[]:

"configurations": [
    {
        "name": "UnrealEngine",
        "includePath": [
            "${workspaceFolder}/**"
        ],
        "intelliSenseMode": "msvc-x64",
        "defines": [
            "${default}"
        ],
        "browse": {
            "path": []
        },
        "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe"
    }
],
"version": 4

Now the Project Workspace’s project file, ‘ProjectName.code-workspace’. It will contain all ‘includePath’ and ‘defines’ settings (shortened with …):

"folders": [
	{
		"name": "MyProject",
		"path": "."
	},
	{
		"name": "UE4",
		"path": "J:\\Program Files\\Epic Games\\UE_4.25"
	}
],
"settings": {
	"typescript.tsc.autoDetect": "off",
	"C_Cpp.default.includePath": [
		"J:\\Program Files\\Epic Games\\UE_4.25\\Engine\\Source",
		"J:\\Program Files\\Epic Games\\UE_4.25\\Engine\\Intermediate\\Build\\Win64\\UE4Editor\\Inc\\Engine",
		"J:\\Program Files\\Epic Games\\UE_4.25\\Engine\\Source\\Runtime",
		...
	],
	"C_Cpp.default.defines": [
		"DEPRECATED_FORGAME=DEPRECATED",
		"UE_DEPRECATED_FORGAME=UE_DEPRECATED",
		"IS_PROGRAM=0",
		"UE_EDITOR=1",
		"ENABLE_PGO_PROFILE=0",
		"USE_VORBIS_FOR_STREAMING=1",
		...
	]
},
"extensions": {
	"recommendations": [
		"ms-vscode.cpptools",
		"ms-dotnettools.csharp"
	]
}

VSCode and VS 2019 Build Tools with UE4 4.26 moves to compile commands. This makes most, if not all, of this unneeded.

No this is still needed as I am still experiencing issues with this new way of defining VS code intellisense in Unreal 4.26
https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1828953-unreal-engine-4-26-vscode-errors
Check that out here