diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..2b921b583e --- /dev/null +++ b/.clang-format @@ -0,0 +1,31 @@ +--- +# this file work is a derivative of .clang-format which follows +# https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md +# +Language: Cpp +BasedOnStyle: Microsoft +AccessModifierOffset: -4 +AlignAfterOpenBracket: AlwaysBreak +AlignEscapedNewlines: DontAlign +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: true + AfterUnion: true + AfterExternBlock: false +BreakConstructorInitializers: AfterColon +CompactNamespaces: true +ConstructorInitializerAllOnOneLineOrOnePerLine: true +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^"(stdafx.h|pch.h|precomp.h)"$' + Priority: -1 +NamespaceIndentation: Inner +PenaltyExcessCharacter: 1 +PointerAlignment: Left +SortIncludes: false +Standard: Cpp11 +UseTab: Never +... diff --git a/.gitignore b/.gitignore index 06e7187522..11fc5dda13 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ ## files generated by popular Visual Studio add-ons. .gitconfig +scripts/hooks/pre-commit + # User-specific files *.suo *.user diff --git a/.pipelines/clang-format-ci.yml b/.pipelines/clang-format-ci.yml new file mode 100644 index 0000000000..53df7680f4 --- /dev/null +++ b/.pipelines/clang-format-ci.yml @@ -0,0 +1,56 @@ +name: $(Year:yy).$(Month).$(DayOfMonth).$(rev:r) + +pr: + branches: + include: + - main + +pool: + vmImage: ubuntu-latest + +steps: +- task: NodeTool@0 + inputs: + versionSpec: '14.x' + displayName: 'Install Node.js' + +- script: | + npm install + displayName: 'npm install' + workingDirectory: source/nodejs + +- script: | + npm run verify --verbose + displayName: 'npm run verify --verbose' + workingDirectory: source/nodejs + +- bash: | + echo "##[command]Three ways to fix the format problem" + echo '##[command]1. powershell -ExecutionPolicy Bypass scripts\FormatSource.ps1 -ModifiedOnly $False' + echo "##[command]2. or cd source\nodejs, then npm run format --verbse" + echo "##[command]3. or download format.patch from pippeline, then git apply format.patch" + displayName: 'How to fix the format problem' + condition: failed() + +- script: | + npm run format --verbose + displayName: 'npm run format --verbose' + workingDirectory: source/nodejs + condition: failed() + +- script: | + git diff > format.patch + displayName: 'create format.patch' + condition: failed() + +- task: CopyFiles@2 + inputs: + contents: 'format.patch' + targetFolder: $(Build.ArtifactStagingDirectory) + condition: failed() + +- task: PublishBuildArtifacts@1 + inputs: + pathToPublish: $(Build.ArtifactStagingDirectory) + artifactName: drop + condition: failed() \ No newline at end of file diff --git a/README.md b/README.md index dfa68ea1b9..dac1a31084 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,53 @@ PS: Latest Build Status is against `main` branch. | iOS | [![CocoaPods](https://img.shields.io/cocoapods/v/AdaptiveCards.svg)](https://cocoapods.org/pods/AdaptiveCards) | [Source](https://github.com/Microsoft/AdaptiveCards/tree/main/source/ios) | [Docs](https://docs.microsoft.com/en-us/adaptive-cards/display/libraries/ios) | ![Build status](https://img.shields.io/azure-devops/build/Microsoft/56cf629e-8f3a-4412-acbc-bf69366c552c/37917/main.svg) | | Card Designer | [![npm install](https://img.shields.io/npm/v/adaptivecards-designer.svg)](https://www.npmjs.com/package/adaptivecards-designer) | [Source](https://github.com/Microsoft/AdaptiveCards/tree/main/source/nodejs/adaptivecards-designer)| [Docs](https://www.npmjs.com/package/adaptivecards-designer) | ![Build Status](https://img.shields.io/azure-devops/build/Microsoft/56cf629e-8f3a-4412-acbc-bf69366c552c/20564/main.svg) | -#### End User License Agreement for our binary packages +## Code format + +We require the C++ code inside this project to follow the clang-format. If you change them, please make sure your changed files are formatted correctly. + +Make sure clang-format version 12.0.0 and above version is used. + +### IDE integration +ClangFormat describes a set of tools that are built on top of LibFormat. It can support your workflow in a variety of ways including a standalone tool and editor integrations. For details, refer to https://clang.llvm.org/docs/ClangFormat.html + +### Format with script +Two scripts are provided to help you format files. +- Windows user only: use FormatSource.ps1. This script use clang-format.exe which is built into Visual Studio by default. + + Execute below command in the root folder of the project + + ``` + PowerShell.exe -ExecutionPolicy Bypass scripts\FormatSource.ps1 -ModifiedOnly $False + ``` + +If it's the first time to run the script, make sure clang-format version 12.0.0 or above in the output. Otherwise you may need to upgrade Visual Studio or use your own clang-format binaries. +``` +[clang-format] Version is: +clang-format version 12.0.0 +``` + +- Both Windows and MAC users: Use clang-format npmjs package + + Execute below command in source/nodejs + + ``` + npm run format + ``` + +Make sure `npm install` is run before. + +### Use Git pre-commit hook +`git pre-commit hook` is an optional process. When you run `git commit`, it will automatically do the format check and auto fix the format if error detected. + +First make sure clang-format binary is installed in your dev enviroment. +Then modify scripts/hooks/pre-commit to make sure clangFormat is point to the correct path. +And finally setup the git hook. + +Two ways to setup the hook: +1. Copy `scripts/hooks/pre-commit` to `.git/hooks` +2. `git config --local core.hooksPath scripts/hooks` + +## End User License Agreement for our binary packages Consumption of the AdaptiveCards binary packages are subject to the Microsoft EULA (End User License Agreement). Please see the relevant terms as listed below: - [UWP/.NET](https://github.com/microsoft/AdaptiveCards/blob/main/source/EULA-Windows.txt) - [Android/iOS](https://github.com/microsoft/AdaptiveCards/blob/main/source/EULA-Non-Windows.txt) diff --git a/scripts/FormatSource.ps1 b/scripts/FormatSource.ps1 new file mode 100644 index 0000000000..035433ca96 --- /dev/null +++ b/scripts/FormatSource.ps1 @@ -0,0 +1,293 @@ +<# +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See LICENSE in the project root for license information. + +this file work is a derivative of https://github.com/microsoft/MixedReality-GraphicsTools-Unreal/blob/main/Tools/scripts/Common.psm1 +#> + +<# +.SYNOPSIS + Run clang-format on all source files. +.PARAMETER Path + Path to the directory (or file) to be processed recursively. By default scans the entire repo. +.PARAMETER ClangFormat + Path to clang-format executable, e.g. "C:\Tools\clang-format.exe" +.PARAMETER ModifiedOnly + Scan only files modified in current git checkout. +.PARAMETER Staged + Check only files staged for commit +.PARAMETER ChangesFile + Scan only files listed in provided txt file (one path per line). Paths need to be relative to repo root. +.PARAMETER Verify + Whether to fail if files are not formatted (instead of applying changes). +.PARAMETER UseVS2019 + Use ClangFormat provided with Visual Studio 2019. This version will take precedence over -ClangFormat parameter + and PATH variable. +.PARAMETER NoFail` + Do not set RC=1 when errors found, i.e. only report errors in output. +#> +[CmdletBinding()] +param ( + [string]$Path = $null, + [string]$ClangFormat = $null, + [boolean]$ModifiedOnly = $True, + [boolean]$Staged = $false, + [string]$ChangesFile = $null, + [boolean]$Verify = $false, + [boolean]$UseVS2019 = $true, + [boolean]$NoFail = $false +) + +# Only check source files +$FilePatterns = "\.(h|cpp|hpp|c)$" + +#PerfApp is C++/Cx project and not supported +$IgnoreFolders = "(Generated Files|PerfApp|android|ios|nodejs|vscode|community|dotnet|node_modules|out|.git|.vs|.vscode|bin|CMakeFiles|generated|debug|x64)$" + +$RepoRoot = (Resolve-Path "$PSScriptRoot\..") + +<# +.SYNOPSIS + Given the path to the list of raw git changes, returns an array of + those changes rooted in the git root directory. +.DESCRIPTION + For example, the raw git changes will contain lines like: + + Assets/File.cs + + This function will return a list of paths that look like (assuming + that RepoRoot is C:\repo): + + C:\repo\Assets\File.cs +#> +function GetChangedFiles { + [CmdletBinding()] + param( + [string]$Filename, + [string]$RepoRoot + ) + process { + $rawContent = Get-Content -Path $Filename + $processedContent = @() + foreach ($line in $rawContent) { + $joinedPath = Join-Path -Path $RepoRoot -ChildPath $line + $processedContent += $joinedPath + } + $processedContent + } +} + +if ([string]::IsNullOrEmpty($Path)) +{ + $Path = $RepoRoot +} + +$ModifiedFiles = $null + +if ($ChangesFile) +{ + if (-not (Test-Path -Path $ChangesFile -PathType Leaf)) + { + Write-Host -ForegroundColor Red "ChangesFile not found: $ChangesFile" + Write-Host "Checking all source files" + } + else + { + $ModifiedFiles = GetChangedFiles -Filename $ChangesFile -RepoRoot $RepoRoot + if (($null -eq $ModifiedFiles) -or ($ModifiedFiles.Count -eq 0)) + { + Write-Host -ForegroundColor Green "No modified files to format." + exit 0 + } + } +} +elseif ($ModifiedOnly -or $Staged) +{ + $ModifiedFiles = @() + Push-Location -Path $RepoRoot + $Success = $False + try + { + if ($Staged) + { + $Status = (& git diff-index --cached --name-only HEAD) + $Success = ($LASTEXITCODE -eq 0) + $Status | ForEach-Object { + $FullPath = Resolve-Path $_ -ErrorAction SilentlyContinue + $FileName = Split-Path -Leaf -Path $FullPath + if ($FileName -match $FilePatterns) + { + $ModifiedFiles += $FullPath + } + } + } + else + { + $Status = (& git status --porcelain) + $Success = ($LASTEXITCODE -eq 0) + $Status | ForEach-Object { + $FullPath = (Resolve-Path ($_.Trim() -split " ",2)[-1] -ErrorAction SilentlyContinue) + $FileName = Split-Path -Leaf -Path $FullPath + if ($FileName -match $FilePatterns) + { + $ModifiedFiles += $FullPath + } + } + } + } + catch + { + # empty + } + if (-not $Success) + { + Write-Host -ForegroundColor Red "Could not get the list of modified files. Check if git is configured correctly." + exit 1 + } + Pop-Location + if (($null -eq $ModifiedFiles) -or ($ModifiedFiles.Count -eq 0)) + { + Write-Host -ForegroundColor Green "No modified files to format." + exit 0 + } +} + +if ($UseVS2019) +{ + # Attempt to use clang-format from Visual Studio 2019 if available + $LLVMDirs = @("${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm", + "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Professional\VC\Tools\Llvm", + "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm") + foreach ($LLVMDir in $LLVMDirs) + { + $VS2019ClangFormatX64 = "$LLVMDir\x64\bin\clang-format.exe" + $VS2019ClangFormatX86 = "$LLVMDir\bin\clang-format.exe" + if (Test-Path -Type Leaf -Path $VS2019ClangFormatX64) + { + $ClangFormat = $VS2019ClangFormatX64 + break + } + elseif (Test-Path -Type Leaf -Path $VS2019ClangFormatX86) + { + $ClangFormat = $VS2019ClangFormatX86 + break + } + } +} +elseif ([string]::IsNullOrEmpty($ClangFormat) -or (-not (Test-Path -Type Leaf -Path $ClangFormat))) +{ + # Check for clang-format in PATH + $ClangFormat = (Get-Command -Name "clang-format.exe" -ErrorAction SilentlyContinue) +} + +if ([string]::IsNullOrEmpty($ClangFormat)) +{ + Write-Host -ForegroundColor Red "clang-format.exe not found. Please install VS2019 or make sure clang-format.exe is in PATH." + exit 1 +} + +Write-Host "[clang-format] Path is $ClangFormat" +Write-Host "[clang-format] Version is: " + & $ClangFormat --version + +function Format-Directory +{ + [CmdletBinding()] + param ( + [Parameter(Mandatory=$True)] + [string]$Path, + [Parameter(Mandatory=$True)] + [string]$ClangFormat, + [string]$RepoRoot = $null, + [AllowEmptyString()][string]$FilePatterns = $null, + [string[]]$ModifiedFiles = $null, + [boolean]$Verify = $false + ) + process + { + if (-not (Test-Path -Path $Path)) + { + Write-Host -ForegroundColor Red "Item not found: $Path" + return $False + } + if ($null -eq $FilePatterns) + { + $FilePatterns = "" + } + $Path = Resolve-Path $Path + $Success = $True + $FilesToFormat = @() + if ((Get-Item -Path $Path) -is [System.IO.DirectoryInfo]) + { + Get-ChildItem -Path $Path -File ` + | Where-Object { $_ -match $FilePatterns } ` + | ForEach-Object { + $FilePath = "$Path\$_" + if (($null -eq $ModifiedFiles) -or ($ModifiedFiles -contains $FilePath)) + { + if (!($FilePath -match "Intermediate")) + { + $FilesToFormat += $FilePath + } + } + } + Get-ChildItem -Path $Path -Directory ` + | Where-Object { $_ -notmatch $IgnoreFolders } ` + | ForEach-Object { + $SubResult = (Format-Directory -Path "$Path\$_" ` + -ClangFormat $ClangFormat ` + -RepoRoot $RepoRoot ` + -FilePatterns $FilePatterns ` + -ModifiedFiles $ModifiedFiles ` + -Verify $Verify) + $Success = $SubResult -and $Success + } + } + else + { + $FilesToFormat += $Path + } + $FilesToFormat | ForEach-Object { + if ($Verify) + { + Write-Host "[clang-format] Checking formatting: $_" + & $ClangFormat --style=file -Werror --dry-run $_ + } + else + { + Write-Host "[clang-format] Formatting $_" + & $ClangFormat --style=file -Werror -i $_ + } + $Success = (0 -eq $LASTEXITCODE) -and $Success + } + return $Success + } +} + +$Success = (Format-Directory -Path $Path ` + -ClangFormat $ClangFormat ` + -FilePatterns $FilePatterns ` + -ModifiedFiles $ModifiedFiles ` + -RepoRoot $RepoRoot ` + -Verify $Verify) + +if ($Success) +{ + Write-Host "Done." + exit 0 +} +else +{ + Write-Host "You may need to update Visual studio and have the correct clang-format version in your local machine" + Write-Host -ForegroundColor Red "Errors found (see output). Please make sure to resolve all issues before opening a Pull Request." + Write-Host -ForegroundColor Red "Formatting can be applied by running:" + Write-Host -ForegroundColor Red " PowerShell.exe -ExecutionPolicy Bypass $PSCommandPath -ModifiedOnly `$False` [-Path ]" + Write-Host -ForegroundColor Red "or run below command in source/nodejs " + Write-Host -ForegroundColor Red " npm run format" + + if ($NoFail) + { + exit 0 # do not prevent commit when used in pre-commit hook + } + exit 1 +} \ No newline at end of file diff --git a/scripts/hooks/clangFormatFunc b/scripts/hooks/clangFormatFunc new file mode 100644 index 0000000000..5b536f1c8a --- /dev/null +++ b/scripts/hooks/clangFormatFunc @@ -0,0 +1,20 @@ +#!/bin/sh + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +endWith='\.(cpp|cc|h|hpp)$' +ignoreFolder='/(PerfApp|android|ios|nodejs|vscode|community|dotnet)/' + +function checkFormat() { + GIT_ROOT=`git rev-parse --show-toplevel` + git diff-index --cached --name-only HEAD | grep -iE "${endWith}" | grep -iE -v "${ignoreFolder}" | xargs -I _ -P 0 "$clangFormat" --dry-run -Werror --ferror-limit=1 --verbose "$GIT_ROOT/_" + return $? +} + +function fixFormat() { + + GIT_ROOT=`git rev-parse --show-toplevel` + git diff-index --cached --name-only HEAD | grep -iE "${endWith}" | grep -iE -v "${ignoreFolder}" | xargs -I _ -P 0 "$clangFormat" --style=file -Werror -i --verbose "$GIT_ROOT/_" + return $? +} diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit new file mode 100644 index 0000000000..ebbb71a719 --- /dev/null +++ b/scripts/hooks/pre-commit @@ -0,0 +1,37 @@ +#!/bin/sh + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +# clangFormat="c:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\x64\bin\clang-format.exe" +if [ -z "$clangFormat" ]; then + clangFormat="clang-format" +else + if [[ ! -f "$clangFormat" ]]; then + echo "Can't find the binary $clangFormat" + exit 1 + fi +fi + +"$clangFormat" --version +if [ "$?" -ne "0" ]; then + echo "'git commit' aborted! Please make sure clangFormat is set correctly in pre-commit." + exit 1 +fi + +. "scripts/hooks/clangFormatFunc" + +checkFormat + +if [ "$?" -ne "0" ]; then + echo "start auto fix clang-format" + fixFormat + if [ "$?" -ne "0" ]; then + echo "'git commit' aborted! Clang-format auto fix failed, and you have to manually fix the format issue." + else + echo "'git commit' aborted! But clang-format auto fix success, please re-run 'git add' and 'git commit'." + fi + exit 1 +else + echo "clang-format check passed, and will continue the commit" +fi diff --git a/source/nodejs/package-lock.json b/source/nodejs/package-lock.json index 049b7c2a73..156db236da 100644 --- a/source/nodejs/package-lock.json +++ b/source/nodejs/package-lock.json @@ -13,6 +13,8 @@ "@types/react-dom": "^16.9.14", "@typescript-eslint/eslint-plugin": "^5.2.0", "@typescript-eslint/parser": "^5.2.0", + "clang-format": "^1.5.0", + "clang-format-launcher": "^0.1.3", "copy-webpack-plugin": "^9.0.1", "css-loader": "^6.4.0", "dotenv-webpack": "^7.0.3", @@ -4291,6 +4293,40 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "node_modules/clang-format": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.6.0.tgz", + "integrity": "sha512-W3/L7fWkA8DoLkz9UGjrRnNi+J5a5TuS2HDLqk6WsicpOzb66MBu4eY/EcXhicHriVnAXWQVyk5/VeHWY6w4ow==", + "dev": true, + "dependencies": { + "async": "^1.5.2", + "glob": "^7.0.0", + "resolve": "^1.1.6" + }, + "bin": { + "check-clang-format": "bin/check-clang-format.js", + "clang-format": "index.js", + "git-clang-format": "bin/git-clang-format" + } + }, + "node_modules/clang-format-launcher": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/clang-format-launcher/-/clang-format-launcher-0.1.3.tgz", + "integrity": "sha512-+yiJBVyUFU9/fX6HcAu9fNBrc5x7nSrAkoLTf23YM8jVoz5AuEiGiNoODuQQOcwyxw6kfoqR+Lw2R4NHI9HKpQ==", + "dev": true, + "bin": { + "clang-format-launcher": "cli.js" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/clang-format/node_modules/async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, "node_modules/clean-css": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.2.tgz", @@ -18411,6 +18447,31 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "clang-format": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.6.0.tgz", + "integrity": "sha512-W3/L7fWkA8DoLkz9UGjrRnNi+J5a5TuS2HDLqk6WsicpOzb66MBu4eY/EcXhicHriVnAXWQVyk5/VeHWY6w4ow==", + "dev": true, + "requires": { + "async": "^1.5.2", + "glob": "^7.0.0", + "resolve": "^1.1.6" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + } + } + }, + "clang-format-launcher": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/clang-format-launcher/-/clang-format-launcher-0.1.3.tgz", + "integrity": "sha512-+yiJBVyUFU9/fX6HcAu9fNBrc5x7nSrAkoLTf23YM8jVoz5AuEiGiNoODuQQOcwyxw6kfoqR+Lw2R4NHI9HKpQ==", + "dev": true + }, "clean-css": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.2.tgz", diff --git a/source/nodejs/package.json b/source/nodejs/package.json index 801a2446c8..7c5abc517b 100644 --- a/source/nodejs/package.json +++ b/source/nodejs/package.json @@ -7,6 +7,8 @@ "start:designer-app": "lerna run start --scope=adaptivecards-designer-app --stream", "start:all": "lerna run --parallel watch && lerna run --parallel start", "audit-all": "lerna-audit", + "format": "clang-format-launcher --verbose", + "verify": "clang-format-launcher -verify --verbose", "prepare": "cd ../.. && husky install source/nodejs/.husky" }, "devDependencies": { @@ -43,6 +45,38 @@ "webpack": "^5.60.0", "webpack-cli": "^4.9.1", "webpack-concat-files-plugin": "^0.5.2", - "webpack-dev-server": "^4.3.1" + "webpack-dev-server": "^4.3.1", + "clang-format": "^1.5.0", + "clang-format-launcher": "^0.1.3" + }, + "clang-format-launcher": { + "includeEndsWith": [ + ".h", + ".cpp", + ".hpp", + ".c" + ], + "excludePathContains": [ + "/PerfApp/", + "/experimental/", + "/dotnet/", + "/community/", + "/pic2card/", + "/ios/", + "/nodejs/", + "/android/" + ], + "excludePathEndsWith": [ + ".g.h", + ".g.cpp", + "ObjectModel/jsoncpp.cpp" + ], + "excludePathStartsWith": [ + "specs/", + "samples", + "assets/", + "scripts" + ], + "style": "--style=file" } } diff --git a/source/shared/cpp/.clang-format b/source/shared/cpp/.clang-format deleted file mode 100644 index 9b5a16672a..0000000000 --- a/source/shared/cpp/.clang-format +++ /dev/null @@ -1,70 +0,0 @@ -# Note: directives below have been commented out to support Visual Studio, which currently only supports up to -# clang-format 5.0 -Language: Cpp -Standard: Cpp11 -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Left -AlignOperands: false -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: InlineOnly -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -#AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false -BinPackParameters: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Allman -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializers: AfterColon -#BreakInheritanceList: AfterColon -BreakStringLiterals: false -ColumnLimit: 120 -CompactNamespaces: true -ConstructorInitializerAllOnOneLineOrOnePerLine: false -Cpp11BracedListStyle: true -FixNamespaceComments: false -IndentCaseLabels: false -IndentPPDirectives: None -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: All -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 100 -PenaltyBreakComment: 40 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakString: 50 -#PenaltyBreakTemplateDeclaration: 100 -PenaltyExcessCharacter: 1 -PenaltyReturnTypeOnItsOwnLine: 100 -PointerAlignment: Left -ReflowComments: true -SortIncludes: false -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -#SpaceBeforeCpp11BracedList : false -#SpaceBeforeCtorInitializerColon: true -#SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -#SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -UseTab: Never diff --git a/source/shared/cpp/ObjectModel/jsoncpp.cpp b/source/shared/cpp/ObjectModel/jsoncpp.cpp index 488a4cd5d1..e1ff8115db 100644 --- a/source/shared/cpp/ObjectModel/jsoncpp.cpp +++ b/source/shared/cpp/ObjectModel/jsoncpp.cpp @@ -68,6 +68,8 @@ license you like. // End of content of file: LICENSE // ////////////////////////////////////////////////////////////////////// +// clang-format off + #include "pch.h" #ifdef USE_CPPCORECHECK @@ -5394,3 +5396,5 @@ JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) { #ifdef USE_CPPCORECHECK #pragma warning(pop) #endif + +// clang-format on \ No newline at end of file diff --git a/source/uwp/AdaptiveCardsObjectModel/.clang-format b/source/uwp/AdaptiveCardsObjectModel/.clang-format deleted file mode 100644 index 940d95b2d0..0000000000 --- a/source/uwp/AdaptiveCardsObjectModel/.clang-format +++ /dev/null @@ -1,70 +0,0 @@ -# Note: directives below have been commented out to support Visual Studio, which currently only supports up to -# clang-format 5.0 -Language: Cpp -Standard: Cpp11 -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: DontAlign -AlignOperands: false -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: InlineOnly -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -#AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false -BinPackParameters: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Allman -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializers: AfterColon -#BreakInheritanceList: AfterColon -BreakStringLiterals: false -ColumnLimit: 120 -CompactNamespaces: true -ConstructorInitializerAllOnOneLineOrOnePerLine: false -Cpp11BracedListStyle: true -FixNamespaceComments: false -IndentCaseLabels: false -IndentPPDirectives: None -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: All -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 100 -PenaltyBreakComment: 40 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakString: 50 -#PenaltyBreakTemplateDeclaration: 100 -PenaltyExcessCharacter: 1 -PenaltyReturnTypeOnItsOwnLine: 100 -PointerAlignment: Left -ReflowComments: true -SortIncludes: false -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -#SpaceBeforeCpp11BracedList : false -#SpaceBeforeCtorInitializerColon: true -#SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -#SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -UseTab: Never diff --git a/source/uwp/Renderer/.clang-format b/source/uwp/Renderer/.clang-format deleted file mode 100644 index 940d95b2d0..0000000000 --- a/source/uwp/Renderer/.clang-format +++ /dev/null @@ -1,70 +0,0 @@ -# Note: directives below have been commented out to support Visual Studio, which currently only supports up to -# clang-format 5.0 -Language: Cpp -Standard: Cpp11 -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: DontAlign -AlignOperands: false -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: InlineOnly -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -#AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false -BinPackParameters: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Allman -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializers: AfterColon -#BreakInheritanceList: AfterColon -BreakStringLiterals: false -ColumnLimit: 120 -CompactNamespaces: true -ConstructorInitializerAllOnOneLineOrOnePerLine: false -Cpp11BracedListStyle: true -FixNamespaceComments: false -IndentCaseLabels: false -IndentPPDirectives: None -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: All -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 100 -PenaltyBreakComment: 40 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakString: 50 -#PenaltyBreakTemplateDeclaration: 100 -PenaltyExcessCharacter: 1 -PenaltyReturnTypeOnItsOwnLine: 100 -PointerAlignment: Left -ReflowComments: true -SortIncludes: false -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -#SpaceBeforeCpp11BracedList : false -#SpaceBeforeCtorInitializerColon: true -#SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -#SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -UseTab: Never diff --git a/source/uwp/Renderer/lib/ElementTagContent.h b/source/uwp/Renderer/lib/ElementTagContent.h index 2b00b7069f..aadfe0aa37 100644 --- a/source/uwp/Renderer/lib/ElementTagContent.h +++ b/source/uwp/Renderer/lib/ElementTagContent.h @@ -5,6 +5,7 @@ namespace AdaptiveCards::Rendering::Uwp { + // clang-format off interface __declspec(uuid("0331D653-957C-4385-A327-D326750C10B6")) IElementTagContent : IInspectable { public: @@ -21,6 +22,7 @@ namespace AdaptiveCards::Rendering::Uwp virtual HRESULT get_IsStretchable(_Outptr_ boolean * isStretchable) = 0; virtual HRESULT put_IsStretchable(boolean isStretchable) = 0; }; + // clang-format on class ElementTagContent : public Microsoft::WRL::RuntimeClass, IElementTagContent>