diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..43f50064a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# ignore cache files for sample projects +.vscode/ipch +browse*.db* +*.obj +*.pdb +*.exe +*.ilk \ No newline at end of file diff --git a/Code Samples/BoxConsoleSample/Objects/box.h b/Code Samples/BoxConsoleSample/Objects/box.h new file mode 100644 index 000000000..5e0102bb0 --- /dev/null +++ b/Code Samples/BoxConsoleSample/Objects/box.h @@ -0,0 +1,19 @@ +#ifndef BOX_H +#define BOX_H + +/** + * Definition of a box object with three dimensions. + */ +struct box +{ + int length; + int width; + int height; + + int volume() + { + return length * width * height; + } +}; + +#endif diff --git a/Code Samples/BoxConsoleSample/README.md b/Code Samples/BoxConsoleSample/README.md new file mode 100644 index 000000000..178feeeb8 --- /dev/null +++ b/Code Samples/BoxConsoleSample/README.md @@ -0,0 +1,24 @@ +# Box Sample +This sample is a simple C++ program that computes and outputs the volume of a box. + +We use this example in our blog posts to illustrate new extension features. + +## Build and Debug Active File +Available as of March 2019, "Build and Debug Active File" automatically configures the build tasks and kicks off a build and debug session. There are +three ways to get started with this feature. + +### Command +While editing a file in your workspace folder, you can open the command palette and select the `C/C++: Build and Debug Active File` command. +This option will generate a tasks.json file for you, build your active source file, and then launch the debugger. + +![Open command palette and select Build and Debug Active File](build_debug_command.png) + +### Context Menu +While editing a file in a workspace folder, you can right click in the editor field and select the "Build and Debug Active File" context menu option. +This option will generate a tasks.json file for you, build your active source file, and then launch the debugger. + +![Right click and select Build and Debug Active File](build_debug_context_menu.png) + +### F5 +Another way to begin building and debugging your active file is to execute the command by pressing F5. This method will configure +both a tasks.json and launch.json file for you, build your active source file, and then launch the debugger. diff --git a/Code Samples/BoxConsoleSample/box_sample.cpp b/Code Samples/BoxConsoleSample/box_sample.cpp new file mode 100644 index 000000000..dcf4c4672 --- /dev/null +++ b/Code Samples/BoxConsoleSample/box_sample.cpp @@ -0,0 +1,16 @@ +#include +#include "Objects/box.h" + +using namespace std; + +/** + * Calculate and print the volume of a box. + */ +int main() +{ + box package{ 10, 10, 10 }; + cout << "Package length: " << package.length << endl; + cout << "Package width: " << package.width << endl; + cout << "Package height: " << package.height << endl; + cout << "Package volume: " << package.volume() << endl; +} \ No newline at end of file diff --git a/Code Samples/BoxConsoleSample/build_debug_command.png b/Code Samples/BoxConsoleSample/build_debug_command.png new file mode 100644 index 000000000..2fb7301ff Binary files /dev/null and b/Code Samples/BoxConsoleSample/build_debug_command.png differ diff --git a/Code Samples/BoxConsoleSample/build_debug_context_menu.png b/Code Samples/BoxConsoleSample/build_debug_context_menu.png new file mode 100644 index 000000000..23c163ece Binary files /dev/null and b/Code Samples/BoxConsoleSample/build_debug_context_menu.png differ diff --git a/Code Samples/SampleClangProject/.gitignore b/Code Samples/SampleClangProject/.gitignore deleted file mode 100644 index f62bc62d3..000000000 --- a/Code Samples/SampleClangProject/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -main.exe -main.exe.dSYM \ No newline at end of file diff --git a/Code Samples/SampleClangProject/.vscode/launch.json b/Code Samples/SampleClangProject/.vscode/launch.json deleted file mode 100644 index 89e34616f..000000000 --- a/Code Samples/SampleClangProject/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "(lldb) Launch", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceRoot}/main.exe", // this is executable to launch the debugger with - "args": ["YourNameHere"], - "stopAtEntry": true, // if true then stop at the main entry (function) - "cwd": "${workspaceRoot}", - "environment": [], - "externalConsole": true, - "MIMode": "lldb" - } - ] -} \ No newline at end of file diff --git a/Code Samples/SampleClangProject/.vscode/tasks.json b/Code Samples/SampleClangProject/.vscode/tasks.json deleted file mode 100644 index 84132dc85..000000000 --- a/Code Samples/SampleClangProject/.vscode/tasks.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "clang++", - "command": "clang++ --debug -o main.exe main.cpp", - // "--debug" enables debugging symbols - // "-o main.exe" specifies the output executable - // "main.cpp" is the source file to compile - "type": "shell", - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} diff --git a/Code Samples/SampleClangProject/README.md b/Code Samples/SampleClangProject/README.md deleted file mode 100644 index 3a4a27d58..000000000 --- a/Code Samples/SampleClangProject/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# README -This is a sample debuggable C++ project. It uses the vendor provided version of clang installed. `tasks.json` and `launch.json` have been edited to demonstrate how to create a configuration for a C++ project that builds with clang. - -There's a sample build task in `.vscode/tasks.json`; you can also see the build configurations by using the menu option `Configure` -> `Configure Tasks` or by clicking the gear icon in the Debug Panel. - -To run a build, use the menu option `Tasks` -> `Run Build Task...`. - -There's a sample debug configuration in `.vscode/launch.json`; you can also see the configuration by using the menu option `Debug` -> `Open Configurations`. - -To debug the build, use the menu option `Debug` -> `Start Debugging`. The executable will launch and stop in the main function. \ No newline at end of file diff --git a/Code Samples/SampleClangProject/main.cpp b/Code Samples/SampleClangProject/main.cpp deleted file mode 100644 index dc0d3f748..000000000 --- a/Code Samples/SampleClangProject/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace std; - -void greet(const string& person) { - cout << "Hello, " << person << "!" << endl; -} - -int main(int argc, char** argv) { - if(argc >= 2) { - greet(argv[1]); - } else { - cerr << "insufficient args, usage: " << argv[0] << " personNameHere" << endl; - } - return 0; -} diff --git a/Extension/.gitignore b/Extension/.gitignore index 96497bc9b..1df67693c 100644 --- a/Extension/.gitignore +++ b/Extension/.gitignore @@ -18,4 +18,3 @@ install.lock # ignore vscode test .vscode-test/ -browse*db* \ No newline at end of file