├── .editorconfig ├── .gitattributes ├── .gitignore ├── Build.cmd ├── CODE-OF-CONDUCT.md ├── License.txt ├── NuGet.config ├── README.md ├── Restore.cmd ├── SymReaderPortable.sln ├── THIRD-PARTY-NOTICES ├── Test.cmd ├── azure-pipelines-PR.yml ├── azure-pipelines.yml ├── build.sh ├── eng ├── Publishing.props ├── Signing.props ├── Version.Details.xml ├── Versions.props ├── common │ ├── BuildConfiguration │ │ └── build-configuration.json │ ├── CIBuild.cmd │ ├── PSScriptAnalyzerSettings.psd1 │ ├── README.md │ ├── SetupNugetSources.ps1 │ ├── SetupNugetSources.sh │ ├── build.cmd │ ├── build.ps1 │ ├── build.sh │ ├── cibuild.sh │ ├── core-templates │ │ ├── job │ │ │ ├── job.yml │ │ │ ├── onelocbuild.yml │ │ │ ├── publish-build-assets.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1.yml │ │ ├── jobs │ │ │ ├── codeql-build.yml │ │ │ ├── jobs.yml │ │ │ └── source-build.yml │ │ ├── post-build │ │ │ ├── common-variables.yml │ │ │ ├── post-build.yml │ │ │ └── setup-maestro-vars.yml │ │ ├── steps │ │ │ ├── cleanup-microbuild.yml │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── enable-internal-sources.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── install-microbuild.yml │ │ │ ├── publish-build-artifacts.yml │ │ │ ├── publish-logs.yml │ │ │ ├── publish-pipeline-artifacts.yml │ │ │ ├── retain-build.yml │ │ │ ├── send-to-helix.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1-publish.yml │ │ └── variables │ │ │ └── pool-providers.yml │ ├── cross │ │ ├── arm │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── arm64 │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── armel │ │ │ ├── armel.jessie.patch │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── build-android-rootfs.sh │ │ ├── build-rootfs.sh │ │ ├── install-debs.py │ │ ├── riscv64 │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── tizen-build-rootfs.sh │ │ ├── tizen-fetch.sh │ │ ├── toolchain.cmake │ │ ├── x64 │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ └── x86 │ │ │ └── tizen │ │ │ └── tizen.patch │ ├── darc-init.ps1 │ ├── darc-init.sh │ ├── dotnet-install.cmd │ ├── dotnet-install.ps1 │ ├── dotnet-install.sh │ ├── enable-cross-org-publishing.ps1 │ ├── generate-locproject.ps1 │ ├── generate-sbom-prep.ps1 │ ├── generate-sbom-prep.sh │ ├── helixpublish.proj │ ├── init-tools-native.cmd │ ├── init-tools-native.ps1 │ ├── init-tools-native.sh │ ├── internal-feed-operations.ps1 │ ├── internal-feed-operations.sh │ ├── internal │ │ ├── Directory.Build.props │ │ ├── NuGet.config │ │ └── Tools.csproj │ ├── loc │ │ └── P22DotNetHtmlLocalization.lss │ ├── msbuild.ps1 │ ├── msbuild.sh │ ├── native │ │ ├── CommonLibrary.psm1 │ │ ├── common-library.sh │ │ ├── init-compiler.sh │ │ ├── init-distro-rid.sh │ │ ├── init-os-and-arch.sh │ │ ├── install-cmake-test.sh │ │ ├── install-cmake.sh │ │ ├── install-dependencies.sh │ │ └── install-tool.ps1 │ ├── pipeline-logging-functions.ps1 │ ├── pipeline-logging-functions.sh │ ├── post-build │ │ ├── check-channel-consistency.ps1 │ │ ├── nuget-validation.ps1 │ │ ├── nuget-verification.ps1 │ │ ├── publish-using-darc.ps1 │ │ ├── redact-logs.ps1 │ │ ├── sourcelink-validation.ps1 │ │ └── symbols-validation.ps1 │ ├── retain-build.ps1 │ ├── sdk-task.ps1 │ ├── sdl │ │ ├── NuGet.config │ │ ├── configure-sdl-tool.ps1 │ │ ├── execute-all-sdl-tools.ps1 │ │ ├── extract-artifact-archives.ps1 │ │ ├── extract-artifact-packages.ps1 │ │ ├── init-sdl.ps1 │ │ ├── packages.config │ │ ├── run-sdl.ps1 │ │ ├── sdl.ps1 │ │ └── trim-assets-version.ps1 │ ├── template-guidance.md │ ├── templates-official │ │ ├── job │ │ │ ├── job.yml │ │ │ ├── onelocbuild.yml │ │ │ ├── publish-build-assets.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1.yml │ │ ├── jobs │ │ │ ├── codeql-build.yml │ │ │ ├── jobs.yml │ │ │ └── source-build.yml │ │ ├── post-build │ │ │ ├── common-variables.yml │ │ │ ├── post-build.yml │ │ │ └── setup-maestro-vars.yml │ │ ├── steps │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── enable-internal-sources.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── publish-build-artifacts.yml │ │ │ ├── publish-logs.yml │ │ │ ├── publish-pipeline-artifacts.yml │ │ │ ├── retain-build.yml │ │ │ ├── send-to-helix.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1-publish.yml │ │ └── variables │ │ │ ├── pool-providers.yml │ │ │ └── sdl-variables.yml │ ├── templates │ │ ├── job │ │ │ ├── job.yml │ │ │ ├── onelocbuild.yml │ │ │ ├── publish-build-assets.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1.yml │ │ ├── jobs │ │ │ ├── codeql-build.yml │ │ │ ├── jobs.yml │ │ │ └── source-build.yml │ │ ├── post-build │ │ │ ├── common-variables.yml │ │ │ ├── post-build.yml │ │ │ └── setup-maestro-vars.yml │ │ ├── steps │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── enable-internal-sources.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── publish-build-artifacts.yml │ │ │ ├── publish-logs.yml │ │ │ ├── publish-pipeline-artifacts.yml │ │ │ ├── retain-build.yml │ │ │ ├── send-to-helix.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1-publish.yml │ │ └── variables │ │ │ └── pool-providers.yml │ ├── tools.ps1 │ └── tools.sh └── tsaconfig.gdntsa ├── global.json ├── restore.sh ├── src ├── Directory.Build.props ├── Directory.Build.targets ├── Microsoft.DiaSymReader.PortablePdb.NativeTests │ ├── Microsoft.DiaSymReader.PortablePdb.Native.UnitTests.vcxproj │ ├── Microsoft.DiaSymReader.PortablePdb.Native.UnitTests.vcxproj.filters │ └── SymReaderTests.cpp ├── Microsoft.DiaSymReader.PortablePdb.Tests │ ├── EmbeddedSourceTests.cs │ ├── EncTests.cs │ ├── MethodMapTests.cs │ ├── Microsoft.DiaSymReader.PortablePdb.UnitTests.csproj │ ├── Resources │ │ ├── Async.cmd │ │ ├── Async.cs │ │ ├── Async.dll │ │ ├── Async.dllx │ │ ├── Async.pdb │ │ ├── Async.pdbx │ │ ├── Documents.cmd │ │ ├── Documents.cs │ │ ├── Documents.dll │ │ ├── Documents.dllx │ │ ├── Documents.pdb │ │ ├── Documents.pdbx │ │ ├── EmbeddedSource.cmd │ │ ├── EmbeddedSource.cs │ │ ├── EmbeddedSource.dll │ │ ├── EmbeddedSource.dllx │ │ ├── EmbeddedSource.pdb │ │ ├── EmbeddedSource.pdbx │ │ ├── EmbeddedSourceNoCode.cs │ │ ├── EmbeddedSourceNoSequencePoints.cs │ │ ├── EmbeddedSourceSmall.cs │ │ ├── EncDocuments │ │ │ ├── App.dll │ │ │ ├── App.dllx │ │ │ ├── App.pdb │ │ │ ├── App.pdbx │ │ │ ├── Delta.pdb │ │ │ └── Delta.pdbx │ │ ├── EncMethodExtents │ │ │ ├── EncMethodExtents.1.metadata │ │ │ ├── EncMethodExtents.1.metadatax │ │ │ ├── EncMethodExtents.1.pdb │ │ │ ├── EncMethodExtents.1.pdbx │ │ │ ├── EncMethodExtents.2.metadata │ │ │ ├── EncMethodExtents.2.metadatax │ │ │ ├── EncMethodExtents.2.pdb │ │ │ ├── EncMethodExtents.2.pdbx │ │ │ ├── EncMethodExtents.dll │ │ │ ├── EncMethodExtents.dllx │ │ │ ├── EncMethodExtents.pdb │ │ │ └── EncMethodExtents.pdbx │ │ ├── MethodBoundaries.cmd │ │ ├── MethodBoundaries.cs │ │ ├── MethodBoundaries.dll │ │ ├── MethodBoundaries.dllx │ │ ├── MethodBoundaries.pdb │ │ ├── MethodBoundaries.pdbx │ │ ├── MiscEmbedded.cmd │ │ ├── MiscEmbedded.cs │ │ ├── MiscEmbedded.dll │ │ ├── Scopes.cmd │ │ ├── Scopes.cs │ │ ├── Scopes.dll │ │ ├── Scopes.dllx │ │ ├── Scopes.pdb │ │ ├── Scopes.pdbx │ │ ├── SourceData.pdb │ │ ├── SourceLink.Embedded.dll │ │ ├── SourceLink.cmd │ │ ├── SourceLink.dll │ │ ├── SourceLink.dllx │ │ ├── SourceLink.json │ │ ├── SourceLink.pdb │ │ └── SourceLink.pdbx │ ├── SymBinderTests.cs │ ├── SymReaderTests.cs │ └── TestHelpers │ │ ├── AssertEx.cs │ │ ├── ConditionalFactAttribute.cs │ │ ├── EnumerableHelpersTests.cs │ │ ├── PdbTestData.cs │ │ ├── ResourceLoader.cs │ │ ├── SymMetadataProvider.cs │ │ ├── SymTestHelpers.cs │ │ ├── TestIMetadataImport.cs │ │ ├── TestResource.cs │ │ └── TestResources.cs └── Microsoft.DiaSymReader.PortablePdb │ ├── AsyncMethodData.cs │ ├── ChildScopeData.cs │ ├── DocumentId.cs │ ├── DocumentMap.cs │ ├── IMetadataImport.cs │ ├── InvalidInputDataException.cs │ ├── MetadataImport.cs │ ├── MethodExtent.cs │ ├── MethodExtents.cs │ ├── MethodId.cs │ ├── MethodLineDeltas.cs │ ├── MethodMap.cs │ ├── Microsoft.DiaSymReader.PortablePdb.csproj │ ├── PortablePdbReader.cs │ ├── RootScopeData.cs │ ├── ScopeData.cs │ ├── SymBinder.cs │ ├── SymConstant.cs │ ├── SymDocument.cs │ ├── SymMethod.cs │ ├── SymReader.cs │ ├── SymScope.cs │ ├── SymVariable.cs │ └── Utilities │ ├── BlobWriter.cs │ ├── Debug.cs │ ├── EmptyArray.cs │ ├── EnumerableHelpers.cs │ ├── ExceptionUtilities.cs │ ├── FileNameUtilities.cs │ ├── HResult.cs │ ├── HashHelpers.cs │ ├── ImmutableArrayExtensions.cs │ ├── ImmutableByteArrayInterop.cs │ ├── InteropUtilities.cs │ ├── KeyValuePair.cs │ ├── LazyMetadataImport.cs │ ├── MetadataUtilities.cs │ ├── Nullable.cs │ ├── PortableShim.cs │ ├── ReadOnlyInteropStream.cs │ ├── ReflectionUtilities.cs │ ├── StreamExtensions.cs │ ├── TupleElementNamesAttribute.cs │ └── ValueTuple.cs └── test.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to: 3 | # automatically normalize line endings on check-in, and 4 | # convert to Windows-style line endings on check-out 5 | ############################################################################### 6 | * text=auto encoding=UTF-8 7 | *.sh text eol=lf 8 | 9 | ############################################################################### 10 | # Set file behavior to: 11 | # treat as text, and 12 | # diff as C# source code 13 | ############################################################################### 14 | *.cs text diff=csharp 15 | 16 | ############################################################################### 17 | # Set file behavior to: 18 | # treat as text 19 | ############################################################################### 20 | *.cmd text 21 | *.config text 22 | *.csproj text 23 | *.groovy text 24 | *.json text 25 | *.md text 26 | *.nuspec text 27 | *.pkgdef text 28 | *.proj text 29 | *.projitems text 30 | *.props text 31 | *.ps1 text 32 | *.resx text 33 | *.ruleset text 34 | *.shproj text 35 | *.sln text 36 | *.targets text 37 | *.vb text 38 | *.vbproj text 39 | *.vcxproj text 40 | *.vcxproj.filters text 41 | *.vsct text 42 | *.vsixmanifest text 43 | 44 | ############################################################################### 45 | # Set file behavior to: 46 | # treat as binary 47 | ############################################################################### 48 | *.png binary 49 | *.snk binary 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | .vs/ 8 | .vscode/ 9 | 10 | # Build results 11 | artifacts/ 12 | Debug/ 13 | Release/ 14 | bin/ 15 | obj/ 16 | .dotnet/ 17 | .tools/ 18 | .packages/ 19 | 20 | # Per-user project properties 21 | launchSettings.json 22 | 23 | # Visual Studio profiler 24 | *.psess 25 | *.vsp 26 | *.vspx 27 | 28 | # ReSharper is a .NET coding add-in 29 | _ReSharper*/ 30 | *.[Rr]e[Ss]harper 31 | 32 | # DotCover is a Code Coverage Tool 33 | *.dotCover 34 | 35 | # NCrunch 36 | *.ncrunch* 37 | .*crunch*.local.xml 38 | -------------------------------------------------------------------------------- /Build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore -build %*" 3 | exit /b %ErrorLevel% 4 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project has adopted the code of conduct defined by the Contributor Covenant 4 | to clarify expected behavior in our community. 5 | 6 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). 7 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft.DiaSymReader.PortablePdb 2 | 3 | Reader of [Portable PDBs](https://github.com/dotnet/core/blob/main/Documentation/diagnostics/portable_pdb.md) format that implements DiaSymReader interfaces ([ISymUnmanagedReader](https://msdn.microsoft.com/en-us/library/ms232131.aspx), [ISymUnmanagedBinder](https://msdn.microsoft.com/en-us/library/ms232451.aspx), etc.). 4 | 5 | The definitions of the DiaSymReader COM interfaces are provided by [Microsoft.DiaSymReader](https://www.nuget.org/packages/Microsoft.DiaSymReader) package. 6 | The implementation of these interfaces for Windows PDBs is provided by [Microsoft.DiaSymReader.Native](https://www.nuget.org/packages/Microsoft.DiaSymReader.Native) package. 7 | 8 | It is recommended that new applications and libraries read Portable PDBs directly using APIs provided by [System.Reflection.Metadata](https://www.nuget.org/packages/System.Reflection.Metadata) package. These APIs are much more efficient than DiaSymReader APIs. Microsoft.DiaSymReader.PortablePdb bridge is recommended for existings apps that already use DiaSymReader APIs and need to be able to read Portable PDBs without significant changes to their source. 9 | 10 | Pre-release builds are available from Azure DevOps public feed: `https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json` ([browse](https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet-tools)). 11 | 12 | [![Build Status](https://dnceng.visualstudio.com/public/_apis/build/status/SymReaderPortable%20PR?branchName=main)](https://dnceng.visualstudio.com/public/_build/latest?definitionId=296?branchName=main) 13 | -------------------------------------------------------------------------------- /Restore.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore %*" 3 | exit /b %ErrorLevel% 4 | -------------------------------------------------------------------------------- /SymReaderPortable.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26725.2 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DiaSymReader.PortablePdb", "src\Microsoft.DiaSymReader.PortablePdb\Microsoft.DiaSymReader.PortablePdb.csproj", "{0B7BE784-8FBA-419D-82B2-377EA827CD62}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DiaSymReader.PortablePdb.UnitTests", "src\Microsoft.DiaSymReader.PortablePdb.Tests\Microsoft.DiaSymReader.PortablePdb.UnitTests.csproj", "{A6254A83-E3EF-47B8-967E-8D1455CE6905}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FA0C23C9-1AF8-4DF6-B75A-E33BC1D2E332}" 11 | ProjectSection(SolutionItems) = preProject 12 | .editorconfig = .editorconfig 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Debug|x64 = Debug|x64 19 | Release|Any CPU = Release|Any CPU 20 | Release|x64 = Release|x64 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Debug|x64.ActiveCfg = Debug|Any CPU 26 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Debug|x64.Build.0 = Debug|Any CPU 27 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Release|x64.ActiveCfg = Release|Any CPU 30 | {0B7BE784-8FBA-419D-82B2-377EA827CD62}.Release|x64.Build.0 = Release|Any CPU 31 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Debug|x64.ActiveCfg = Debug|Any CPU 34 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Debug|x64.Build.0 = Debug|Any CPU 35 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Release|Any CPU.Build.0 = Release|Any CPU 37 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Release|x64.ActiveCfg = Release|Any CPU 38 | {A6254A83-E3EF-47B8-967E-8D1455CE6905}.Release|x64.Build.0 = Release|Any CPU 39 | EndGlobalSection 40 | GlobalSection(SolutionProperties) = preSolution 41 | HideSolutionNode = FALSE 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityGlobals) = postSolution 44 | SolutionGuid = {6BF7BC52-A26D-43DC-BBF5-6DC93B4836C9} 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /THIRD-PARTY-NOTICES: -------------------------------------------------------------------------------- 1 | .NET Core uses third-party libraries or other resources that may be 2 | distributed under licenses different than the .NET Core software. 3 | 4 | In the event that we accidentally failed to list a required notice, please 5 | bring it to our attention. Post an issue or email us: 6 | 7 | dotnet@microsoft.com 8 | 9 | The attached notices are provided for information only. 10 | 11 | License notice for dotnet/corefx 12 | -------------------------------- 13 | 14 | https://github.com/dotnet/corefx/blob/master/LICENSE 15 | 16 | The MIT License (MIT) 17 | 18 | Copyright (c) .NET Foundation and Contributors 19 | 20 | Permission is hereby granted, free of charge, to any person obtaining a copy 21 | of this software and associated documentation files (the "Software"), to deal 22 | in the Software without restriction, including without limitation the rights 23 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | copies of the Software, and to permit persons to whom the Software is 25 | furnished to do so, subject to the following conditions: 26 | 27 | The above copyright notice and this permission notice shall be included in all 28 | copies or substantial portions of the Software. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | SOFTWARE. 37 | -------------------------------------------------------------------------------- /Test.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -test %*" 3 | exit /b %ErrorLevel% -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where the 11 | # symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | 15 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 16 | "$scriptroot/eng/common/build.sh" --build --restore $@ -------------------------------------------------------------------------------- /eng/Publishing.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 3 6 | 7 | 8 | -------------------------------------------------------------------------------- /eng/Signing.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | 5 | 6 | -------------------------------------------------------------------------------- /eng/Version.Details.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | https://github.com/dotnet/arcade 8 | bbea86c614fcf4380c58c80eacd279a0b8305a79 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /eng/Versions.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 2.0.0 7 | beta 8 | true 9 | 10 | false 11 | true 12 | true 13 | 14 | 2.2.0-beta.24327.1 15 | 16 | 17 | 17.0.0-beta1.21524.1 18 | 19 | 5.0.0 20 | 5.0.0 21 | 4.5.0 22 | 23 | 24 | -------------------------------------------------------------------------------- /eng/common/BuildConfiguration/build-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "RetryCountLimit": 1, 3 | "RetryByAnyError": false 4 | } 5 | -------------------------------------------------------------------------------- /eng/common/CIBuild.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*" -------------------------------------------------------------------------------- /eng/common/PSScriptAnalyzerSettings.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | IncludeRules=@('PSAvoidUsingCmdletAliases', 3 | 'PSAvoidUsingWMICmdlet', 4 | 'PSAvoidUsingPositionalParameters', 5 | 'PSAvoidUsingInvokeExpression', 6 | 'PSUseDeclaredVarsMoreThanAssignments', 7 | 'PSUseCmdletCorrectly', 8 | 'PSStandardDSCFunctionsInResource', 9 | 'PSUseIdenticalMandatoryParametersForDSC', 10 | 'PSUseIdenticalParametersForDSC') 11 | } -------------------------------------------------------------------------------- /eng/common/README.md: -------------------------------------------------------------------------------- 1 | # Don't touch this folder 2 | 3 | uuuuuuuuuuuuuuuuuuuu 4 | u" uuuuuuuuuuuuuuuuuu "u 5 | u" u$$$$$$$$$$$$$$$$$$$$u "u 6 | u" u$$$$$$$$$$$$$$$$$$$$$$$$u "u 7 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u 8 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u 9 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u 10 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ 11 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ 12 | $ $$$" ... "$... ...$" ... "$$$ ... "$$$ $ 13 | $ $$$u `"$$$$$$$ $$$ $$$$$ $$ $$$ $$$ $ 14 | $ $$$$$$uu "$$$$ $$$ $$$$$ $$ """ u$$$ $ 15 | $ $$$""$$$ $$$$ $$$u "$$$" u$$ $$$$$$$$ $ 16 | $ $$$$....,$$$$$..$$$$$....,$$$$..$$$$$$$$ $ 17 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ 18 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" 19 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" 20 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" 21 | "u "$$$$$$$$$$$$$$$$$$$$$$$$" u" 22 | "u "$$$$$$$$$$$$$$$$$$$$" u" 23 | "u """""""""""""""""" u" 24 | """""""""""""""""""" 25 | 26 | !!! Changes made in this directory are subject to being overwritten by automation !!! 27 | 28 | The files in this directory are shared by all Arcade repos and managed by automation. If you need to make changes to these files, open an issue or submit a pull request to https://github.com/dotnet/arcade first. 29 | -------------------------------------------------------------------------------- /eng/common/build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0build.ps1""" %*" 3 | exit /b %ErrorLevel% 4 | -------------------------------------------------------------------------------- /eng/common/cibuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where 11 | # the symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 15 | 16 | . "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@ -------------------------------------------------------------------------------- /eng/common/core-templates/job/source-index-stage1.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | runAsPublic: false 3 | sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci" 4 | preSteps: [] 5 | binlogPath: artifacts/log/Debug/Build.binlog 6 | condition: '' 7 | dependsOn: '' 8 | pool: '' 9 | is1ESPipeline: '' 10 | 11 | jobs: 12 | - job: SourceIndexStage1 13 | dependsOn: ${{ parameters.dependsOn }} 14 | condition: ${{ parameters.condition }} 15 | variables: 16 | - name: BinlogPath 17 | value: ${{ parameters.binlogPath }} 18 | - template: /eng/common/core-templates/variables/pool-providers.yml 19 | parameters: 20 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 21 | 22 | ${{ if ne(parameters.pool, '') }}: 23 | pool: ${{ parameters.pool }} 24 | ${{ if eq(parameters.pool, '') }}: 25 | pool: 26 | ${{ if eq(variables['System.TeamProject'], 'public') }}: 27 | name: $(DncEngPublicBuildPool) 28 | image: windows.vs2022.amd64.open 29 | ${{ if eq(variables['System.TeamProject'], 'internal') }}: 30 | name: $(DncEngInternalBuildPool) 31 | image: windows.vs2022.amd64 32 | 33 | steps: 34 | - ${{ if eq(parameters.is1ESPipeline, '') }}: 35 | - 'Illegal entry point, is1ESPipeline is not defined. Repository yaml should not directly reference templates in core-templates folder.': error 36 | 37 | - ${{ each preStep in parameters.preSteps }}: 38 | - ${{ preStep }} 39 | - script: ${{ parameters.sourceIndexBuildCommand }} 40 | displayName: Build Repository 41 | 42 | - template: /eng/common/core-templates/steps/source-index-stage1-publish.yml 43 | parameters: 44 | binLogPath: ${{ parameters.binLogPath }} -------------------------------------------------------------------------------- /eng/common/core-templates/jobs/codeql-build.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md 3 | continueOnError: false 4 | # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job 5 | jobs: [] 6 | # Optional: if specified, restore and use this version of Guardian instead of the default. 7 | overrideGuardianVersion: '' 8 | is1ESPipeline: '' 9 | 10 | jobs: 11 | - template: /eng/common/core-templates/jobs/jobs.yml 12 | parameters: 13 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 14 | enableMicrobuild: false 15 | enablePublishBuildArtifacts: false 16 | enablePublishTestResults: false 17 | enablePublishBuildAssets: false 18 | enablePublishUsingPipelines: false 19 | enableTelemetry: true 20 | 21 | variables: 22 | - group: Publish-Build-Assets 23 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in 24 | # sync with the packages.config file. 25 | - name: DefaultGuardianVersion 26 | value: 0.109.0 27 | - name: GuardianPackagesConfigFile 28 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config 29 | - name: GuardianVersion 30 | value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }} 31 | 32 | jobs: ${{ parameters.jobs }} 33 | 34 | -------------------------------------------------------------------------------- /eng/common/core-templates/jobs/source-build.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # This template adds arcade-powered source-build to CI. A job is created for each platform, as 3 | # well as an optional server job that completes when all platform jobs complete. 4 | 5 | # The name of the "join" job for all source-build platforms. If set to empty string, the job is 6 | # not included. Existing repo pipelines can use this job depend on all source-build jobs 7 | # completing without maintaining a separate list of every single job ID: just depend on this one 8 | # server job. By default, not included. Recommended name if used: 'Source_Build_Complete'. 9 | allCompletedJobId: '' 10 | 11 | # See /eng/common/core-templates/job/source-build.yml 12 | jobNamePrefix: 'Source_Build' 13 | 14 | # This is the default platform provided by Arcade, intended for use by a managed-only repo. 15 | defaultManagedPlatform: 16 | name: 'Managed' 17 | container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9' 18 | 19 | # Defines the platforms on which to run build jobs. One job is created for each platform, and the 20 | # object in this array is sent to the job template as 'platform'. If no platforms are specified, 21 | # one job runs on 'defaultManagedPlatform'. 22 | platforms: [] 23 | 24 | is1ESPipeline: '' 25 | 26 | # If set to true and running on a non-public project, 27 | # Internal nuget and blob storage locations will be enabled. 28 | # This is not enabled by default because many repositories do not need internal sources 29 | # and do not need to have the required service connections approved in the pipeline. 30 | enableInternalSources: false 31 | 32 | jobs: 33 | 34 | - ${{ if ne(parameters.allCompletedJobId, '') }}: 35 | - job: ${{ parameters.allCompletedJobId }} 36 | displayName: Source-Build Complete 37 | pool: server 38 | dependsOn: 39 | - ${{ each platform in parameters.platforms }}: 40 | - ${{ parameters.jobNamePrefix }}_${{ platform.name }} 41 | - ${{ if eq(length(parameters.platforms), 0) }}: 42 | - ${{ parameters.jobNamePrefix }}_${{ parameters.defaultManagedPlatform.name }} 43 | 44 | - ${{ each platform in parameters.platforms }}: 45 | - template: /eng/common/core-templates/job/source-build.yml 46 | parameters: 47 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 48 | jobNamePrefix: ${{ parameters.jobNamePrefix }} 49 | platform: ${{ platform }} 50 | enableInternalSources: ${{ parameters.enableInternalSources }} 51 | 52 | - ${{ if eq(length(parameters.platforms), 0) }}: 53 | - template: /eng/common/core-templates/job/source-build.yml 54 | parameters: 55 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 56 | jobNamePrefix: ${{ parameters.jobNamePrefix }} 57 | platform: ${{ parameters.defaultManagedPlatform }} 58 | enableInternalSources: ${{ parameters.enableInternalSources }} 59 | -------------------------------------------------------------------------------- /eng/common/core-templates/post-build/common-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | - group: Publish-Build-Assets 3 | 4 | # Whether the build is internal or not 5 | - name: IsInternalBuild 6 | value: ${{ and(ne(variables['System.TeamProject'], 'public'), contains(variables['Build.SourceBranch'], 'internal')) }} 7 | 8 | # Default Maestro++ API Endpoint and API Version 9 | - name: MaestroApiEndPoint 10 | value: "https://maestro.dot.net" 11 | - name: MaestroApiVersion 12 | value: "2020-02-20" 13 | 14 | - name: SourceLinkCLIVersion 15 | value: 3.0.0 16 | - name: SymbolToolVersion 17 | value: 1.0.1 18 | - name: BinlogToolVersion 19 | value: 1.0.11 20 | 21 | - name: runCodesignValidationInjection 22 | value: false 23 | -------------------------------------------------------------------------------- /eng/common/core-templates/post-build/setup-maestro-vars.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | BARBuildId: '' 3 | PromoteToChannelIds: '' 4 | is1ESPipeline: '' 5 | 6 | steps: 7 | - ${{ if eq(parameters.is1ESPipeline, '') }}: 8 | - 'Illegal entry point, is1ESPipeline is not defined. Repository yaml should not directly reference templates in core-templates folder.': error 9 | 10 | - ${{ if eq(coalesce(parameters.PromoteToChannelIds, 0), 0) }}: 11 | - task: DownloadBuildArtifacts@0 12 | displayName: Download Release Configs 13 | inputs: 14 | buildType: current 15 | artifactName: ReleaseConfigs 16 | checkDownloadedFiles: true 17 | 18 | - task: AzureCLI@2 19 | name: setReleaseVars 20 | displayName: Set Release Configs Vars 21 | inputs: 22 | azureSubscription: "Darc: Maestro Production" 23 | scriptType: pscore 24 | scriptLocation: inlineScript 25 | inlineScript: | 26 | try { 27 | if (!$Env:PromoteToMaestroChannels -or $Env:PromoteToMaestroChannels.Trim() -eq '') { 28 | $Content = Get-Content $(Build.StagingDirectory)/ReleaseConfigs/ReleaseConfigs.txt 29 | 30 | $BarId = $Content | Select -Index 0 31 | $Channels = $Content | Select -Index 1 32 | $IsStableBuild = $Content | Select -Index 2 33 | 34 | $AzureDevOpsProject = $Env:System_TeamProject 35 | $AzureDevOpsBuildDefinitionId = $Env:System_DefinitionId 36 | $AzureDevOpsBuildId = $Env:Build_BuildId 37 | } 38 | else { 39 | . $(Build.SourcesDirectory)\eng\common\tools.ps1 40 | $darc = Get-Darc 41 | $buildInfo = & $darc get-build ` 42 | --id ${{ parameters.BARBuildId }} ` 43 | --extended ` 44 | --output-format json ` 45 | --ci ` 46 | | convertFrom-Json 47 | 48 | $BarId = ${{ parameters.BARBuildId }} 49 | $Channels = $Env:PromoteToMaestroChannels -split "," 50 | $Channels = $Channels -join "][" 51 | $Channels = "[$Channels]" 52 | 53 | $IsStableBuild = $buildInfo.stable 54 | $AzureDevOpsProject = $buildInfo.azureDevOpsProject 55 | $AzureDevOpsBuildDefinitionId = $buildInfo.azureDevOpsBuildDefinitionId 56 | $AzureDevOpsBuildId = $buildInfo.azureDevOpsBuildId 57 | } 58 | 59 | Write-Host "##vso[task.setvariable variable=BARBuildId]$BarId" 60 | Write-Host "##vso[task.setvariable variable=TargetChannels]$Channels" 61 | Write-Host "##vso[task.setvariable variable=IsStableBuild]$IsStableBuild" 62 | 63 | Write-Host "##vso[task.setvariable variable=AzDOProjectName]$AzureDevOpsProject" 64 | Write-Host "##vso[task.setvariable variable=AzDOPipelineId]$AzureDevOpsBuildDefinitionId" 65 | Write-Host "##vso[task.setvariable variable=AzDOBuildId]$AzureDevOpsBuildId" 66 | } 67 | catch { 68 | Write-Host $_ 69 | Write-Host $_.Exception 70 | Write-Host $_.ScriptStackTrace 71 | exit 1 72 | } 73 | env: 74 | PromoteToMaestroChannels: ${{ parameters.PromoteToChannelIds }} 75 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/cleanup-microbuild.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # Enable cleanup tasks for MicroBuild 3 | enableMicrobuild: false 4 | # Enable cleanup tasks for MicroBuild on Mac and Linux 5 | # Will be ignored if 'enableMicrobuild' is false or 'Agent.Os' is 'Windows_NT' 6 | enableMicrobuildForMacAndLinux: false 7 | continueOnError: false 8 | 9 | steps: 10 | - ${{ if eq(parameters.enableMicrobuild, 'true') }}: 11 | - task: MicroBuildCleanup@1 12 | displayName: Execute Microbuild cleanup tasks 13 | condition: and( 14 | always(), 15 | or( 16 | and( 17 | eq(variables['Agent.Os'], 'Windows_NT'), 18 | in(variables['_SignType'], 'real', 'test') 19 | ), 20 | and( 21 | ${{ eq(parameters.enableMicrobuildForMacAndLinux, true) }}, 22 | ne(variables['Agent.Os'], 'Windows_NT'), 23 | eq(variables['_SignType'], 'real') 24 | ) 25 | )) 26 | continueOnError: ${{ parameters.continueOnError }} 27 | env: 28 | TeamName: $(_TeamName) 29 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | disableComponentGovernance: false 3 | componentGovernanceIgnoreDirectories: '' 4 | is1ESPipeline: false 5 | displayName: 'Component Detection' 6 | 7 | steps: 8 | - ${{ if eq(parameters.disableComponentGovernance, 'true') }}: 9 | - script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true" 10 | displayName: Set skipComponentGovernanceDetection variable 11 | - ${{ if ne(parameters.disableComponentGovernance, 'true') }}: 12 | - task: ComponentGovernanceComponentDetection@0 13 | continueOnError: true 14 | displayName: ${{ parameters.displayName }} 15 | inputs: 16 | ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} 17 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/enable-internal-runtimes.yml: -------------------------------------------------------------------------------- 1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64' 2 | # variable with the base64-encoded SAS token, by default 3 | 4 | parameters: 5 | - name: federatedServiceConnection 6 | type: string 7 | default: 'dotnetbuilds-internal-read' 8 | - name: outputVariableName 9 | type: string 10 | default: 'dotnetbuilds-internal-container-read-token-base64' 11 | - name: expiryInHours 12 | type: number 13 | default: 1 14 | - name: base64Encode 15 | type: boolean 16 | default: true 17 | - name: is1ESPipeline 18 | type: boolean 19 | default: false 20 | 21 | steps: 22 | - ${{ if ne(variables['System.TeamProject'], 'public') }}: 23 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml 24 | parameters: 25 | federatedServiceConnection: ${{ parameters.federatedServiceConnection }} 26 | outputVariableName: ${{ parameters.outputVariableName }} 27 | expiryInHours: ${{ parameters.expiryInHours }} 28 | base64Encode: ${{ parameters.base64Encode }} 29 | storageAccount: dotnetbuilds 30 | container: internal 31 | permissions: rl 32 | is1ESPipeline: ${{ parameters.is1ESPipeline }} -------------------------------------------------------------------------------- /eng/common/core-templates/steps/enable-internal-sources.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # This is the Azure federated service connection that we log into to get an access token. 3 | - name: nugetFederatedServiceConnection 4 | type: string 5 | default: 'dnceng-artifacts-feeds-read' 6 | - name: is1ESPipeline 7 | type: boolean 8 | default: false 9 | # Legacy parameters to allow for PAT usage 10 | - name: legacyCredential 11 | type: string 12 | default: '' 13 | 14 | steps: 15 | - ${{ if ne(variables['System.TeamProject'], 'public') }}: 16 | - ${{ if ne(parameters.legacyCredential, '') }}: 17 | - task: PowerShell@2 18 | displayName: Setup Internal Feeds 19 | inputs: 20 | filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 21 | arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token 22 | env: 23 | Token: ${{ parameters.legacyCredential }} 24 | # If running on dnceng (internal project), just use the default behavior for NuGetAuthenticate. 25 | # If running on DevDiv, NuGetAuthenticate is not really an option. It's scoped to a single feed, and we have many feeds that 26 | # may be added. Instead, we'll use the traditional approach (add cred to nuget.config), but use an account token. 27 | - ${{ else }}: 28 | - ${{ if eq(variables['System.TeamProject'], 'internal') }}: 29 | - task: PowerShell@2 30 | displayName: Setup Internal Feeds 31 | inputs: 32 | filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 33 | arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config 34 | - ${{ else }}: 35 | - template: /eng/common/templates/steps/get-federated-access-token.yml 36 | parameters: 37 | federatedServiceConnection: ${{ parameters.nugetFederatedServiceConnection }} 38 | outputVariableName: 'dnceng-artifacts-feeds-read-access-token' 39 | - task: PowerShell@2 40 | displayName: Setup Internal Feeds 41 | inputs: 42 | filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 43 | arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $(dnceng-artifacts-feeds-read-access-token) 44 | # This is required in certain scenarios to install the ADO credential provider. 45 | # It installed by default in some msbuild invocations (e.g. VS msbuild), but needs to be installed for others 46 | # (e.g. dotnet msbuild). 47 | - task: NuGetAuthenticate@1 48 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/generate-sbom.yml: -------------------------------------------------------------------------------- 1 | # BuildDropPath - The root folder of the drop directory for which the manifest file will be generated. 2 | # PackageName - The name of the package this SBOM represents. 3 | # PackageVersion - The version of the package this SBOM represents. 4 | # ManifestDirPath - The path of the directory where the generated manifest files will be placed 5 | # IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector. 6 | 7 | parameters: 8 | PackageVersion: 9.0.0 9 | BuildDropPath: '$(Build.SourcesDirectory)/artifacts' 10 | PackageName: '.NET' 11 | ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom 12 | IgnoreDirectories: '' 13 | sbomContinueOnError: true 14 | is1ESPipeline: false 15 | # disable publishArtifacts if some other step is publishing the artifacts (like job.yml). 16 | publishArtifacts: true 17 | 18 | steps: 19 | - task: PowerShell@2 20 | displayName: Prep for SBOM generation in (Non-linux) 21 | condition: or(eq(variables['Agent.Os'], 'Windows_NT'), eq(variables['Agent.Os'], 'Darwin')) 22 | inputs: 23 | filePath: ./eng/common/generate-sbom-prep.ps1 24 | arguments: ${{parameters.manifestDirPath}} 25 | 26 | # Chmodding is a workaround for https://github.com/dotnet/arcade/issues/8461 27 | - script: | 28 | chmod +x ./eng/common/generate-sbom-prep.sh 29 | ./eng/common/generate-sbom-prep.sh ${{parameters.manifestDirPath}} 30 | displayName: Prep for SBOM generation in (Linux) 31 | condition: eq(variables['Agent.Os'], 'Linux') 32 | continueOnError: ${{ parameters.sbomContinueOnError }} 33 | 34 | - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 35 | displayName: 'Generate SBOM manifest' 36 | continueOnError: ${{ parameters.sbomContinueOnError }} 37 | inputs: 38 | PackageName: ${{ parameters.packageName }} 39 | BuildDropPath: ${{ parameters.buildDropPath }} 40 | PackageVersion: ${{ parameters.packageVersion }} 41 | ManifestDirPath: ${{ parameters.manifestDirPath }} 42 | ${{ if ne(parameters.IgnoreDirectories, '') }}: 43 | AdditionalComponentDetectorArgs: '--IgnoreDirectories ${{ parameters.IgnoreDirectories }}' 44 | 45 | - ${{ if eq(parameters.publishArtifacts, 'true')}}: 46 | - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml 47 | parameters: 48 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 49 | args: 50 | displayName: Publish SBOM manifest 51 | continueOnError: ${{parameters.sbomContinueOnError}} 52 | targetPath: '${{ parameters.manifestDirPath }}' 53 | artifactName: $(ARTIFACT_NAME) 54 | 55 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/get-delegation-sas.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: federatedServiceConnection 3 | type: string 4 | - name: outputVariableName 5 | type: string 6 | - name: expiryInHours 7 | type: number 8 | default: 1 9 | - name: base64Encode 10 | type: boolean 11 | default: false 12 | - name: storageAccount 13 | type: string 14 | - name: container 15 | type: string 16 | - name: permissions 17 | type: string 18 | default: 'rl' 19 | - name: is1ESPipeline 20 | type: boolean 21 | default: false 22 | 23 | steps: 24 | - task: AzureCLI@2 25 | displayName: 'Generate delegation SAS Token for ${{ parameters.storageAccount }}/${{ parameters.container }}' 26 | inputs: 27 | azureSubscription: ${{ parameters.federatedServiceConnection }} 28 | scriptType: 'pscore' 29 | scriptLocation: 'inlineScript' 30 | inlineScript: | 31 | # Calculate the expiration of the SAS token and convert to UTC 32 | $expiry = (Get-Date).AddHours(${{ parameters.expiryInHours }}).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") 33 | 34 | $sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv 35 | 36 | if ($LASTEXITCODE -ne 0) { 37 | Write-Error "Failed to generate SAS token." 38 | exit 1 39 | } 40 | 41 | if ('${{ parameters.base64Encode }}' -eq 'true') { 42 | $sas = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($sas)) 43 | } 44 | 45 | Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value" 46 | Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true]$sas" 47 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: federatedServiceConnection 3 | type: string 4 | - name: outputVariableName 5 | type: string 6 | - name: is1ESPipeline 7 | type: boolean 8 | - name: stepName 9 | type: string 10 | default: 'getFederatedAccessToken' 11 | - name: condition 12 | type: string 13 | default: '' 14 | # Resource to get a token for. Common values include: 15 | # - '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps 16 | # - 'https://storage.azure.com/' for storage 17 | # Defaults to Azure DevOps 18 | - name: resource 19 | type: string 20 | default: '499b84ac-1321-427f-aa17-267ca6975798' 21 | - name: isStepOutputVariable 22 | type: boolean 23 | default: false 24 | 25 | steps: 26 | - task: AzureCLI@2 27 | displayName: 'Getting federated access token for feeds' 28 | name: ${{ parameters.stepName }} 29 | ${{ if ne(parameters.condition, '') }}: 30 | condition: ${{ parameters.condition }} 31 | inputs: 32 | azureSubscription: ${{ parameters.federatedServiceConnection }} 33 | scriptType: 'pscore' 34 | scriptLocation: 'inlineScript' 35 | inlineScript: | 36 | $accessToken = az account get-access-token --query accessToken --resource ${{ parameters.resource }} --output tsv 37 | if ($LASTEXITCODE -ne 0) { 38 | Write-Error "Failed to get access token for resource '${{ parameters.resource }}'" 39 | exit 1 40 | } 41 | Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value" 42 | Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true;isOutput=${{ parameters.isStepOutputVariable }}]$accessToken" -------------------------------------------------------------------------------- /eng/common/core-templates/steps/publish-build-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | - name: args 6 | type: object 7 | default: {} 8 | steps: 9 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 10 | - template: /eng/common/templates/steps/publish-build-artifacts.yml 11 | parameters: 12 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 13 | ${{ each parameter in parameters.args }}: 14 | ${{ parameter.key }}: ${{ parameter.value }} 15 | - ${{ else }}: 16 | - template: /eng/common/templates-official/steps/publish-build-artifacts.yml 17 | parameters: 18 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 19 | ${{ each parameter in parameters.args }}: 20 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/core-templates/steps/publish-logs.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | StageLabel: '' 3 | JobLabel: '' 4 | CustomSensitiveDataList: '' 5 | # A default - in case value from eng/common/core-templates/post-build/common-variables.yml is not passed 6 | BinlogToolVersion: '1.0.11' 7 | is1ESPipeline: false 8 | 9 | steps: 10 | - task: Powershell@2 11 | displayName: Prepare Binlogs to Upload 12 | inputs: 13 | targetType: inline 14 | script: | 15 | New-Item -ItemType Directory $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ 16 | Move-Item -Path $(Build.SourcesDirectory)/artifacts/log/Debug/* $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ 17 | continueOnError: true 18 | condition: always() 19 | 20 | - task: PowerShell@2 21 | displayName: Redact Logs 22 | inputs: 23 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/redact-logs.ps1 24 | # For now this needs to have explicit list of all sensitive data. Taken from eng/publishing/v3/publish.yml 25 | # Sensitive data can as well be added to $(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt' 26 | # If the file exists - sensitive data for redaction will be sourced from it 27 | # (single entry per line, lines starting with '# ' are considered comments and skipped) 28 | arguments: -InputPath '$(Build.SourcesDirectory)/PostBuildLogs' 29 | -BinlogToolVersion ${{parameters.BinlogToolVersion}} 30 | -TokensFilePath '$(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt' 31 | '$(publishing-dnceng-devdiv-code-r-build-re)' 32 | '$(MaestroAccessToken)' 33 | '$(dn-bot-all-orgs-artifact-feeds-rw)' 34 | '$(akams-client-id)' 35 | '$(microsoft-symbol-server-pat)' 36 | '$(symweb-symbol-server-pat)' 37 | '$(dnceng-symbol-server-pat)' 38 | '$(dn-bot-all-orgs-build-rw-code-rw)' 39 | '$(System.AccessToken)' 40 | ${{parameters.CustomSensitiveDataList}} 41 | continueOnError: true 42 | condition: always() 43 | 44 | - task: CopyFiles@2 45 | displayName: Gather post build logs 46 | inputs: 47 | SourceFolder: '$(Build.SourcesDirectory)/PostBuildLogs' 48 | Contents: '**' 49 | TargetFolder: '$(Build.ArtifactStagingDirectory)/PostBuildLogs' 50 | condition: always() 51 | 52 | - template: /eng/common/core-templates/steps/publish-build-artifacts.yml 53 | parameters: 54 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 55 | args: 56 | displayName: Publish Logs 57 | pathToPublish: '$(Build.ArtifactStagingDirectory)/PostBuildLogs' 58 | publishLocation: Container 59 | artifactName: PostBuildLogs 60 | continueOnError: true 61 | condition: always() 62 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/publish-pipeline-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | 6 | - name: args 7 | type: object 8 | default: {} 9 | 10 | steps: 11 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 12 | - template: /eng/common/templates/steps/publish-pipeline-artifacts.yml 13 | parameters: 14 | ${{ each parameter in parameters }}: 15 | ${{ parameter.key }}: ${{ parameter.value }} 16 | - ${{ else }}: 17 | - template: /eng/common/templates-official/steps/publish-pipeline-artifacts.yml 18 | parameters: 19 | ${{ each parameter in parameters }}: 20 | ${{ parameter.key }}: ${{ parameter.value }} 21 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/retain-build.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # Optional azure devops PAT with build execute permissions for the build's organization, 3 | # only needed if the build that should be retained ran on a different organization than 4 | # the pipeline where this template is executing from 5 | Token: '' 6 | # Optional BuildId to retain, defaults to the current running build 7 | BuildId: '' 8 | # Azure devops Organization URI for the build in the https://dev.azure.com/ format. 9 | # Defaults to the organization the current pipeline is running on 10 | AzdoOrgUri: '$(System.CollectionUri)' 11 | # Azure devops project for the build. Defaults to the project the current pipeline is running on 12 | AzdoProject: '$(System.TeamProject)' 13 | 14 | steps: 15 | - task: powershell@2 16 | inputs: 17 | targetType: 'filePath' 18 | filePath: eng/common/retain-build.ps1 19 | pwsh: true 20 | arguments: > 21 | -AzdoOrgUri: ${{parameters.AzdoOrgUri}} 22 | -AzdoProject ${{parameters.AzdoProject}} 23 | -Token ${{coalesce(parameters.Token, '$env:SYSTEM_ACCESSTOKEN') }} 24 | -BuildId ${{coalesce(parameters.BuildId, '$env:BUILD_ID')}} 25 | displayName: Enable permanent build retention 26 | env: 27 | SYSTEM_ACCESSTOKEN: $(System.AccessToken) 28 | BUILD_ID: $(Build.BuildId) -------------------------------------------------------------------------------- /eng/common/core-templates/steps/source-index-stage1-publish.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | sourceIndexUploadPackageVersion: 2.0.0-20240522.1 3 | sourceIndexProcessBinlogPackageVersion: 1.0.1-20240522.1 4 | sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json 5 | binlogPath: artifacts/log/Debug/Build.binlog 6 | 7 | steps: 8 | - task: UseDotNet@2 9 | displayName: "Source Index: Use .NET 8 SDK" 10 | inputs: 11 | packageType: sdk 12 | version: 8.0.x 13 | installationPath: $(Agent.TempDirectory)/dotnet 14 | workingDirectory: $(Agent.TempDirectory) 15 | 16 | - script: | 17 | $(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version ${{parameters.sourceIndexProcessBinlogPackageVersion}} --add-source ${{parameters.SourceIndexPackageSource}} --tool-path $(Agent.TempDirectory)/.source-index/tools 18 | $(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version ${{parameters.sourceIndexUploadPackageVersion}} --add-source ${{parameters.SourceIndexPackageSource}} --tool-path $(Agent.TempDirectory)/.source-index/tools 19 | displayName: "Source Index: Download netsourceindex Tools" 20 | # Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk. 21 | workingDirectory: $(Agent.TempDirectory) 22 | 23 | - script: $(Agent.TempDirectory)/.source-index/tools/BinLogToSln -i ${{parameters.BinlogPath}} -r $(Build.SourcesDirectory) -n $(Build.Repository.Name) -o .source-index/stage1output 24 | displayName: "Source Index: Process Binlog into indexable sln" 25 | 26 | - ${{ if and(ne(parameters.runAsPublic, 'true'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: 27 | - task: AzureCLI@2 28 | displayName: "Source Index: Upload Source Index stage1 artifacts to Azure" 29 | inputs: 30 | azureSubscription: 'SourceDotNet Stage1 Publish' 31 | addSpnToEnvironment: true 32 | scriptType: 'ps' 33 | scriptLocation: 'inlineScript' 34 | inlineScript: | 35 | $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name) -s netsourceindexstage1 -b stage1 36 | -------------------------------------------------------------------------------- /eng/common/core-templates/variables/pool-providers.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | is1ESPipeline: false 3 | 4 | variables: 5 | - ${{ if eq(parameters.is1ESPipeline, 'true') }}: 6 | - template: /eng/common/templates-official/variables/pool-providers.yml 7 | - ${{ else }}: 8 | - template: /eng/common/templates/variables/pool-providers.yml -------------------------------------------------------------------------------- /eng/common/cross/arm/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf32-littlearm) 8 | -GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-armhf.so.3 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-armhf.so.3 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf64-littleaarch64) 8 | -GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-aarch64.so.1 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-aarch64.so.1 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/armel/armel.jessie.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/include/urcu/uatomic/generic.h b/usr/include/urcu/uatomic/generic.h 2 | --- a/usr/include/urcu/uatomic/generic.h 2014-10-22 15:00:58.000000000 -0700 3 | +++ b/usr/include/urcu/uatomic/generic.h 2020-10-30 21:38:28.550000000 -0700 4 | @@ -69,10 +69,10 @@ 5 | #endif 6 | #ifdef UATOMIC_HAS_ATOMIC_SHORT 7 | case 2: 8 | - return __sync_val_compare_and_swap_2(addr, old, _new); 9 | + return __sync_val_compare_and_swap_2((uint16_t*) addr, old, _new); 10 | #endif 11 | case 4: 12 | - return __sync_val_compare_and_swap_4(addr, old, _new); 13 | + return __sync_val_compare_and_swap_4((uint32_t*) addr, old, _new); 14 | #if (CAA_BITS_PER_LONG == 64) 15 | case 8: 16 | return __sync_val_compare_and_swap_8(addr, old, _new); 17 | @@ -109,7 +109,7 @@ 18 | return; 19 | #endif 20 | case 4: 21 | - __sync_and_and_fetch_4(addr, val); 22 | + __sync_and_and_fetch_4((uint32_t*) addr, val); 23 | return; 24 | #if (CAA_BITS_PER_LONG == 64) 25 | case 8: 26 | @@ -148,7 +148,7 @@ 27 | return; 28 | #endif 29 | case 4: 30 | - __sync_or_and_fetch_4(addr, val); 31 | + __sync_or_and_fetch_4((uint32_t*) addr, val); 32 | return; 33 | #if (CAA_BITS_PER_LONG == 64) 34 | case 8: 35 | @@ -187,7 +187,7 @@ 36 | return __sync_add_and_fetch_2(addr, val); 37 | #endif 38 | case 4: 39 | - return __sync_add_and_fetch_4(addr, val); 40 | + return __sync_add_and_fetch_4((uint32_t*) addr, val); 41 | #if (CAA_BITS_PER_LONG == 64) 42 | case 8: 43 | return __sync_add_and_fetch_8(addr, val); 44 | -------------------------------------------------------------------------------- /eng/common/cross/armel/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf32-littlearm) 8 | -GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.3 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.3 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/riscv64/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf64-littleriscv) 8 | -GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-riscv64-lp64d.so.1 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-riscv64-lp64d.so.1 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/tizen-build-rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | ARCH=$1 5 | LINK_ARCH=$ARCH 6 | 7 | case "$ARCH" in 8 | arm) 9 | TIZEN_ARCH="armv7hl" 10 | ;; 11 | armel) 12 | TIZEN_ARCH="armv7l" 13 | LINK_ARCH="arm" 14 | ;; 15 | arm64) 16 | TIZEN_ARCH="aarch64" 17 | ;; 18 | x86) 19 | TIZEN_ARCH="i686" 20 | ;; 21 | x64) 22 | TIZEN_ARCH="x86_64" 23 | LINK_ARCH="x86" 24 | ;; 25 | riscv64) 26 | TIZEN_ARCH="riscv64" 27 | LINK_ARCH="riscv" 28 | ;; 29 | *) 30 | echo "Unsupported architecture for tizen: $ARCH" 31 | exit 1 32 | esac 33 | 34 | __CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 35 | __TIZEN_CROSSDIR="$__CrossDir/${ARCH}/tizen" 36 | 37 | if [[ -z "$ROOTFS_DIR" ]]; then 38 | echo "ROOTFS_DIR is not defined." 39 | exit 1; 40 | fi 41 | 42 | TIZEN_TMP_DIR=$ROOTFS_DIR/tizen_tmp 43 | mkdir -p $TIZEN_TMP_DIR 44 | 45 | # Download files 46 | echo ">>Start downloading files" 47 | VERBOSE=1 $__CrossDir/tizen-fetch.sh $TIZEN_TMP_DIR $TIZEN_ARCH 48 | echo "<>Start constructing Tizen rootfs" 51 | TIZEN_RPM_FILES=`ls $TIZEN_TMP_DIR/*.rpm` 52 | cd $ROOTFS_DIR 53 | for f in $TIZEN_RPM_FILES; do 54 | rpm2cpio $f | cpio -idm --quiet 55 | done 56 | echo "<>Start configuring Tizen rootfs" 63 | ln -sfn asm-${LINK_ARCH} ./usr/include/asm 64 | patch -p1 < $__TIZEN_CROSSDIR/tizen.patch 65 | if [[ "$TIZEN_ARCH" == "riscv64" ]]; then 66 | echo "Fixing broken symlinks in $PWD" 67 | rm ./usr/lib64/libresolv.so 68 | ln -s ../../lib64/libresolv.so.2 ./usr/lib64/libresolv.so 69 | rm ./usr/lib64/libpthread.so 70 | ln -s ../../lib64/libpthread.so.0 ./usr/lib64/libpthread.so 71 | rm ./usr/lib64/libdl.so 72 | ln -s ../../lib64/libdl.so.2 ./usr/lib64/libdl.so 73 | rm ./usr/lib64/libutil.so 74 | ln -s ../../lib64/libutil.so.1 ./usr/lib64/libutil.so 75 | rm ./usr/lib64/libm.so 76 | ln -s ../../lib64/libm.so.6 ./usr/lib64/libm.so 77 | rm ./usr/lib64/librt.so 78 | ln -s ../../lib64/librt.so.1 ./usr/lib64/librt.so 79 | rm ./lib/ld-linux-riscv64-lp64d.so.1 80 | ln -s ../lib64/ld-linux-riscv64-lp64d.so.1 ./lib/ld-linux-riscv64-lp64d.so.1 81 | fi 82 | echo "< 0 ]]; do 9 | opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")" 10 | case "$opt" in 11 | --darcversion) 12 | darcVersion=$2 13 | shift 14 | ;; 15 | --versionendpoint) 16 | versionEndpoint=$2 17 | shift 18 | ;; 19 | --verbosity) 20 | verbosity=$2 21 | shift 22 | ;; 23 | --toolpath) 24 | toolpath=$2 25 | shift 26 | ;; 27 | *) 28 | echo "Invalid argument: $1" 29 | usage 30 | exit 1 31 | ;; 32 | esac 33 | 34 | shift 35 | done 36 | 37 | # resolve $source until the file is no longer a symlink 38 | while [[ -h "$source" ]]; do 39 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 40 | source="$(readlink "$source")" 41 | # if $source was a relative symlink, we need to resolve it relative to the path where the 42 | # symlink file was located 43 | [[ $source != /* ]] && source="$scriptroot/$source" 44 | done 45 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 46 | 47 | . "$scriptroot/tools.sh" 48 | 49 | if [ -z "$darcVersion" ]; then 50 | darcVersion=$(curl -X GET "$versionEndpoint" -H "accept: text/plain") 51 | fi 52 | 53 | function InstallDarcCli { 54 | local darc_cli_package_name="microsoft.dotnet.darc" 55 | 56 | InitializeDotNetCli true 57 | local dotnet_root=$_InitializeDotNetCli 58 | 59 | if [ -z "$toolpath" ]; then 60 | local tool_list=$($dotnet_root/dotnet tool list -g) 61 | if [[ $tool_list = *$darc_cli_package_name* ]]; then 62 | echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name -g) 63 | fi 64 | else 65 | local tool_list=$($dotnet_root/dotnet tool list --tool-path "$toolpath") 66 | if [[ $tool_list = *$darc_cli_package_name* ]]; then 67 | echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name --tool-path "$toolpath") 68 | fi 69 | fi 70 | 71 | local arcadeServicesSource="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" 72 | 73 | echo "Installing Darc CLI version $darcVersion..." 74 | echo "You may need to restart your command shell if this is the first dotnet tool you have installed." 75 | if [ -z "$toolpath" ]; then 76 | echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g) 77 | else 78 | echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath") 79 | fi 80 | } 81 | 82 | InstallDarcCli 83 | -------------------------------------------------------------------------------- /eng/common/dotnet-install.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0dotnet-install.ps1""" %*" -------------------------------------------------------------------------------- /eng/common/dotnet-install.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding(PositionalBinding=$false)] 2 | Param( 3 | [string] $verbosity = 'minimal', 4 | [string] $architecture = '', 5 | [string] $version = 'Latest', 6 | [string] $runtime = 'dotnet', 7 | [string] $RuntimeSourceFeed = '', 8 | [string] $RuntimeSourceFeedKey = '' 9 | ) 10 | 11 | . $PSScriptRoot\tools.ps1 12 | 13 | $dotnetRoot = Join-Path $RepoRoot '.dotnet' 14 | 15 | $installdir = $dotnetRoot 16 | try { 17 | if ($architecture -and $architecture.Trim() -eq 'x86') { 18 | $installdir = Join-Path $installdir 'x86' 19 | } 20 | InstallDotNet $installdir $version $architecture $runtime $true -RuntimeSourceFeed $RuntimeSourceFeed -RuntimeSourceFeedKey $RuntimeSourceFeedKey 21 | } 22 | catch { 23 | Write-Host $_.ScriptStackTrace 24 | Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ 25 | ExitWithExitCode 1 26 | } 27 | 28 | ExitWithExitCode 0 29 | -------------------------------------------------------------------------------- /eng/common/dotnet-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | # resolve $source until the file is no longer a symlink 5 | while [[ -h "$source" ]]; do 6 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 7 | source="$(readlink "$source")" 8 | # if $source was a relative symlink, we need to resolve it relative to the path where the 9 | # symlink file was located 10 | [[ $source != /* ]] && source="$scriptroot/$source" 11 | done 12 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 13 | 14 | . "$scriptroot/tools.sh" 15 | 16 | version='Latest' 17 | architecture='' 18 | runtime='dotnet' 19 | runtimeSourceFeed='' 20 | runtimeSourceFeedKey='' 21 | while [[ $# > 0 ]]; do 22 | opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")" 23 | case "$opt" in 24 | -version|-v) 25 | shift 26 | version="$1" 27 | ;; 28 | -architecture|-a) 29 | shift 30 | architecture="$1" 31 | ;; 32 | -runtime|-r) 33 | shift 34 | runtime="$1" 35 | ;; 36 | -runtimesourcefeed) 37 | shift 38 | runtimeSourceFeed="$1" 39 | ;; 40 | -runtimesourcefeedkey) 41 | shift 42 | runtimeSourceFeedKey="$1" 43 | ;; 44 | *) 45 | Write-PipelineTelemetryError -Category 'Build' -Message "Invalid argument: $1" 46 | exit 1 47 | ;; 48 | esac 49 | shift 50 | done 51 | 52 | # Use uname to determine what the CPU is, see https://en.wikipedia.org/wiki/Uname#Examples 53 | cpuname=$(uname -m) 54 | case $cpuname in 55 | arm64|aarch64) 56 | buildarch=arm64 57 | if [ "$(getconf LONG_BIT)" -lt 64 ]; then 58 | # This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS) 59 | buildarch=arm 60 | fi 61 | ;; 62 | loongarch64) 63 | buildarch=loongarch64 64 | ;; 65 | amd64|x86_64) 66 | buildarch=x64 67 | ;; 68 | armv*l) 69 | buildarch=arm 70 | ;; 71 | i[3-6]86) 72 | buildarch=x86 73 | ;; 74 | riscv64) 75 | buildarch=riscv64 76 | ;; 77 | *) 78 | echo "Unknown CPU $cpuname detected, treating it as x64" 79 | buildarch=x64 80 | ;; 81 | esac 82 | 83 | dotnetRoot="${repo_root}.dotnet" 84 | if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then 85 | dotnetRoot="$dotnetRoot/$architecture" 86 | fi 87 | 88 | InstallDotNet "$dotnetRoot" $version "$architecture" $runtime true $runtimeSourceFeed $runtimeSourceFeedKey || { 89 | local exit_code=$? 90 | Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2 91 | ExitWithExitCode $exit_code 92 | } 93 | 94 | ExitWithExitCode 0 95 | -------------------------------------------------------------------------------- /eng/common/enable-cross-org-publishing.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [string] $token 3 | ) 4 | 5 | 6 | . $PSScriptRoot\pipeline-logging-functions.ps1 7 | 8 | # Write-PipelineSetVariable will no-op if a variable named $ci is not defined 9 | # Since this script is only ever called in AzDO builds, just universally set it 10 | $ci = $true 11 | 12 | Write-PipelineSetVariable -Name 'VSS_NUGET_ACCESSTOKEN' -Value $token -IsMultiJobVariable $false 13 | Write-PipelineSetVariable -Name 'VSS_NUGET_URI_PREFIXES' -Value 'https://dnceng.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/dnceng/;https://devdiv.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/devdiv/' -IsMultiJobVariable $false 14 | -------------------------------------------------------------------------------- /eng/common/generate-sbom-prep.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [Parameter(Mandatory=$true)][string] $ManifestDirPath # Manifest directory where sbom will be placed 3 | ) 4 | 5 | . $PSScriptRoot\pipeline-logging-functions.ps1 6 | 7 | Write-Host "Creating dir $ManifestDirPath" 8 | # create directory for sbom manifest to be placed 9 | if (!(Test-Path -path $ManifestDirPath)) 10 | { 11 | New-Item -ItemType Directory -path $ManifestDirPath 12 | Write-Host "Successfully created directory $ManifestDirPath" 13 | } 14 | else{ 15 | Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." 16 | } 17 | 18 | Write-Host "Updating artifact name" 19 | $artifact_name = "${env:SYSTEM_STAGENAME}_${env:AGENT_JOBNAME}_SBOM" -replace '["/:<>\\|?@*"() ]', '_' 20 | Write-Host "Artifact name $artifact_name" 21 | Write-Host "##vso[task.setvariable variable=ARTIFACT_NAME]$artifact_name" 22 | -------------------------------------------------------------------------------- /eng/common/generate-sbom-prep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where the 11 | # symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 15 | . $scriptroot/pipeline-logging-functions.sh 16 | 17 | manifest_dir=$1 18 | 19 | if [ ! -d "$manifest_dir" ] ; then 20 | mkdir -p "$manifest_dir" 21 | echo "Sbom directory created." $manifest_dir 22 | else 23 | Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." 24 | fi 25 | 26 | artifact_name=$SYSTEM_STAGENAME"_"$AGENT_JOBNAME"_SBOM" 27 | echo "Artifact name before : "$artifact_name 28 | # replace all special characters with _, some builds use special characters like : in Agent.Jobname, that is not a permissible name while uploading artifacts. 29 | safe_artifact_name="${artifact_name//["/:<>\\|?@*$" ]/_}" 30 | echo "Artifact name after : "$safe_artifact_name 31 | export ARTIFACT_NAME=$safe_artifact_name 32 | echo "##vso[task.setvariable variable=ARTIFACT_NAME]$safe_artifact_name" 33 | 34 | exit 0 35 | -------------------------------------------------------------------------------- /eng/common/helixpublish.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | msbuild 6 | 7 | 8 | 9 | 10 | %(Identity) 11 | 12 | 13 | 14 | 15 | 16 | $(WorkItemDirectory) 17 | $(WorkItemCommand) 18 | $(WorkItemTimeout) 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /eng/common/init-tools-native.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -NoProfile -NoLogo -ExecutionPolicy ByPass -command "& """%~dp0init-tools-native.ps1""" %*" 3 | exit /b %ErrorLevel% -------------------------------------------------------------------------------- /eng/common/internal/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | false 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /eng/common/internal/NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /eng/common/internal/Tools.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | net472 6 | false 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /eng/common/loc/P22DotNetHtmlLocalization.lss: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /eng/common/msbuild.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding(PositionalBinding=$false)] 2 | Param( 3 | [string] $verbosity = 'minimal', 4 | [bool] $warnAsError = $true, 5 | [bool] $nodeReuse = $true, 6 | [switch] $ci, 7 | [switch] $prepareMachine, 8 | [switch] $excludePrereleaseVS, 9 | [string] $msbuildEngine = $null, 10 | [Parameter(ValueFromRemainingArguments=$true)][String[]]$extraArgs 11 | ) 12 | 13 | . $PSScriptRoot\tools.ps1 14 | 15 | try { 16 | if ($ci) { 17 | $nodeReuse = $false 18 | } 19 | 20 | MSBuild @extraArgs 21 | } 22 | catch { 23 | Write-Host $_.ScriptStackTrace 24 | Write-PipelineTelemetryError -Category 'Build' -Message $_ 25 | ExitWithExitCode 1 26 | } 27 | 28 | ExitWithExitCode 0 -------------------------------------------------------------------------------- /eng/common/msbuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $source until the file is no longer a symlink 6 | while [[ -h "$source" ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | # if $source was a relative symlink, we need to resolve it relative to the path where the 10 | # symlink file was located 11 | [[ $source != /* ]] && source="$scriptroot/$source" 12 | done 13 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 14 | 15 | verbosity='minimal' 16 | warn_as_error=true 17 | node_reuse=true 18 | prepare_machine=false 19 | extra_args='' 20 | 21 | while (($# > 0)); do 22 | lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" 23 | case $lowerI in 24 | --verbosity) 25 | verbosity=$2 26 | shift 2 27 | ;; 28 | --warnaserror) 29 | warn_as_error=$2 30 | shift 2 31 | ;; 32 | --nodereuse) 33 | node_reuse=$2 34 | shift 2 35 | ;; 36 | --ci) 37 | ci=true 38 | shift 1 39 | ;; 40 | --preparemachine) 41 | prepare_machine=true 42 | shift 1 43 | ;; 44 | *) 45 | extra_args="$extra_args $1" 46 | shift 1 47 | ;; 48 | esac 49 | done 50 | 51 | . "$scriptroot/tools.sh" 52 | 53 | if [[ "$ci" == true ]]; then 54 | node_reuse=false 55 | fi 56 | 57 | MSBuild $extra_args 58 | ExitWithExitCode 0 59 | -------------------------------------------------------------------------------- /eng/common/native/init-os-and-arch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Use uname to determine what the OS is. 4 | OSName=$(uname -s | tr '[:upper:]' '[:lower:]') 5 | 6 | if command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then 7 | OSName="android" 8 | fi 9 | 10 | case "$OSName" in 11 | freebsd|linux|netbsd|openbsd|sunos|android|haiku) 12 | os="$OSName" ;; 13 | darwin) 14 | os=osx ;; 15 | *) 16 | echo "Unsupported OS $OSName detected!" 17 | exit 1 ;; 18 | esac 19 | 20 | # On Solaris, `uname -m` is discouraged, see https://docs.oracle.com/cd/E36784_01/html/E36870/uname-1.html 21 | # and `uname -p` returns processor type (e.g. i386 on amd64). 22 | # The appropriate tool to determine CPU is isainfo(1) https://docs.oracle.com/cd/E36784_01/html/E36870/isainfo-1.html. 23 | if [ "$os" = "sunos" ]; then 24 | if uname -o 2>&1 | grep -q illumos; then 25 | os="illumos" 26 | else 27 | os="solaris" 28 | fi 29 | CPUName=$(isainfo -n) 30 | else 31 | # For the rest of the operating systems, use uname(1) to determine what the CPU is. 32 | CPUName=$(uname -m) 33 | fi 34 | 35 | case "$CPUName" in 36 | arm64|aarch64) 37 | arch=arm64 38 | if [ "$(getconf LONG_BIT)" -lt 64 ]; then 39 | # This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS) 40 | arch=arm 41 | fi 42 | ;; 43 | 44 | loongarch64) 45 | arch=loongarch64 46 | ;; 47 | 48 | riscv64) 49 | arch=riscv64 50 | ;; 51 | 52 | amd64|x86_64) 53 | arch=x64 54 | ;; 55 | 56 | armv7l|armv8l) 57 | # shellcheck disable=SC1091 58 | if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then 59 | arch=armel 60 | else 61 | arch=arm 62 | fi 63 | ;; 64 | 65 | armv6l) 66 | arch=armv6 67 | ;; 68 | 69 | i[3-6]86) 70 | echo "Unsupported CPU $CPUName detected, build might not succeed!" 71 | arch=x86 72 | ;; 73 | 74 | s390x) 75 | arch=s390x 76 | ;; 77 | 78 | ppc64le) 79 | arch=ppc64le 80 | ;; 81 | *) 82 | echo "Unknown CPU $CPUName detected!" 83 | exit 1 84 | ;; 85 | esac 86 | -------------------------------------------------------------------------------- /eng/common/native/install-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # This is a simple script primarily used for CI to install necessary dependencies 6 | # 7 | # Usage: 8 | # 9 | # ./install-dependencies.sh 10 | 11 | os="$(echo "$1" | tr "[:upper:]" "[:lower:]")" 12 | 13 | if [ -z "$os" ]; then 14 | . "$(dirname "$0")"/init-os-and-arch.sh 15 | fi 16 | 17 | case "$os" in 18 | linux) 19 | if [ -e /etc/os-release ]; then 20 | . /etc/os-release 21 | fi 22 | 23 | if [ "$ID" = "debian" ] || [ "$ID_LIKE" = "debian" ]; then 24 | apt update 25 | 26 | apt install -y build-essential gettext locales cmake llvm clang lld lldb liblldb-dev libunwind8-dev libicu-dev liblttng-ust-dev \ 27 | libssl-dev libkrb5-dev pigz cpio 28 | 29 | localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 30 | elif [ "$ID" = "fedora" ] || [ "$ID" = "rhel" ]; then 31 | dnf install -y cmake llvm lld lldb clang python curl libicu-devel openssl-devel krb5-devel lttng-ust-devel pigz cpio 32 | elif [ "$ID" = "alpine" ]; then 33 | apk add build-base cmake bash curl clang llvm-dev lld lldb krb5-dev lttng-ust-dev icu-dev openssl-dev pigz cpio 34 | else 35 | echo "Unsupported distro. distro: $ID" 36 | exit 1 37 | fi 38 | ;; 39 | 40 | osx|maccatalyst|ios|iossimulator|tvos|tvossimulator) 41 | echo "Installed xcode version: $(xcode-select -p)" 42 | 43 | export HOMEBREW_NO_INSTALL_CLEANUP=1 44 | export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 45 | # Skip brew update for now, see https://github.com/actions/setup-python/issues/577 46 | # brew update --preinstall 47 | brew bundle --no-upgrade --no-lock --file=- < 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /eng/common/sdl/extract-artifact-archives.ps1: -------------------------------------------------------------------------------- 1 | # This script looks for each archive file in a directory and extracts it into the target directory. 2 | # For example, the file "$InputPath/bin.tar.gz" extracts to "$ExtractPath/bin.tar.gz.extracted/**". 3 | # Uses the "tar" utility added to Windows 10 / Windows 2019 that supports tar.gz and zip. 4 | param( 5 | # Full path to directory where archives are stored. 6 | [Parameter(Mandatory=$true)][string] $InputPath, 7 | # Full path to directory to extract archives into. May be the same as $InputPath. 8 | [Parameter(Mandatory=$true)][string] $ExtractPath 9 | ) 10 | 11 | $ErrorActionPreference = 'Stop' 12 | Set-StrictMode -Version 2.0 13 | 14 | $disableConfigureToolsetImport = $true 15 | 16 | try { 17 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 18 | # scripts don't necessarily execute in the same agent that run the 19 | # build.ps1/sh script this variable isn't automatically set. 20 | $ci = $true 21 | . $PSScriptRoot\..\tools.ps1 22 | 23 | Measure-Command { 24 | $jobs = @() 25 | 26 | # Find archive files for non-Windows and Windows builds. 27 | $archiveFiles = @( 28 | Get-ChildItem (Join-Path $InputPath "*.tar.gz") 29 | Get-ChildItem (Join-Path $InputPath "*.zip") 30 | ) 31 | 32 | foreach ($targzFile in $archiveFiles) { 33 | $jobs += Start-Job -ScriptBlock { 34 | $file = $using:targzFile 35 | $fileName = [System.IO.Path]::GetFileName($file) 36 | $extractDir = Join-Path $using:ExtractPath "$fileName.extracted" 37 | 38 | New-Item $extractDir -ItemType Directory -Force | Out-Null 39 | 40 | Write-Host "Extracting '$file' to '$extractDir'..." 41 | 42 | # Pipe errors to stdout to prevent PowerShell detecting them and quitting the job early. 43 | # This type of quit skips the catch, so we wouldn't be able to tell which file triggered the 44 | # error. Save output so it can be stored in the exception string along with context. 45 | $output = tar -xf $file -C $extractDir 2>&1 46 | # Handle NZEC manually rather than using Exit-IfNZEC: we are in a background job, so we 47 | # don't have access to the outer scope. 48 | if ($LASTEXITCODE -ne 0) { 49 | throw "Error extracting '$file': non-zero exit code ($LASTEXITCODE). Output: '$output'" 50 | } 51 | 52 | Write-Host "Extracted to $extractDir" 53 | } 54 | } 55 | 56 | Receive-Job $jobs -Wait 57 | } 58 | } 59 | catch { 60 | Write-Host $_ 61 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 62 | ExitWithExitCode 1 63 | } 64 | -------------------------------------------------------------------------------- /eng/common/sdl/extract-artifact-packages.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where artifact packages are stored 3 | [Parameter(Mandatory=$true)][string] $ExtractPath # Full path to directory where the packages will be extracted 4 | ) 5 | 6 | $ErrorActionPreference = 'Stop' 7 | Set-StrictMode -Version 2.0 8 | 9 | $disableConfigureToolsetImport = $true 10 | 11 | function ExtractArtifacts { 12 | if (!(Test-Path $InputPath)) { 13 | Write-Host "Input Path does not exist: $InputPath" 14 | ExitWithExitCode 0 15 | } 16 | $Jobs = @() 17 | Get-ChildItem "$InputPath\*.nupkg" | 18 | ForEach-Object { 19 | $Jobs += Start-Job -ScriptBlock $ExtractPackage -ArgumentList $_.FullName 20 | } 21 | 22 | foreach ($Job in $Jobs) { 23 | Wait-Job -Id $Job.Id | Receive-Job 24 | } 25 | } 26 | 27 | try { 28 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 29 | # scripts don't necessarily execute in the same agent that run the 30 | # build.ps1/sh script this variable isn't automatically set. 31 | $ci = $true 32 | . $PSScriptRoot\..\tools.ps1 33 | 34 | $ExtractPackage = { 35 | param( 36 | [string] $PackagePath # Full path to a NuGet package 37 | ) 38 | 39 | if (!(Test-Path $PackagePath)) { 40 | Write-PipelineTelemetryError -Category 'Build' -Message "Input file does not exist: $PackagePath" 41 | ExitWithExitCode 1 42 | } 43 | 44 | $RelevantExtensions = @('.dll', '.exe', '.pdb') 45 | Write-Host -NoNewLine 'Extracting ' ([System.IO.Path]::GetFileName($PackagePath)) '...' 46 | 47 | $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) 48 | $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageId 49 | 50 | Add-Type -AssemblyName System.IO.Compression.FileSystem 51 | 52 | [System.IO.Directory]::CreateDirectory($ExtractPath); 53 | 54 | try { 55 | $zip = [System.IO.Compression.ZipFile]::OpenRead($PackagePath) 56 | 57 | $zip.Entries | 58 | Where-Object {$RelevantExtensions -contains [System.IO.Path]::GetExtension($_.Name)} | 59 | ForEach-Object { 60 | $TargetPath = Join-Path -Path $ExtractPath -ChildPath (Split-Path -Path $_.FullName) 61 | [System.IO.Directory]::CreateDirectory($TargetPath); 62 | 63 | $TargetFile = Join-Path -Path $ExtractPath -ChildPath $_.FullName 64 | [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile) 65 | } 66 | } 67 | catch { 68 | Write-Host $_ 69 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 70 | ExitWithExitCode 1 71 | } 72 | finally { 73 | $zip.Dispose() 74 | } 75 | } 76 | Measure-Command { ExtractArtifacts } 77 | } 78 | catch { 79 | Write-Host $_ 80 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 81 | ExitWithExitCode 1 82 | } 83 | -------------------------------------------------------------------------------- /eng/common/sdl/init-sdl.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [string] $GuardianCliLocation, 3 | [string] $Repository, 4 | [string] $BranchName='master', 5 | [string] $WorkingDirectory, 6 | [string] $AzureDevOpsAccessToken, 7 | [string] $GuardianLoggerLevel='Standard' 8 | ) 9 | 10 | $ErrorActionPreference = 'Stop' 11 | Set-StrictMode -Version 2.0 12 | $disableConfigureToolsetImport = $true 13 | $global:LASTEXITCODE = 0 14 | 15 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 16 | # scripts don't necessarily execute in the same agent that run the 17 | # build.ps1/sh script this variable isn't automatically set. 18 | $ci = $true 19 | . $PSScriptRoot\..\tools.ps1 20 | 21 | # Don't display the console progress UI - it's a huge perf hit 22 | $ProgressPreference = 'SilentlyContinue' 23 | 24 | # Construct basic auth from AzDO access token; construct URI to the repository's gdn folder stored in that repository; construct location of zip file 25 | $encodedPat = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$AzureDevOpsAccessToken")) 26 | $escapedRepository = [Uri]::EscapeDataString("/$Repository/$BranchName/.gdn") 27 | $uri = "https://dev.azure.com/dnceng/internal/_apis/git/repositories/sdl-tool-cfg/Items?path=$escapedRepository&versionDescriptor[versionOptions]=0&`$format=zip&api-version=5.0" 28 | $zipFile = "$WorkingDirectory/gdn.zip" 29 | 30 | Add-Type -AssemblyName System.IO.Compression.FileSystem 31 | $gdnFolder = (Join-Path $WorkingDirectory '.gdn') 32 | 33 | try { 34 | # if the folder does not exist, we'll do a guardian init and push it to the remote repository 35 | Write-Host 'Initializing Guardian...' 36 | Write-Host "$GuardianCliLocation init --working-directory $WorkingDirectory --logger-level $GuardianLoggerLevel" 37 | & $GuardianCliLocation init --working-directory $WorkingDirectory --logger-level $GuardianLoggerLevel 38 | if ($LASTEXITCODE -ne 0) { 39 | Write-PipelineTelemetryError -Force -Category 'Build' -Message "Guardian init failed with exit code $LASTEXITCODE." 40 | ExitWithExitCode $LASTEXITCODE 41 | } 42 | # We create the mainbaseline so it can be edited later 43 | Write-Host "$GuardianCliLocation baseline --working-directory $WorkingDirectory --name mainbaseline" 44 | & $GuardianCliLocation baseline --working-directory $WorkingDirectory --name mainbaseline 45 | if ($LASTEXITCODE -ne 0) { 46 | Write-PipelineTelemetryError -Force -Category 'Build' -Message "Guardian baseline failed with exit code $LASTEXITCODE." 47 | ExitWithExitCode $LASTEXITCODE 48 | } 49 | ExitWithExitCode 0 50 | } 51 | catch { 52 | Write-Host $_.ScriptStackTrace 53 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 54 | ExitWithExitCode 1 55 | } 56 | -------------------------------------------------------------------------------- /eng/common/sdl/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /eng/common/sdl/run-sdl.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [string] $GuardianCliLocation, 3 | [string] $WorkingDirectory, 4 | [string] $GdnFolder, 5 | [string] $UpdateBaseline, 6 | [string] $GuardianLoggerLevel='Standard' 7 | ) 8 | 9 | $ErrorActionPreference = 'Stop' 10 | Set-StrictMode -Version 2.0 11 | $disableConfigureToolsetImport = $true 12 | $global:LASTEXITCODE = 0 13 | 14 | try { 15 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 16 | # scripts don't necessarily execute in the same agent that run the 17 | # build.ps1/sh script this variable isn't automatically set. 18 | $ci = $true 19 | . $PSScriptRoot\..\tools.ps1 20 | 21 | # We store config files in the r directory of .gdn 22 | $gdnConfigPath = Join-Path $GdnFolder 'r' 23 | $ValidPath = Test-Path $GuardianCliLocation 24 | 25 | if ($ValidPath -eq $False) 26 | { 27 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location." 28 | ExitWithExitCode 1 29 | } 30 | 31 | $gdnConfigFiles = Get-ChildItem $gdnConfigPath -Recurse -Include '*.gdnconfig' 32 | Write-Host "Discovered Guardian config files:" 33 | $gdnConfigFiles | Out-String | Write-Host 34 | 35 | Exec-BlockVerbosely { 36 | & $GuardianCliLocation run ` 37 | --working-directory $WorkingDirectory ` 38 | --baseline mainbaseline ` 39 | --update-baseline $UpdateBaseline ` 40 | --logger-level $GuardianLoggerLevel ` 41 | --config @gdnConfigFiles 42 | Exit-IfNZEC "Sdl" 43 | } 44 | } 45 | catch { 46 | Write-Host $_.ScriptStackTrace 47 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 48 | ExitWithExitCode 1 49 | } 50 | -------------------------------------------------------------------------------- /eng/common/sdl/sdl.ps1: -------------------------------------------------------------------------------- 1 | 2 | function Install-Gdn { 3 | param( 4 | [Parameter(Mandatory=$true)] 5 | [string]$Path, 6 | 7 | # If omitted, install the latest version of Guardian, otherwise install that specific version. 8 | [string]$Version 9 | ) 10 | 11 | $ErrorActionPreference = 'Stop' 12 | Set-StrictMode -Version 2.0 13 | $disableConfigureToolsetImport = $true 14 | $global:LASTEXITCODE = 0 15 | 16 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 17 | # scripts don't necessarily execute in the same agent that run the 18 | # build.ps1/sh script this variable isn't automatically set. 19 | $ci = $true 20 | . $PSScriptRoot\..\tools.ps1 21 | 22 | $argumentList = @("install", "Microsoft.Guardian.Cli", "-Source https://securitytools.pkgs.visualstudio.com/_packaging/Guardian/nuget/v3/index.json", "-OutputDirectory $Path", "-NonInteractive", "-NoCache") 23 | 24 | if ($Version) { 25 | $argumentList += "-Version $Version" 26 | } 27 | 28 | Start-Process nuget -Verbose -ArgumentList $argumentList -NoNewWindow -Wait 29 | 30 | $gdnCliPath = Get-ChildItem -Filter guardian.cmd -Recurse -Path $Path 31 | 32 | if (!$gdnCliPath) 33 | { 34 | Write-PipelineTelemetryError -Category 'Sdl' -Message 'Failure installing Guardian' 35 | } 36 | 37 | return $gdnCliPath.FullName 38 | } -------------------------------------------------------------------------------- /eng/common/sdl/trim-assets-version.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Install and run the 'Microsoft.DotNet.VersionTools.Cli' tool with the 'trim-artifacts-version' command to trim the version from the NuGet assets file name. 4 | 5 | .PARAMETER InputPath 6 | Full path to directory where artifact packages are stored 7 | 8 | .PARAMETER Recursive 9 | Search for NuGet packages recursively 10 | 11 | #> 12 | 13 | Param( 14 | [string] $InputPath, 15 | [bool] $Recursive = $true 16 | ) 17 | 18 | $CliToolName = "Microsoft.DotNet.VersionTools.Cli" 19 | 20 | function Install-VersionTools-Cli { 21 | param( 22 | [Parameter(Mandatory=$true)][string]$Version 23 | ) 24 | 25 | Write-Host "Installing the package '$CliToolName' with a version of '$version' ..." 26 | $feed = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" 27 | 28 | $argumentList = @("tool", "install", "--local", "$CliToolName", "--add-source $feed", "--no-cache", "--version $Version", "--create-manifest-if-needed") 29 | Start-Process "$dotnet" -Verbose -ArgumentList $argumentList -NoNewWindow -Wait 30 | } 31 | 32 | # ------------------------------------------------------------------- 33 | 34 | if (!(Test-Path $InputPath)) { 35 | Write-Host "Input Path '$InputPath' does not exist" 36 | ExitWithExitCode 1 37 | } 38 | 39 | $ErrorActionPreference = 'Stop' 40 | Set-StrictMode -Version 2.0 41 | 42 | $disableConfigureToolsetImport = $true 43 | $global:LASTEXITCODE = 0 44 | 45 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 46 | # scripts don't necessarily execute in the same agent that run the 47 | # build.ps1/sh script this variable isn't automatically set. 48 | $ci = $true 49 | . $PSScriptRoot\..\tools.ps1 50 | 51 | try { 52 | $dotnetRoot = InitializeDotNetCli -install:$true 53 | $dotnet = "$dotnetRoot\dotnet.exe" 54 | 55 | $toolsetVersion = Read-ArcadeSdkVersion 56 | Install-VersionTools-Cli -Version $toolsetVersion 57 | 58 | $cliToolFound = (& "$dotnet" tool list --local | Where-Object {$_.Split(' ')[0] -eq $CliToolName}) 59 | if ($null -eq $cliToolFound) { 60 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "The '$CliToolName' tool is not installed." 61 | ExitWithExitCode 1 62 | } 63 | 64 | Exec-BlockVerbosely { 65 | & "$dotnet" $CliToolName trim-assets-version ` 66 | --assets-path $InputPath ` 67 | --recursive $Recursive 68 | Exit-IfNZEC "Sdl" 69 | } 70 | } 71 | catch { 72 | Write-Host $_ 73 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 74 | ExitWithExitCode 1 75 | } 76 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/onelocbuild.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/onelocbuild.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/publish-build-assets.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/publish-build-assets.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/source-index-stage1.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-index-stage1.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/jobs/codeql-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/codeql-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/jobs/jobs.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/jobs.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/jobs/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/source-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/post-build/common-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | - template: /eng/common/core-templates/post-build/common-variables.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: true 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/post-build/post-build.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - template: /eng/common/core-templates/post-build/post-build.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: true 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} 9 | -------------------------------------------------------------------------------- /eng/common/templates-official/post-build/setup-maestro-vars.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: true 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/component-governance.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/enable-internal-runtimes.yml: -------------------------------------------------------------------------------- 1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64' 2 | # variable with the base64-encoded SAS token, by default 3 | steps: 4 | - template: /eng/common/core-templates/steps/enable-internal-runtimes.yml 5 | parameters: 6 | is1ESPipeline: true 7 | 8 | ${{ each parameter in parameters }}: 9 | ${{ parameter.key }}: ${{ parameter.value }} 10 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/enable-internal-sources.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/enable-internal-sources.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/steps/generate-sbom.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/generate-sbom.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/get-delegation-sas.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-federated-access-token.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/steps/publish-build-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: displayName 3 | type: string 4 | default: 'Publish to Build Artifact' 5 | 6 | - name: condition 7 | type: string 8 | default: succeeded() 9 | 10 | - name: artifactName 11 | type: string 12 | 13 | - name: pathToPublish 14 | type: string 15 | 16 | - name: continueOnError 17 | type: boolean 18 | default: false 19 | 20 | - name: publishLocation 21 | type: string 22 | default: 'Container' 23 | 24 | - name: is1ESPipeline 25 | type: boolean 26 | default: true 27 | 28 | steps: 29 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 30 | - 'eng/common/templates-official cannot be referenced from a non-1ES managed template': error 31 | - task: 1ES.PublishBuildArtifacts@1 32 | displayName: ${{ parameters.displayName }} 33 | condition: ${{ parameters.condition }} 34 | ${{ if parameters.continueOnError }}: 35 | continueOnError: ${{ parameters.continueOnError }} 36 | inputs: 37 | PublishLocation: ${{ parameters.publishLocation }} 38 | PathtoPublish: ${{ parameters.pathToPublish }} 39 | ${{ if parameters.artifactName }}: 40 | ArtifactName: ${{ parameters.artifactName }} 41 | 42 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/publish-logs.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/publish-logs.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/publish-pipeline-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: true 5 | 6 | - name: args 7 | type: object 8 | default: {} 9 | 10 | steps: 11 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 12 | - 'eng/common/templates-official cannot be referenced from a non-1ES managed template': error 13 | - task: 1ES.PublishPipelineArtifact@1 14 | displayName: ${{ coalesce(parameters.args.displayName, 'Publish to Build Artifact') }} 15 | ${{ if parameters.args.condition }}: 16 | condition: ${{ parameters.args.condition }} 17 | ${{ else }}: 18 | condition: succeeded() 19 | ${{ if parameters.args.continueOnError }}: 20 | continueOnError: ${{ parameters.args.continueOnError }} 21 | inputs: 22 | targetPath: ${{ parameters.args.targetPath }} 23 | ${{ if parameters.args.artifactName }}: 24 | artifactName: ${{ parameters.args.artifactName }} 25 | ${{ if parameters.args.properties }}: 26 | properties: ${{ parameters.args.properties }} 27 | ${{ if parameters.args.sbomEnabled }}: 28 | sbomEnabled: ${{ parameters.args.sbomEnabled }} 29 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/retain-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/retain-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/send-to-helix.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/send-to-helix.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/source-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/source-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/source-index-stage1-publish.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/source-index-stage1-publish.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/variables/pool-providers.yml: -------------------------------------------------------------------------------- 1 | # Select a pool provider based off branch name. Anything with branch name containing 'release' must go into an -Svc pool, 2 | # otherwise it should go into the "normal" pools. This separates out the queueing and billing of released branches. 3 | 4 | # Motivation: 5 | # Once a given branch of a repository's output has been officially "shipped" once, it is then considered to be COGS 6 | # (Cost of goods sold) and should be moved to a servicing pool provider. This allows both separation of queueing 7 | # (allowing release builds and main PR builds to not intefere with each other) and billing (required for COGS. 8 | # Additionally, the pool provider name itself may be subject to change when the .NET Core Engineering Services 9 | # team needs to move resources around and create new and potentially differently-named pools. Using this template 10 | # file from an Arcade-ified repo helps guard against both having to update one's release/* branches and renaming. 11 | 12 | # How to use: 13 | # This yaml assumes your shipped product branches use the naming convention "release/..." (which many do). 14 | # If we find alternate naming conventions in broad usage it can be added to the condition below. 15 | # 16 | # First, import the template in an arcade-ified repo to pick up the variables, e.g.: 17 | # 18 | # variables: 19 | # - template: /eng/common/templates-official/variables/pool-providers.yml 20 | # 21 | # ... then anywhere specifying the pool provider use the runtime variables, 22 | # $(DncEngInternalBuildPool) 23 | # 24 | # pool: 25 | # name: $(DncEngInternalBuildPool) 26 | # image: 1es-windows-2022 27 | 28 | variables: 29 | # Coalesce the target and source branches so we know when a PR targets a release branch 30 | # If these variables are somehow missing, fall back to main (tends to have more capacity) 31 | 32 | # Any new -Svc alternative pools should have variables added here to allow for splitting work 33 | 34 | - name: DncEngInternalBuildPool 35 | value: $[ 36 | replace( 37 | replace( 38 | eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), 39 | True, 40 | 'NetCore1ESPool-Svc-Internal' 41 | ), 42 | False, 43 | 'NetCore1ESPool-Internal' 44 | ) 45 | ] -------------------------------------------------------------------------------- /eng/common/templates-official/variables/sdl-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in 3 | # sync with the packages.config file. 4 | - name: DefaultGuardianVersion 5 | value: 0.109.0 6 | - name: GuardianPackagesConfigFile 7 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config -------------------------------------------------------------------------------- /eng/common/templates/job/onelocbuild.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/onelocbuild.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/job/publish-build-assets.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/publish-build-assets.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/job/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/job/source-index-stage1.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-index-stage1.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/jobs/codeql-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/codeql-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/jobs/jobs.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/jobs.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/jobs/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/source-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/post-build/common-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | - template: /eng/common/core-templates/post-build/common-variables.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: false 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/post-build/post-build.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - template: /eng/common/core-templates/post-build/post-build.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: false 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/post-build/setup-maestro-vars.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: false 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/component-governance.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/enable-internal-runtimes.yml: -------------------------------------------------------------------------------- 1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64' 2 | # variable with the base64-encoded SAS token, by default 3 | 4 | steps: 5 | - template: /eng/common/core-templates/steps/enable-internal-runtimes.yml 6 | parameters: 7 | is1ESPipeline: false 8 | 9 | ${{ each parameter in parameters }}: 10 | ${{ parameter.key }}: ${{ parameter.value }} 11 | -------------------------------------------------------------------------------- /eng/common/templates/steps/enable-internal-sources.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/enable-internal-sources.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/steps/generate-sbom.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/generate-sbom.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/get-delegation-sas.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-federated-access-token.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/steps/publish-build-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | 6 | - name: displayName 7 | type: string 8 | default: 'Publish to Build Artifact' 9 | 10 | - name: condition 11 | type: string 12 | default: succeeded() 13 | 14 | - name: artifactName 15 | type: string 16 | 17 | - name: pathToPublish 18 | type: string 19 | 20 | - name: continueOnError 21 | type: boolean 22 | default: false 23 | 24 | - name: publishLocation 25 | type: string 26 | default: 'Container' 27 | 28 | steps: 29 | - ${{ if eq(parameters.is1ESPipeline, true) }}: 30 | - 'eng/common/templates cannot be referenced from a 1ES managed template': error 31 | - task: PublishBuildArtifacts@1 32 | displayName: ${{ parameters.displayName }} 33 | condition: ${{ parameters.condition }} 34 | ${{ if parameters.continueOnError }}: 35 | continueOnError: ${{ parameters.continueOnError }} 36 | inputs: 37 | PublishLocation: ${{ parameters.publishLocation }} 38 | PathtoPublish: ${{ parameters.pathToPublish }} 39 | ${{ if parameters.artifactName }}: 40 | ArtifactName: ${{ parameters.artifactName }} -------------------------------------------------------------------------------- /eng/common/templates/steps/publish-logs.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/publish-logs.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/publish-pipeline-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | 6 | - name: args 7 | type: object 8 | default: {} 9 | 10 | steps: 11 | - ${{ if eq(parameters.is1ESPipeline, true) }}: 12 | - 'eng/common/templates cannot be referenced from a 1ES managed template': error 13 | - task: PublishPipelineArtifact@1 14 | displayName: ${{ coalesce(parameters.args.displayName, 'Publish to Build Artifact') }} 15 | ${{ if parameters.args.condition }}: 16 | condition: ${{ parameters.args.condition }} 17 | ${{ else }}: 18 | condition: succeeded() 19 | ${{ if parameters.args.continueOnError }}: 20 | continueOnError: ${{ parameters.args.continueOnError }} 21 | inputs: 22 | targetPath: ${{ parameters.args.targetPath }} 23 | ${{ if parameters.args.artifactName }}: 24 | artifactName: ${{ parameters.args.artifactName }} 25 | ${{ if parameters.args.publishLocation }}: 26 | publishLocation: ${{ parameters.args.publishLocation }} 27 | ${{ if parameters.args.fileSharePath }}: 28 | fileSharePath: ${{ parameters.args.fileSharePath }} 29 | ${{ if parameters.args.Parallel }}: 30 | parallel: ${{ parameters.args.Parallel }} 31 | ${{ if parameters.args.parallelCount }}: 32 | parallelCount: ${{ parameters.args.parallelCount }} 33 | ${{ if parameters.args.properties }}: 34 | properties: ${{ parameters.args.properties }} -------------------------------------------------------------------------------- /eng/common/templates/steps/retain-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/retain-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/send-to-helix.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/send-to-helix.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/source-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/source-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/source-index-stage1-publish.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/source-index-stage1-publish.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/variables/pool-providers.yml: -------------------------------------------------------------------------------- 1 | # Select a pool provider based off branch name. Anything with branch name containing 'release' must go into an -Svc pool, 2 | # otherwise it should go into the "normal" pools. This separates out the queueing and billing of released branches. 3 | 4 | # Motivation: 5 | # Once a given branch of a repository's output has been officially "shipped" once, it is then considered to be COGS 6 | # (Cost of goods sold) and should be moved to a servicing pool provider. This allows both separation of queueing 7 | # (allowing release builds and main PR builds to not intefere with each other) and billing (required for COGS. 8 | # Additionally, the pool provider name itself may be subject to change when the .NET Core Engineering Services 9 | # team needs to move resources around and create new and potentially differently-named pools. Using this template 10 | # file from an Arcade-ified repo helps guard against both having to update one's release/* branches and renaming. 11 | 12 | # How to use: 13 | # This yaml assumes your shipped product branches use the naming convention "release/..." (which many do). 14 | # If we find alternate naming conventions in broad usage it can be added to the condition below. 15 | # 16 | # First, import the template in an arcade-ified repo to pick up the variables, e.g.: 17 | # 18 | # variables: 19 | # - template: /eng/common/templates/variables/pool-providers.yml 20 | # 21 | # ... then anywhere specifying the pool provider use the runtime variables, 22 | # $(DncEngInternalBuildPool) and $ (DncEngPublicBuildPool), e.g.: 23 | # 24 | # pool: 25 | # name: $(DncEngInternalBuildPool) 26 | # demands: ImageOverride -equals windows.vs2019.amd64 27 | variables: 28 | - ${{ if eq(variables['System.TeamProject'], 'internal') }}: 29 | - template: /eng/common/templates-official/variables/pool-providers.yml 30 | - ${{ else }}: 31 | # Coalesce the target and source branches so we know when a PR targets a release branch 32 | # If these variables are somehow missing, fall back to main (tends to have more capacity) 33 | 34 | # Any new -Svc alternative pools should have variables added here to allow for splitting work 35 | - name: DncEngPublicBuildPool 36 | value: $[ 37 | replace( 38 | replace( 39 | eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), 40 | True, 41 | 'NetCore-Svc-Public' 42 | ), 43 | False, 44 | 'NetCore-Public' 45 | ) 46 | ] 47 | 48 | - name: DncEngInternalBuildPool 49 | value: $[ 50 | replace( 51 | replace( 52 | eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), 53 | True, 54 | 'NetCore1ESPool-Svc-Internal' 55 | ), 56 | False, 57 | 'NetCore1ESPool-Internal' 58 | ) 59 | ] 60 | -------------------------------------------------------------------------------- /eng/tsaconfig.gdntsa: -------------------------------------------------------------------------------- 1 | { 2 | "codebaseName": "Symreader-Portable-GitHub", 3 | "notificationAliases": [ 4 | "mlinfraswat@microsoft.com" 5 | ], 6 | "codebaseAdmins": [ 7 | "REDMOND\\tomat", 8 | "REDMOND\\phillipa" 9 | ], 10 | "instanceUrl": "https://devdiv.visualstudio.com", 11 | "projectName": "DevDiv", 12 | "areaPath": "DevDiv\\NET Developer Experience\\Debugger and Interactive", 13 | "iterationPath": "DevDiv", 14 | "allTools": true 15 | } -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "tools": { 3 | "dotnet": "10.0.100-alpha.1.25077.2" 4 | }, 5 | "msbuild-sdks": { 6 | "Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25080.7" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /restore.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where the 11 | # symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | 15 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 16 | "$scriptroot/eng/common/build.sh" --restore $@ -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Preview 8 | MIT 9 | false 10 | 11 | 12 | true 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Directory.Build.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.NativeTests/Microsoft.DiaSymReader.PortablePdb.Native.UnitTests.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Source Files 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.NativeTests/SymReaderTests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | #if TODO 3 | #pragma warning( push ) 4 | #pragma warning( disable: 4499 ) 5 | #include "CppUnitTest.h" 6 | #pragma warning (pop) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; 13 | 14 | namespace Microsoft_DiaSymReader_PortablePdb_UnitTests 15 | { 16 | // {E4B18DEF-3B78-46AE-8F50-E67E421BDF70} 17 | static const GUID CLSID_Factory = { 0xE4B18DEF, 0x3B78, 0x46AE, { 0x8F, 0x50, 0xE6, 0x7E, 0x42, 0x1B, 0xDF, 0x70 } }; 18 | 19 | // {AA544D42-28CB-11d3-BD22-0000F80849BD} 20 | static const GUID IID_ISymUnmanagedBinder = { 0xAA544D42, 0x28CB, 0x11d3, { 0xBD, 0x22, 0x00, 0x00, 0xF8, 0x08, 0x49, 0xBD } }; 21 | 22 | // To run these test from command line 23 | // vstest.console.exe Microsoft.DiaSymReader.PortablePdb.Native.UnitTests.dll 24 | TEST_CLASS(SymReaderTests) 25 | { 26 | public: 27 | TEST_METHOD(Instantiation) 28 | { 29 | HRESULT hr; 30 | 31 | hr = CoInitialize(nullptr); 32 | Assert::IsTrue(hr == S_OK || hr == S_FALSE, L"CoInitialize"); 33 | 34 | LPVOID factory; 35 | hr = CoCreateInstance(CLSID_Factory, nullptr, CLSCTX_INPROC_SERVER, IID_ISymUnmanagedBinder, &factory); 36 | Assert::AreEqual(S_OK, hr, L"CoCreateInstance"); 37 | 38 | Assert::AreEqual(1, 1); 39 | } 40 | }; 41 | 42 | } 43 | #endif -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.cmd: -------------------------------------------------------------------------------- 1 | csc /target:library /debug:portable /optimize- /deterministic Async.cs 2 | copy /y Async.pdb Async.pdbx 3 | copy /y Async.dll Async.dllx 4 | 5 | csc /target:library /debug+ /optimize- /deterministic Async.cs 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.cs: -------------------------------------------------------------------------------- 1 | #line 1 "C:\Async.cs" 2 | #pragma checksum "C:\Async.cs" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "DBEB2A067B2F0E0D678A002C587A2806056C3DCE" 3 | 4 | using System.Threading.Tasks; 5 | 6 | public class C 7 | { 8 | public async Task M1() 9 | { 10 | await Task.FromResult(0); 11 | await Task.FromResult(1); 12 | await Task.FromResult(2); 13 | 14 | return 1; 15 | } 16 | 17 | public async void M2() 18 | { 19 | await Task.FromResult(0); 20 | } 21 | } -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Async.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.cmd: -------------------------------------------------------------------------------- 1 | csc /target:library /debug:portable /optimize- /deterministic /pathmap:%~dp0=/ /checksumalgorithm:sha256 Documents.cs 2 | copy /y Documents.pdb Documents.pdbx 3 | copy /y Documents.dll Documents.dllx 4 | 5 | csc /target:library /debug+ /optimize- /deterministic /pathmap:%~dp0=/ /checksumalgorithm:sha256 Documents.cs 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.cs: -------------------------------------------------------------------------------- 1 | #line 1 "C:\Documents.cs" 2 | #pragma checksum "C:\Documents.cs" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "DBEB2A067B2F0E0D678A002C587A2806056C3DCE" 3 | using System; 4 | 5 | class C 6 | { 7 | public void M() 8 | { 9 | #line 10 "C:\a\b\c\d\1.cs" 10 | Console.WriteLine(1); 11 | #line 20 "C:\a\b\c\D\2.cs" 12 | Console.WriteLine(2); 13 | #line 30 "C:\a\b\C\d\3.cs" 14 | Console.WriteLine(3); 15 | #line 40 16 | Console.WriteLine(4); 17 | #line hidden 18 | Console.WriteLine(); 19 | #line 50 "C:\a\b\c\d\x.cs" 20 | Console.WriteLine(5); 21 | #line 60 "C:\A\b\c\x.cs" 22 | Console.WriteLine(5); 23 | #line 70 "C:\a\b\x.cs" 24 | Console.WriteLine(5); 25 | #line 80 "C:\a\B\3.cs" 26 | Console.WriteLine(3); 27 | #line 90 "C:\a\B\c/4.cs" 28 | Console.WriteLine(4); 29 | #line 100 "C:\*\5.cs" 30 | Console.WriteLine(5); 31 | #line 110 ":6.cs" 32 | Console.WriteLine(6); 33 | #line 120 "C:\a\b\X.cs" 34 | Console.WriteLine(7); 35 | #line 130 "C:\a\B\x.cs" 36 | Console.WriteLine(8); 37 | } 38 | 39 | #line hidden 40 | void F() 41 | { 42 | _ = new Func(i => i + 1); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Documents.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.cmd: -------------------------------------------------------------------------------- 1 | csc /target:library /debug:portable /optimize- /deterministic /out:EmbeddedSource.dll /pathmap:%~dp0=C:\ /embed EmbeddedSource.cs EmbeddedSourceNoCode.cs EmbeddedSourceSmall.cs EmbeddedSourceNoSequencePoints.cs 2 | copy /y EmbeddedSource.pdb EmbeddedSource.pdbx 3 | copy /y EmbeddedSource.dll EmbeddedSource.dllx 4 | 5 | csc /target:library /debug+ /optimize- /deterministic /out:EmbeddedSource.dll /pathmap:%~dp0=C:\ /embed EmbeddedSource.cs EmbeddedSourceNoCode.cs EmbeddedSourceSmall.cs EmbeddedSourceNoSequencePoints.cs 6 | 7 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.cs: -------------------------------------------------------------------------------- 1 | // should be higher than compression threshold (200 chars) 2 | 3 | using System; 4 | 5 | namespace Test 6 | { 7 | public static class SomeCode 8 | { 9 | public static int SomeMethod(int value) 10 | { 11 | if (value < 0) 12 | { 13 | throw new ArgumentOutOfRangeException(nameof(value)); 14 | } 15 | 16 | return checked(value + 42); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSource.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSourceNoCode.cs: -------------------------------------------------------------------------------- 1 | // file with no code 2 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSourceNoSequencePoints.cs: -------------------------------------------------------------------------------- 1 | // file with no sequence points 2 | 3 | interface I { } 4 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EmbeddedSourceSmall.cs: -------------------------------------------------------------------------------- 1 | // should be less than compression threshold (200 chars) 2 | public class Small 3 | { 4 | public Small() {} 5 | } -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/App.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/Delta.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/Delta.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/Delta.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncDocuments/Delta.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.metadata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.metadata -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.metadatax: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.metadatax -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.1.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.metadata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.metadata -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.metadatax: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.metadatax -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.2.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/EncMethodExtents/EncMethodExtents.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.cmd: -------------------------------------------------------------------------------- 1 | csc /target:library /debug:portable /optimize- /deterministic MethodBoundaries.cs 2 | copy /y MethodBoundaries.pdb MethodBoundaries.pdbx 3 | copy /y MethodBoundaries.dll MethodBoundaries.dllx 4 | 5 | csc /target:library /debug+ /optimize- /deterministic MethodBoundaries.cs 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MethodBoundaries.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MiscEmbedded.cmd: -------------------------------------------------------------------------------- 1 | csc /target:library /debug:embedded /optimize- /deterministic MiscEmbedded.cs -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MiscEmbedded.cs: -------------------------------------------------------------------------------- 1 | #line 1 "C:\MiscEmbedded.cs" 2 | #pragma checksum "C:\MiscEmbedded.cs" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "DBEB2A067B2F0E0D678A002C587A2806056C3DCE" 3 | 4 | using System; 5 | using System.IO; 6 | using static System.Math; // unused 7 | 8 | namespace N 9 | { 10 | using System.Threading.Tasks; 11 | using IEB = System.Collections.Generic.IEnumerable; 12 | using TS = System.Threading.Tasks.Task; // unused 13 | 14 | class C 15 | { 16 | public static void Main() 17 | { 18 | Console.WriteLine("hello world"); 19 | } 20 | 21 | public static async Task A() 22 | { 23 | await Task.Delay(1); 24 | return 2; 25 | } 26 | 27 | public static IEB I() 28 | { 29 | yield return 1; 30 | yield return 2; 31 | yield return 3; 32 | } 33 | 34 | public static void Locals() 35 | { 36 | { 37 | const dynamic x = null; 38 | } 39 | 40 | { 41 | const C x = null; 42 | } 43 | 44 | { 45 | object x = null; 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MiscEmbedded.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/MiscEmbedded.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.cmd: -------------------------------------------------------------------------------- 1 | csc /target:library /debug:portable /optimize- /deterministic Scopes.cs 2 | copy /y Scopes.pdb Scopes.pdbx 3 | copy /y Scopes.dll Scopes.dllx 4 | 5 | csc /target:library /debug+ /optimize- /deterministic Scopes.cs -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/Scopes.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceData.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceData.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.Embedded.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.Embedded.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.cmd: -------------------------------------------------------------------------------- 1 | csc /target:library /debug:portable /optimize- /deterministic /out:SourceLink.dll /sourcelink:SourceLink.json Documents.cs 2 | csc /target:library /debug:embedded /optimize- /deterministic /out:SourceLink.Embedded.dll /sourcelink:SourceLink.json Documents.cs 3 | 4 | copy /y SourceLink.dll SourceLink.dllx 5 | copy /y SourceLink.pdb SourceLink.pdbx 6 | 7 | csc.exe /target:library /debug:full /optimize- /deterministic /out:SourceLink.dll /sourcelink:SourceLink.json Documents.cs -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.dll -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.dllx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.dllx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.json: -------------------------------------------------------------------------------- 1 | { 2 | "documents": 3 | { 4 | "C:\\a*": "http://server1/*", 5 | "C:\\A*": "http://server2/*", 6 | } 7 | } -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.pdb -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.pdbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/symreader-portable/75c1bfdced2f01397c11b50833f3e4d14d73af52/src/Microsoft.DiaSymReader.PortablePdb.Tests/Resources/SourceLink.pdbx -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/TestHelpers/ConditionalFactAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Globalization; 7 | using System.IO; 8 | using System.Text; 9 | using Xunit; 10 | 11 | namespace Roslyn.Test.Utilities 12 | { 13 | public class ConditionalFactAttribute : FactAttribute 14 | { 15 | public ConditionalFactAttribute(params Type[] skipConditions) 16 | { 17 | foreach (var skipCondition in skipConditions) 18 | { 19 | ExecutionCondition condition = (ExecutionCondition)Activator.CreateInstance(skipCondition); 20 | if (condition.ShouldSkip) 21 | { 22 | Skip = condition.SkipReason; 23 | break; 24 | } 25 | } 26 | } 27 | } 28 | 29 | public abstract class ExecutionCondition 30 | { 31 | public abstract bool ShouldSkip { get; } 32 | public abstract string SkipReason { get; } 33 | } 34 | 35 | public class x86 : ExecutionCondition 36 | { 37 | public override bool ShouldSkip => IntPtr.Size != 4; 38 | 39 | public override string SkipReason => "Target platform is not x86"; 40 | } 41 | 42 | public class WindowsOnly : ExecutionCondition 43 | { 44 | public override bool ShouldSkip => Path.DirectorySeparatorChar != '\\'; 45 | public override string SkipReason => "Test not supported on Mono"; 46 | } 47 | 48 | public class DesktopOnly : ExecutionCondition 49 | { 50 | internal static bool IsRunningOnCoreClr => AssemblyLoadContext.Type != null; 51 | 52 | internal static class AssemblyLoadContext 53 | { 54 | internal static readonly Type Type = TryGetType( 55 | "System.Runtime.Loader.AssemblyLoadContext, System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); 56 | } 57 | 58 | public static Type TryGetType(string assemblyQualifiedName) 59 | { 60 | try 61 | { 62 | // Note that throwOnError=false only suppresses some exceptions, not all. 63 | return Type.GetType(assemblyQualifiedName, throwOnError: false); 64 | } 65 | catch 66 | { 67 | return null; 68 | } 69 | } 70 | 71 | public override bool ShouldSkip => IsRunningOnCoreClr; 72 | public override string SkipReason => "Test not supported on CoreCLR"; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/TestHelpers/EnumerableHelpersTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using Roslyn.Test.Utilities; 7 | using Xunit; 8 | 9 | namespace Microsoft.DiaSymReader.PortablePdb.UnitTests 10 | { 11 | public class EnumerableHelpersTests 12 | { 13 | [Fact] 14 | public void GroupBy1() 15 | { 16 | var pairs = new[] 17 | { 18 | KeyValuePair.Create("A", 1), 19 | KeyValuePair.Create("B", 2), 20 | KeyValuePair.Create("C", 3), 21 | KeyValuePair.Create("a", 4), 22 | KeyValuePair.Create("B", 5), 23 | KeyValuePair.Create("A", 6), 24 | KeyValuePair.Create("d", 7), 25 | }; 26 | 27 | var groups = pairs.GroupBy(StringComparer.OrdinalIgnoreCase); 28 | AssertEx.SetEqual(new[] { "A", "B", "C", "d" }, groups.Keys); 29 | 30 | Assert.Equal(0, groups["A"].Single); 31 | AssertEx.Equal(new[] { 1, 4, 6 }, groups["A"].Multiple); 32 | 33 | Assert.Equal(0, groups["B"].Single); 34 | AssertEx.Equal(new[] { 2, 5 }, groups["B"].Multiple); 35 | 36 | Assert.Equal(3, groups["C"].Single); 37 | Assert.True(groups["C"].Multiple.IsDefault); 38 | 39 | Assert.Equal(7, groups["d"].Single); 40 | Assert.True(groups["d"].Multiple.IsDefault); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/TestHelpers/PdbTestData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | 9 | namespace Microsoft.DiaSymReader.PortablePdb.UnitTests 10 | { 11 | public class PdbTestData : IEnumerable 12 | { 13 | private static readonly List _data; 14 | 15 | static PdbTestData() 16 | { 17 | _data = new List(); 18 | 19 | // always test Portable PDB: 20 | _data.Add(new object[] { true }); 21 | 22 | if (Path.DirectorySeparatorChar == '\\') 23 | { 24 | // Test Windows PDBs only on Windows 25 | _data.Add(new object[] { false }); 26 | } 27 | } 28 | 29 | public IEnumerator GetEnumerator() => _data.GetEnumerator(); 30 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/TestHelpers/ResourceLoader.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.IO; 7 | using System.Reflection; 8 | 9 | namespace TestResources 10 | { 11 | internal static class ResourceLoader 12 | { 13 | private static Stream GetResourceStream(string name) 14 | { 15 | var assembly = typeof(ResourceLoader).GetTypeInfo().Assembly; 16 | 17 | var stream = assembly.GetManifestResourceStream(name); 18 | if (stream == null) 19 | { 20 | throw new InvalidOperationException($"Resource '{name}' not found in {assembly.FullName}."); 21 | } 22 | 23 | return stream; 24 | } 25 | 26 | private static byte[] GetResourceBlob(string name) 27 | { 28 | using (var stream = GetResourceStream(name)) 29 | { 30 | var bytes = new byte[stream.Length]; 31 | using (var memoryStream = new MemoryStream(bytes)) 32 | { 33 | stream.CopyTo(memoryStream); 34 | } 35 | 36 | return bytes; 37 | } 38 | } 39 | 40 | public static byte[] GetOrCreateResource(ref byte[] resource, string name) 41 | { 42 | if (resource == null) 43 | { 44 | resource = GetResourceBlob(name); 45 | } 46 | 47 | return resource; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/TestHelpers/SymMetadataProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | using System.IO; 8 | using System.Reflection; 9 | using System.Reflection.Metadata; 10 | using System.Reflection.Metadata.Ecma335; 11 | using System.Reflection.PortableExecutable; 12 | 13 | namespace Microsoft.DiaSymReader.PortablePdb.UnitTests 14 | { 15 | internal sealed class SymMetadataProvider : ISymReaderMetadataProvider, IDisposable 16 | { 17 | private readonly PEReader _peReader; 18 | private readonly MetadataReader _reader; 19 | 20 | public SymMetadataProvider(Stream peStream) 21 | { 22 | _peReader = new PEReader(peStream); 23 | _reader = _peReader.GetMetadataReader(); 24 | } 25 | 26 | public void Dispose() 27 | { 28 | _peReader.Dispose(); 29 | } 30 | 31 | public unsafe bool TryGetStandaloneSignature(int standaloneSignatureToken, out byte* signature, out int length) 32 | { 33 | var sigHandle = (StandaloneSignatureHandle)MetadataTokens.Handle(standaloneSignatureToken); 34 | if (sigHandle.IsNil) 35 | { 36 | signature = null; 37 | length = 0; 38 | return false; 39 | } 40 | 41 | var sig = _reader.GetStandaloneSignature(sigHandle); 42 | var blobReader = _reader.GetBlobReader(sig.Signature); 43 | 44 | signature = blobReader.StartPointer; 45 | length = blobReader.Length; 46 | return true; 47 | } 48 | 49 | public bool TryGetTypeDefinitionInfo(int typeDefinitionToken, out string namespaceName, out string typeName, out TypeAttributes attributes) 50 | { 51 | var handle = (TypeDefinitionHandle)MetadataTokens.Handle(typeDefinitionToken); 52 | if (handle.IsNil) 53 | { 54 | namespaceName = null; 55 | typeName = null; 56 | attributes = 0; 57 | return false; 58 | } 59 | 60 | var typeDefinition = _reader.GetTypeDefinition(handle); 61 | namespaceName = _reader.GetString(typeDefinition.Namespace); 62 | typeName = _reader.GetString(typeDefinition.Name); 63 | attributes = typeDefinition.Attributes; 64 | return true; 65 | } 66 | 67 | public bool TryGetTypeReferenceInfo(int typeReferenceToken, out string namespaceName, out string typeName) 68 | { 69 | var handle = (TypeReferenceHandle)MetadataTokens.Handle(typeReferenceToken); 70 | if (handle.IsNil) 71 | { 72 | namespaceName = null; 73 | typeName = null; 74 | return false; 75 | } 76 | 77 | var typeReference = _reader.GetTypeReference(handle); 78 | namespaceName = _reader.GetString(typeReference.Namespace); 79 | typeName = _reader.GetString(typeReference.Name); 80 | return true; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb.Tests/TestHelpers/TestResource.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | namespace Microsoft.DiaSymReader.PortablePdb.UnitTests 5 | { 6 | public struct TestResource 7 | { 8 | public readonly byte[] PE; 9 | public readonly byte[] Pdb; 10 | 11 | public TestResource(byte[] pe, byte[] pdb) 12 | { 13 | PE = pe; 14 | Pdb = pdb; 15 | } 16 | 17 | public override string ToString() 18 | { 19 | return "TR"; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/AsyncMethodData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Immutable; 7 | using System.Diagnostics; 8 | using System.Reflection.Metadata; 9 | using System.Runtime.InteropServices; 10 | 11 | namespace Microsoft.DiaSymReader.PortablePdb 12 | { 13 | internal sealed class AsyncMethodData 14 | { 15 | public static readonly AsyncMethodData None = new AsyncMethodData(); 16 | 17 | public readonly MethodDefinitionHandle KickoffMethod; 18 | public readonly int CatchHandlerOffset; 19 | public readonly ImmutableArray YieldOffsets; 20 | public readonly ImmutableArray ResumeOffsets; 21 | public readonly ImmutableArray ResumeMethods; 22 | 23 | private AsyncMethodData() 24 | { 25 | } 26 | 27 | public AsyncMethodData( 28 | MethodDefinitionHandle kickoffMethod, 29 | int catchHandlerOffset, 30 | ImmutableArray yieldOffsets, 31 | ImmutableArray resumeOffsets, 32 | ImmutableArray resumeMethods) 33 | { 34 | Debug.Assert(!kickoffMethod.IsNil); 35 | Debug.Assert(catchHandlerOffset >= -1); 36 | 37 | Debug.Assert(yieldOffsets.Length == resumeOffsets.Length); 38 | Debug.Assert(yieldOffsets.Length == resumeMethods.Length); 39 | 40 | KickoffMethod = kickoffMethod; 41 | CatchHandlerOffset = catchHandlerOffset; 42 | YieldOffsets = yieldOffsets; 43 | ResumeOffsets = resumeOffsets; 44 | ResumeMethods = resumeMethods; 45 | } 46 | 47 | public bool IsNone => ReferenceEquals(this, None); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/DocumentId.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | 8 | namespace Microsoft.DiaSymReader.PortablePdb 9 | { 10 | /// 11 | /// Unique ID representing a document across all generations. 12 | /// 13 | [DebuggerDisplay("{GetDebuggerDisplay(),nq}")] 14 | internal readonly struct DocumentId : IEquatable 15 | { 16 | // 1-based 17 | public readonly int Value; 18 | 19 | public DocumentId(int id) 20 | { 21 | Value = id; 22 | } 23 | 24 | public bool IsDefault => Value == 0; 25 | 26 | public bool Equals(DocumentId other) => Value == other.Value; 27 | public override int GetHashCode() => Value.GetHashCode(); 28 | public override bool Equals(object? obj) => obj is DocumentId id && Equals(id); 29 | 30 | private object GetDebuggerDisplay() => Value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/InvalidInputDataException.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | 7 | namespace Microsoft.DiaSymReader.PortablePdb 8 | { 9 | internal class InvalidInputDataException : Exception 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/MethodExtent.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics; 8 | 9 | namespace Microsoft.DiaSymReader.PortablePdb 10 | { 11 | [DebuggerDisplay("{GetDebuggerDisplay(),nq}")] 12 | internal readonly struct MethodLineExtent 13 | { 14 | internal sealed class MethodComparer : IComparer 15 | { 16 | public static readonly MethodComparer Instance = new MethodComparer(); 17 | public int Compare(MethodLineExtent x, MethodLineExtent y) => x.Method.CompareTo(y.Method); 18 | } 19 | 20 | internal sealed class MinLineComparer : IComparer 21 | { 22 | public static readonly MinLineComparer Instance = new MinLineComparer(); 23 | public int Compare(MethodLineExtent x, MethodLineExtent y) => x.MinLine - y.MinLine; 24 | } 25 | 26 | public readonly MethodId Method; 27 | public readonly int Version; 28 | public readonly int MinLine; 29 | public readonly int MaxLine; 30 | 31 | public MethodLineExtent(MethodId method, int version, int minLine, int maxLine) 32 | { 33 | Method = method; 34 | Version = version; 35 | MinLine = minLine; 36 | MaxLine = maxLine; 37 | } 38 | 39 | public static MethodLineExtent Merge(MethodLineExtent left, MethodLineExtent right) 40 | { 41 | Debug.Assert(left.Method == right.Method); 42 | Debug.Assert(left.Version == right.Version); 43 | return new MethodLineExtent(left.Method, left.Version, Math.Min(left.MinLine, right.MinLine), Math.Max(left.MaxLine, right.MaxLine)); 44 | } 45 | 46 | public MethodLineExtent ApplyDelta(int delta) => 47 | new MethodLineExtent(Method, Version, MinLine + delta, MaxLine + delta); 48 | 49 | private string GetDebuggerDisplay() => 50 | $"{Method.Value} v{Version} [{MinLine}-{MaxLine}]"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/MethodId.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | 8 | namespace Microsoft.DiaSymReader.PortablePdb 9 | { 10 | /// 11 | /// Unique ID representing a method across all generations. 12 | /// 13 | [DebuggerDisplay("{GetDebuggerDisplay(),nq}")] 14 | internal readonly struct MethodId : IEquatable, IComparable 15 | { 16 | // 1-based 17 | public readonly int Value; 18 | 19 | public MethodId(int id) 20 | { 21 | Value = id; 22 | } 23 | 24 | public int Token => MetadataUtilities.MethodDefToken(Value); 25 | public static MethodId FromToken(int methodToken) => new MethodId(MetadataUtilities.GetRowId(methodToken)); 26 | 27 | public bool IsDefault => Value == 0; 28 | 29 | public bool Equals(MethodId other) => Value == other.Value; 30 | public override int GetHashCode() => Value.GetHashCode(); 31 | public override bool Equals(object? obj) => obj is MethodId id && Equals(id); 32 | 33 | public int CompareTo(MethodId other) => Value.CompareTo(other.Value); 34 | 35 | public static bool operator ==(MethodId left, MethodId right) => left.Equals(right); 36 | public static bool operator !=(MethodId left, MethodId right) => !left.Equals(right); 37 | public static bool operator <(MethodId left, MethodId right) => left.Value < right.Value; 38 | public static bool operator >(MethodId left, MethodId right) => left.Value > right.Value; 39 | public static bool operator <=(MethodId left, MethodId right) => left.Value <= right.Value; 40 | public static bool operator >=(MethodId left, MethodId right) => left.Value >= right.Value; 41 | 42 | private object GetDebuggerDisplay() => Value; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/MethodLineDeltas.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Immutable; 7 | using System.Diagnostics; 8 | 9 | namespace Microsoft.DiaSymReader.PortablePdb 10 | { 11 | internal readonly struct MethodLineDeltas 12 | { 13 | /// 14 | /// Delta applied to all sequence points. 15 | /// 16 | private readonly int _delta; 17 | 18 | /// 19 | /// Per-sequence-point deltas. 20 | /// 21 | private readonly ImmutableArray _deltas; 22 | 23 | public MethodLineDeltas(int delta, ImmutableArray deltas) 24 | { 25 | Debug.Assert(!deltas.IsDefault); 26 | _deltas = deltas; 27 | _delta = delta; 28 | } 29 | 30 | public bool IsDefault => _deltas.IsDefault; 31 | 32 | public MethodLineDeltas Merge(MethodLineDeltas other) 33 | { 34 | int maxLength = Math.Max(_deltas.Length, other._deltas.Length); 35 | int minLength = Math.Min(_deltas.Length, other._deltas.Length); 36 | 37 | var builder = ImmutableArray.CreateBuilder(maxLength); 38 | 39 | for (int i = 0; i < minLength; i++) 40 | { 41 | builder.Add(unchecked(_deltas[i] + other._deltas[i])); 42 | } 43 | 44 | builder.AddSubRange(_deltas, minLength); 45 | builder.AddSubRange(other._deltas, minLength); 46 | 47 | return new MethodLineDeltas(unchecked(_delta + other._delta), builder.MoveToImmutable()); 48 | } 49 | 50 | public int GetDeltaForSequencePoint(int index) 51 | => unchecked(_delta + (!_deltas.IsDefault && index < _deltas.Length ? _deltas[index] : 0)); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Microsoft.DiaSymReader.PortablePdb.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | netstandard2.0;net9.0 6 | true 7 | true 8 | true 9 | Implementation of Microsoft DiaSymReader interfaces that reads debug information from Portable PDB format. 10 | DiaSymReader ISymUnmanagedReader Portable PDB COM interop debugging 11 | true 12 | enable 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/RootScopeData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections.Immutable; 6 | 7 | namespace Microsoft.DiaSymReader.PortablePdb 8 | { 9 | internal sealed class RootScopeData : ScopeData 10 | { 11 | internal RootScopeData(SymMethod symMethod) 12 | : base(symMethod) 13 | { 14 | } 15 | 16 | internal override ScopeData? Parent => null; 17 | internal override int StartOffset => 0; 18 | 19 | internal override int EndOffset 20 | { 21 | get 22 | { 23 | var mdReader = SymMethod.MetadataReader; 24 | var allScopes = mdReader.GetLocalScopes(SymMethod.DebugHandle); 25 | 26 | foreach (var handle in allScopes) 27 | { 28 | // the first scope spans the entire body 29 | return AdjustEndOffset(mdReader.GetLocalScope(handle).EndOffset); 30 | } 31 | 32 | // method has no body 33 | return 0; 34 | } 35 | } 36 | 37 | protected override ImmutableArray CreateChildren() 38 | { 39 | foreach (var handle in SymMethod.MetadataReader.GetLocalScopes(SymMethod.DebugHandle)) 40 | { 41 | // The root scope has only a single child scope, 42 | // which is the first scope in the scopes belonging to the method: 43 | return ImmutableArray.Create(new ChildScopeData(SymMethod, this, handle)); 44 | } 45 | 46 | // method has no body 47 | return ImmutableArray.Empty; 48 | } 49 | 50 | internal override int GetConstants(int bufferLength, out int count, ISymUnmanagedConstant[]? constants) 51 | { 52 | // C# and VB never define any constants in the root scope 53 | count = 0; 54 | return HResult.S_OK; 55 | } 56 | 57 | internal override int GetLocals(int bufferLength, out int count, ISymUnmanagedVariable[]? locals) 58 | { 59 | // C# and VB never define any locals in the root scope 60 | count = 0; 61 | return HResult.S_OK; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/ScopeData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections.Immutable; 6 | 7 | namespace Microsoft.DiaSymReader.PortablePdb 8 | { 9 | internal abstract class ScopeData 10 | { 11 | internal readonly SymMethod SymMethod; 12 | 13 | private ImmutableArray _lazyChildren; 14 | 15 | internal ScopeData(SymMethod symMethod) 16 | { 17 | SymMethod = symMethod; 18 | } 19 | 20 | internal ImmutableArray GetChildren() 21 | { 22 | if (_lazyChildren.IsDefault) 23 | { 24 | _lazyChildren = CreateChildren(); 25 | } 26 | 27 | return _lazyChildren; 28 | } 29 | 30 | public int AdjustEndOffset(int value) 31 | { 32 | // Portable PDB uses edge-exclusive semantics like C#. 33 | // VB end offset is inclusive. 34 | return SymMethod.SymReader.VbSemantics.Value && Parent is not RootScopeData ? value - 1 : value; 35 | } 36 | 37 | protected abstract ImmutableArray CreateChildren(); 38 | 39 | internal abstract int StartOffset { get; } 40 | internal abstract int EndOffset { get; } 41 | internal abstract ScopeData? Parent { get; } 42 | internal abstract int GetConstants(int bufferLength, out int count, ISymUnmanagedConstant[]? constants); 43 | internal abstract int GetLocals(int bufferLength, out int count, ISymUnmanagedVariable[]? locals); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/Debug.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Diagnostics; 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Microsoft.DiaSymReader.PortablePdb 9 | { 10 | internal static class Debug 11 | { 12 | [Conditional("DEBUG")] 13 | public static void Assert([DoesNotReturnIf(false)] bool b) 14 | => System.Diagnostics.Debug.Assert(b); 15 | 16 | /// 17 | [Conditional("DEBUG")] 18 | public static void Assert([DoesNotReturnIf(false)] bool b, string message) 19 | => System.Diagnostics.Debug.Assert(b, message); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/EmptyArray.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | namespace Microsoft.DiaSymReader.PortablePdb 6 | { 7 | internal static class EmptyArray 8 | { 9 | public static readonly T[] Instance = new T[0]; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/EnumerableHelpers.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | 8 | namespace Microsoft.DiaSymReader.PortablePdb 9 | { 10 | internal static class EnumerableHelpers 11 | { 12 | /// 13 | /// Groups specified entries by key optimizing for single-item groups. 14 | /// The ordering of values within each bucket is the same as their ordering in the sequence. 15 | /// 16 | public static Dictionary Multiple)> GroupBy(this IEnumerable> entries, IEqualityComparer keyComparer) where K : notnull 17 | { 18 | var builder = new Dictionary.Builder? Multiple)>(keyComparer); 19 | 20 | foreach (var entry in entries) 21 | { 22 | if (!builder.TryGetValue(entry.Key, out var existing)) 23 | { 24 | builder[entry.Key] = (entry.Value, default(ImmutableArray.Builder)); 25 | } 26 | else if (existing.Multiple == null) 27 | { 28 | var list = ImmutableArray.CreateBuilder(); 29 | list.Add(existing.Single); 30 | list.Add(entry.Value); 31 | builder[entry.Key] = (default(V)!, list); 32 | } 33 | else 34 | { 35 | existing.Multiple.Add(entry.Value); 36 | } 37 | } 38 | 39 | var result = new Dictionary)>(builder.Count, keyComparer); 40 | foreach (var entry in builder) 41 | { 42 | result.Add(entry.Key, (entry.Value.Single, entry.Value.Multiple?.ToImmutable() ?? default)); 43 | } 44 | 45 | return result; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/ExceptionUtilities.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | 8 | namespace Roslyn.Utilities 9 | { 10 | internal static class ExceptionUtilities 11 | { 12 | internal static Exception UnexpectedValue(object o) 13 | { 14 | string output = string.Format("Unexpected value '{0}' of type '{1}'", o, (o != null) ? o.GetType().FullName : ""); 15 | Debug.Assert(false, output); 16 | 17 | // We do not throw from here because we don't want all Watson reports to be bucketed to this call. 18 | return new InvalidOperationException(output); 19 | } 20 | 21 | internal static Exception Unreachable 22 | { 23 | get { return new InvalidOperationException("This program location is thought to be unreachable."); } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/FileNameUtilities.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | namespace Microsoft.DiaSymReader.PortablePdb 6 | { 7 | internal static class FileNameUtilities 8 | { 9 | private const string DirectorySeparatorStr = "\\"; 10 | private const char DirectorySeparatorChar = '\\'; 11 | private const char AltDirectorySeparatorChar = '/'; 12 | private const char VolumeSeparatorChar = ':'; 13 | 14 | /// 15 | /// Returns the position in given path where the file name starts. 16 | /// 17 | /// -1 if path is null. 18 | internal static int IndexOfFileName(string? path) 19 | { 20 | if (path == null) 21 | { 22 | return -1; 23 | } 24 | 25 | for (int i = path.Length - 1; i >= 0; i--) 26 | { 27 | char ch = path[i]; 28 | if (ch == DirectorySeparatorChar || ch == AltDirectorySeparatorChar || ch == VolumeSeparatorChar) 29 | { 30 | return i + 1; 31 | } 32 | } 33 | 34 | return 0; 35 | } 36 | 37 | internal static bool IsDirectorySeparator(char separator) 38 | { 39 | return separator == DirectorySeparatorChar || separator == AltDirectorySeparatorChar; 40 | } 41 | 42 | /// 43 | /// Get file name from path. 44 | /// 45 | /// Unlike doesn't check for invalid path characters. 46 | internal static string GetFileName(string path) 47 | { 48 | int fileNameStart = IndexOfFileName(path); 49 | return (fileNameStart <= 0) ? path : path.Substring(fileNameStart); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/HResult.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | namespace Microsoft.DiaSymReader.PortablePdb 6 | { 7 | internal static class HResult 8 | { 9 | internal const int S_OK = 0; 10 | internal const int S_FALSE = 1; 11 | internal const int E_NOTIMPL = unchecked((int)0x80004001); 12 | internal const int E_FAIL = unchecked((int)0x80004005); 13 | internal const int E_INVALIDARG = unchecked((int)0x80070057); 14 | internal const int E_WIN32_NOT_ENOUGH_MEMORY = unchecked((int)0x80070008); 15 | internal const int E_OUTOFMEMORY = unchecked((int)0x8007000E); 16 | internal const int E_UNEXPECTED = unchecked((int)0x8000FFFF); 17 | 18 | internal const int E_PDB_NOT_FOUND = unchecked((int)0x806D0005); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/HashHelpers.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | namespace System.Numerics.Hashing 6 | { 7 | internal static class HashHelpers 8 | { 9 | public static readonly int RandomSeed = new Random().Next(Int32.MinValue, Int32.MaxValue); 10 | 11 | public static int Combine(int h1, int h2) 12 | { 13 | // RyuJIT optimizes this to use the ROL instruction 14 | // Related GitHub pull request: dotnet/coreclr#1830 15 | uint rol5 = ((uint)h1 << 5) | ((uint)h1 >> 27); 16 | return ((int)rol5 + h1) ^ h2; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/ImmutableArrayExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Collections.Immutable; 8 | 9 | namespace Microsoft.DiaSymReader.PortablePdb 10 | { 11 | internal static class ImmutableArrayExtensions 12 | { 13 | internal static ImmutableArray ToImmutableArrayOrEmpty(this IEnumerable items) 14 | { 15 | if (items == null) 16 | { 17 | return ImmutableArray.Create(); 18 | } 19 | 20 | return ImmutableArray.CreateRange(items); 21 | } 22 | 23 | internal static ImmutableArray ToImmutableArrayOrEmpty(this ImmutableArray items) 24 | { 25 | if (items.IsDefault) 26 | { 27 | return ImmutableArray.Create(); 28 | } 29 | 30 | return items; 31 | } 32 | 33 | // same as Array.BinarySearch but the ability to pass arbitrary value to the comparer without allocation 34 | internal static int BinarySearch(this ImmutableArray array, TValue value, Func comparer) 35 | { 36 | int low = 0; 37 | int high = array.Length - 1; 38 | 39 | while (low <= high) 40 | { 41 | int middle = low + ((high - low) >> 1); 42 | int comparison = comparer(array[middle], value); 43 | 44 | if (comparison == 0) 45 | { 46 | return middle; 47 | } 48 | 49 | if (comparison > 0) 50 | { 51 | high = middle - 1; 52 | } 53 | else 54 | { 55 | low = middle + 1; 56 | } 57 | } 58 | 59 | return ~low; 60 | } 61 | 62 | internal static void AddSubRange(this ImmutableArray.Builder builder, ImmutableArray items, int start) 63 | { 64 | for (int i = start; i < items.Length; i++) 65 | { 66 | builder.Add(items[i]); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/InteropUtilities.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | namespace Microsoft.DiaSymReader.PortablePdb 9 | { 10 | internal static class InteropUtilities 11 | { 12 | public static int StringToBuffer( 13 | string str, 14 | int bufferLength, 15 | out int count, 16 | char[] buffer) 17 | { 18 | // include NUL terminator: 19 | count = str.Length + 1; 20 | 21 | if (buffer == null) 22 | { 23 | return HResult.S_OK; 24 | } 25 | 26 | if (count > bufferLength) 27 | { 28 | count = 0; 29 | return HResult.E_OUTOFMEMORY; 30 | } 31 | 32 | str.CopyTo(0, buffer, 0, str.Length); 33 | buffer[str.Length] = '\0'; 34 | 35 | return HResult.S_OK; 36 | } 37 | 38 | public static int BytesToBuffer( 39 | byte[] bytes, 40 | int bufferLength, 41 | out int count, 42 | byte[] buffer) 43 | { 44 | count = bytes.Length; 45 | 46 | if (buffer == null) 47 | { 48 | return HResult.S_OK; 49 | } 50 | 51 | if (count > bufferLength) 52 | { 53 | count = 0; 54 | return HResult.E_OUTOFMEMORY; 55 | } 56 | 57 | Buffer.BlockCopy(bytes, 0, buffer, 0, count); 58 | return HResult.S_OK; 59 | } 60 | 61 | internal static void TransferOwnershipOrRelease(ref object? obj, object? newOwner) 62 | { 63 | if (newOwner != null) 64 | { 65 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 66 | { 67 | if (obj != null && Marshal.IsComObject(obj)) 68 | { 69 | Marshal.ReleaseComObject(obj); 70 | } 71 | } 72 | 73 | obj = null; 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/KeyValuePair.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.DiaSymReader.PortablePdb 8 | { 9 | internal static class KeyValuePair 10 | { 11 | public static KeyValuePair Create(K key, V value) 12 | { 13 | return new KeyValuePair(key, value); 14 | } 15 | 16 | public static void Deconstruct(this KeyValuePair pair, out K key, out V value) 17 | { 18 | key = pair.Key; 19 | value = pair.Value; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/LazyMetadataImport.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | using System.Runtime.InteropServices; 8 | using System.Threading; 9 | 10 | namespace Microsoft.DiaSymReader.PortablePdb 11 | { 12 | internal sealed class LazyMetadataImport : IDisposable 13 | { 14 | private MetadataImport? _lazyMetadataImport; 15 | private readonly IMetadataImportProvider? _metadataImportProvider; 16 | 17 | public LazyMetadataImport(MetadataImport metadataImport) 18 | { 19 | _lazyMetadataImport = metadataImport; 20 | } 21 | 22 | public LazyMetadataImport(IMetadataImportProvider metadataImportProvider) 23 | { 24 | _metadataImportProvider = metadataImportProvider; 25 | } 26 | 27 | public MetadataImport GetMetadataImport() 28 | { 29 | if (_lazyMetadataImport == null) 30 | { 31 | Debug.Assert(_metadataImportProvider != null, "MetadataImport disposed"); 32 | 33 | var import = MetadataImport.FromObject(_metadataImportProvider.GetMetadataImport()) ?? 34 | throw new InvalidOperationException(); 35 | 36 | Interlocked.CompareExchange(ref _lazyMetadataImport, import, null); 37 | } 38 | 39 | return _lazyMetadataImport; 40 | } 41 | 42 | public void Dispose() 43 | { 44 | var import = Interlocked.Exchange(ref _lazyMetadataImport, null); 45 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 46 | { 47 | if (import != null && Marshal.IsComObject(import)) 48 | { 49 | Marshal.ReleaseComObject(import); 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/MetadataUtilities.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics; 8 | using System.Reflection.Metadata; 9 | using System.Reflection.Metadata.Ecma335; 10 | 11 | namespace Microsoft.DiaSymReader.PortablePdb 12 | { 13 | internal static class MetadataUtilities 14 | { 15 | public const SignatureTypeCode SignatureTypeCode_ValueType = (SignatureTypeCode)0x11; 16 | public const SignatureTypeCode SignatureTypeCode_Class = (SignatureTypeCode)0x12; 17 | public static int MethodDefToken(int rowId) => 0x06000000 | rowId; 18 | public static int GetRowId(int token) => token & 0xffffff; 19 | public static bool IsMethodToken(int token) => unchecked((uint)token) >> 24 == 0x06; 20 | 21 | // Custom Attribute kinds: 22 | public static readonly Guid MethodSteppingInformationBlobId = new Guid("54FD2AC5-E925-401A-9C2A-F94F171072F8"); 23 | public static readonly Guid VbDefaultNamespaceId = new Guid("58b2eab6-209f-4e4e-a22c-b2d0f910c782"); 24 | public static readonly Guid EmbeddedSourceId = new Guid("0E8A571B-6926-466E-B4AD-8AB04611F5FE"); 25 | public static readonly Guid SourceLinkId = new Guid("CC110556-A091-4D38-9FEC-25AB9A351A6A"); 26 | 27 | internal static int GetTypeDefOrRefOrSpecCodedIndex(EntityHandle typeHandle) 28 | { 29 | int tag = 0; 30 | switch (typeHandle.Kind) 31 | { 32 | case HandleKind.TypeDefinition: 33 | tag = 0; 34 | break; 35 | 36 | case HandleKind.TypeReference: 37 | tag = 1; 38 | break; 39 | 40 | case HandleKind.TypeSpecification: 41 | tag = 2; 42 | break; 43 | } 44 | 45 | return (MetadataTokens.GetRowNumber(typeHandle) << 2) | tag; 46 | } 47 | 48 | internal static BlobHandle GetCustomDebugInformation(this MetadataReader reader, EntityHandle parent, Guid kind) 49 | { 50 | foreach (var cdiHandle in reader.GetCustomDebugInformation(parent)) 51 | { 52 | var cdi = reader.GetCustomDebugInformation(cdiHandle); 53 | if (reader.GetGuid(cdi.Kind) == kind) 54 | { 55 | // return the first record 56 | return cdi.Value; 57 | } 58 | } 59 | 60 | return default; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/Nullable.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the.NET Foundation under one or more agreements. 2 | // The.NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | 6 | #if !NET 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] 11 | internal sealed class NotNullWhenAttribute : Attribute 12 | { 13 | public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; 14 | public bool ReturnValue { get; } 15 | } 16 | 17 | [AttributeUsage(AttributeTargets.Method, Inherited = false)] 18 | internal sealed class DoesNotReturnAttribute : Attribute 19 | { } 20 | 21 | [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] 22 | internal sealed class DoesNotReturnIfAttribute : Attribute 23 | { 24 | public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue; 25 | public bool ParameterValue { get; } 26 | } 27 | 28 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] 29 | internal sealed class MemberNotNullAttribute : Attribute 30 | { 31 | public MemberNotNullAttribute(string member) => Members = new[] { member }; 32 | public MemberNotNullAttribute(params string[] members) => Members = members; 33 | public string[] Members { get; } 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/ReadOnlyInteropStream.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | using System.IO; 8 | using System.Runtime.InteropServices.ComTypes; 9 | 10 | namespace Microsoft.DiaSymReader.PortablePdb 11 | { 12 | internal sealed class ReadOnlyInteropStream : Stream 13 | { 14 | private readonly IStream _stream; 15 | 16 | public ReadOnlyInteropStream(IStream stream) 17 | { 18 | Debug.Assert(stream != null); 19 | _stream = stream; 20 | } 21 | 22 | public override bool CanRead => true; 23 | public override bool CanSeek => true; 24 | public override bool CanWrite => false; 25 | 26 | public unsafe override int Read(byte[] buffer, int offset, int count) 27 | { 28 | int bytesRead = 0; 29 | _stream.Read(buffer, count, (IntPtr)(&bytesRead)); 30 | return bytesRead; 31 | } 32 | 33 | public override long Position 34 | { 35 | get 36 | { 37 | unsafe 38 | { 39 | long position; 40 | _stream.Seek(0, (int)SeekOrigin.Current, (IntPtr)(&position)); 41 | return position; 42 | } 43 | } 44 | 45 | set 46 | { 47 | Seek(value, SeekOrigin.Begin); 48 | } 49 | } 50 | 51 | public unsafe override long Seek(long offset, SeekOrigin origin) 52 | { 53 | long position; 54 | _stream.Seek(0, (int)origin, (IntPtr)(&position)); 55 | return position; 56 | } 57 | 58 | public override long Length 59 | { 60 | get 61 | { 62 | const int STATFLAG_NONAME = 1; 63 | 64 | System.Runtime.InteropServices.ComTypes.STATSTG stats; 65 | _stream.Stat(out stats, STATFLAG_NONAME); 66 | return stats.cbSize; 67 | } 68 | } 69 | 70 | public override void Flush() { } 71 | public override void SetLength(long value) { throw new NotSupportedException(); } 72 | public override void Write(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Diagnostics; 6 | using System.IO; 7 | 8 | namespace Microsoft.DiaSymReader.PortablePdb 9 | { 10 | internal static class StreamExtensions 11 | { 12 | /// 13 | /// Attempts to read all of the requested bytes from the stream into the buffer 14 | /// 15 | /// 16 | /// The number of bytes read. Less than will 17 | /// only be returned if the end of stream is reached before all bytes can be read. 18 | /// 19 | /// 20 | /// Unlike it is not guaranteed that 21 | /// the stream position or the output buffer will be unchanged if an exception is 22 | /// returned. 23 | /// 24 | internal static int TryReadAll(this Stream stream, byte[] buffer, int offset, int count) 25 | { 26 | // The implementations for many streams, e.g. FileStream, allows 0 bytes to be 27 | // read and returns 0, but the documentation for Stream.Read states that 0 is 28 | // only returned when the end of the stream has been reached. Rather than deal 29 | // with this contradiction, let's just never pass a count of 0 bytes 30 | Debug.Assert(count > 0); 31 | 32 | int totalBytesRead; 33 | int bytesRead; 34 | for (totalBytesRead = 0; totalBytesRead < count; totalBytesRead += bytesRead) 35 | { 36 | // Note: Don't attempt to save state in-between calls to .Read as it would 37 | // require a possibly massive intermediate buffer array 38 | bytesRead = stream.Read(buffer, 39 | offset + totalBytesRead, 40 | count - totalBytesRead); 41 | if (bytesRead == 0) 42 | { 43 | break; 44 | } 45 | } 46 | return totalBytesRead; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/TupleElementNamesAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace System.Runtime.CompilerServices 8 | { 9 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Event)] 10 | internal sealed class TupleElementNamesAttribute : Attribute 11 | { 12 | public IList TransformNames { get; } 13 | 14 | public TupleElementNamesAttribute(string[] transformNames) 15 | { 16 | TransformNames = transformNames; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.DiaSymReader.PortablePdb/Utilities/ValueTuple.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using System.Numerics.Hashing; 8 | using System.Runtime.InteropServices; 9 | 10 | #if !NETSTANDARD2_0_OR_GREATER && !NET 11 | 12 | namespace System 13 | { 14 | internal struct ValueTuple 15 | { 16 | public static ValueTuple Create(T1 item1, T2 item2) => 17 | new ValueTuple(item1, item2); 18 | } 19 | 20 | [StructLayout(LayoutKind.Auto)] 21 | internal struct ValueTuple : IEquatable> 22 | { 23 | public T1 Item1; 24 | public T2 Item2; 25 | 26 | public ValueTuple(T1 item1, T2 item2) 27 | { 28 | Item1 = item1; 29 | Item2 = item2; 30 | } 31 | 32 | public override bool Equals(object obj) => 33 | obj is ValueTuple && Equals((ValueTuple)obj); 34 | 35 | public bool Equals(ValueTuple other) => 36 | EqualityComparer.Default.Equals(Item1, other.Item1) && 37 | EqualityComparer.Default.Equals(Item2, other.Item2); 38 | 39 | internal static int CombineHashCodes(int h1, int h2) => 40 | HashHelpers.Combine(HashHelpers.Combine(HashHelpers.RandomSeed, h1), h2); 41 | 42 | public override int GetHashCode() => 43 | CombineHashCodes(Item1?.GetHashCode() ?? 0, Item2?.GetHashCode() ?? 0); 44 | 45 | private int GetHashCodeCore(IEqualityComparer comparer) => 46 | CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2)); 47 | 48 | public override string ToString() => 49 | "(" + Item1?.ToString() + ", " + Item2?.ToString() + ")"; 50 | } 51 | } 52 | 53 | #endif -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where the 11 | # symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | 15 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 16 | "$scriptroot/eng/common/build.sh" --test $@ --------------------------------------------------------------------------------