diff --git a/eng/Version.Details.props b/eng/Version.Details.props index afdfd5818acf34..a35525c98f82e7 100644 --- a/eng/Version.Details.props +++ b/eng/Version.Details.props @@ -6,86 +6,86 @@ This file should be imported by eng/Versions.props - 5.7.0-1.26211.102 - 5.7.0-1.26211.102 - 5.7.0-1.26211.102 - 11.0.100-preview.4.26211.102 - 11.0.100-preview.4.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 0.11.5-preview.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 11.0.0-beta.26211.102 - 3.2.2-beta.26211.102 - 2.9.3-beta.26211.102 - 11.0.0-beta.26211.102 - 5.7.0-1.26211.102 - 11.0.0-preview.4.26211.102 - 11.0.100-preview.4.26211.102 - 11.0.0-preview.4.26211.102 - 11.0.0-preview.4.26211.102 - 7.6.0-rc.21202 - 7.6.0-rc.21202 - 7.6.0-rc.21202 - 7.6.0-rc.21202 - 11.0.0-preview.4.26211.102 - 3.0.0-preview.4.26211.102 - 11.0.0-preview.4.26211.102 - 11.0.0-preview.4.26211.102 - 11.0.0-preview.4.26211.102 + 5.7.0-1.26257.113 + 5.7.0-1.26257.113 + 5.7.0-1.26257.113 + 11.0.100-preview.5.26257.113 + 11.0.100-preview.5.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 0.11.5-preview.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 11.0.0-beta.26257.113 + 3.2.2-beta.26257.113 + 2.9.3-beta.26257.113 + 11.0.0-beta.26257.113 + 5.7.0-1.26257.113 + 11.0.0-preview.5.26257.113 + 11.0.100-preview.5.26257.113 + 11.0.0-preview.5.26257.113 + 11.0.0-preview.5.26257.113 + 7.7.0-rc.25813 + 7.7.0-rc.25813 + 7.7.0-rc.25813 + 7.7.0-rc.25813 + 11.0.0-preview.5.26257.113 + 3.0.0-preview.5.26257.113 + 11.0.0-preview.5.26257.113 + 11.0.0-preview.5.26257.113 + 11.0.0-preview.5.26257.113 11.0.0-alpha.1.26181.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 - 19.1.0-alpha.1.26173.1 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 + 19.1.0-alpha.1.26208.2 - 11.0.0-alpha.1.26173.2 - 11.0.0-alpha.1.26173.2 - 11.0.0-alpha.1.26173.2 - 11.0.0-alpha.1.26173.2 - 11.0.0-alpha.1.26173.2 - 11.0.0-alpha.1.26173.2 - 11.0.0-alpha.1.26173.2 - 11.0.0-alpha.1.26173.2 + 11.0.0-alpha.1.26208.5 + 11.0.0-alpha.1.26208.5 + 11.0.0-alpha.1.26208.5 + 11.0.0-alpha.1.26208.5 + 11.0.0-alpha.1.26208.5 + 11.0.0-alpha.1.26208.5 + 11.0.0-alpha.1.26208.5 + 11.0.0-alpha.1.26208.5 1.0.0-prerelease.26080.1 1.0.0-prerelease.26080.1 diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index ee7fa3d9101fb4..a357698eefc928 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,127 +1,127 @@ - + https://github.com/dotnet/icu 8fe317e707aaa0ab5afeafa926b03cb8deb22d09 - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf https://github.com/dotnet/runtime-assets @@ -175,117 +175,117 @@ https://github.com/dotnet/runtime-assets 509fb52c027cd46fab093f10c89691cda982edc4 - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/llvm-project - adb0185573ea50f6622e29860297b7a3213b1000 + db9a80a3e25e21268d55cf3385298dc03cfbed4d - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf https://github.com/dotnet/xharness @@ -299,9 +299,9 @@ https://github.com/dotnet/xharness 0668c80ec27851f3c7f1b3e4536110a1d39af587 - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf https://dev.azure.com/dnceng/internal/_git/dotnet-optimization @@ -323,29 +323,29 @@ https://github.com/dotnet/runtime-assets 509fb52c027cd46fab093f10c89691cda982edc4 - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf https://dev.azure.com/dnceng/internal/_git/dotnet-optimization @@ -357,53 +357,53 @@ - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/dotnet - 36afe73557f5f93cd7bc827cb644a3ff018eca0b + 0eae08ed2f094f44e0151e4815e7cdd1a334fcdf - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 - + https://github.com/dotnet/node - 0077cd1a0d5bb524db161e5ec289496390c7f5d0 + cfe285c85ac61bde50792e8d516e31b302846f53 https://github.com/dotnet/runtime-assets diff --git a/eng/Versions.props b/eng/Versions.props index 6b58c62b178aa3..e327f7b502100a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -15,7 +15,7 @@ 7.0.20 6.0.36 preview - 4 + 5 false release @@ -152,7 +152,7 @@ 6.0.4 5.0.0 7.0.2 - 13.0.3 + 13.0.4 1.0.2 4.18.4 4.0.722401 diff --git a/eng/common/core-templates/job/job.yml b/eng/common/core-templates/job/job.yml index 748c4f07a64d61..66c7988f222a65 100644 --- a/eng/common/core-templates/job/job.yml +++ b/eng/common/core-templates/job/job.yml @@ -26,12 +26,12 @@ parameters: enablePublishBuildArtifacts: false enablePublishBuildAssets: false enablePublishTestResults: false + enablePublishing: false enableBuildRetry: false mergeTestResults: false testRunTitle: '' testResultsFormat: '' name: '' - componentGovernanceSteps: [] preSteps: [] artifactPublishSteps: [] runAsPublic: false @@ -152,9 +152,6 @@ jobs: - ${{ each step in parameters.steps }}: - ${{ step }} - - ${{ each step in parameters.componentGovernanceSteps }}: - - ${{ step }} - - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - template: /eng/common/core-templates/steps/cleanup-microbuild.yml parameters: diff --git a/eng/common/core-templates/job/publish-build-assets.yml b/eng/common/core-templates/job/publish-build-assets.yml index 9d7490518c48d9..700f7711465883 100644 --- a/eng/common/core-templates/job/publish-build-assets.yml +++ b/eng/common/core-templates/job/publish-build-assets.yml @@ -172,17 +172,18 @@ jobs: targetPath: '$(Build.ArtifactStagingDirectory)/MergedManifest.xml' artifactName: AssetManifests displayName: 'Publish Merged Manifest' - retryCountOnTaskFailure: 10 # for any logs being locked - sbomEnabled: false # we don't need SBOM for logs + retryCountOnTaskFailure: 10 # for any files being locked + isProduction: false # just metadata for publishing - - template: /eng/common/core-templates/steps/publish-build-artifacts.yml + - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml parameters: is1ESPipeline: ${{ parameters.is1ESPipeline }} args: displayName: Publish ReleaseConfigs Artifact - pathToPublish: '$(Build.StagingDirectory)/ReleaseConfigs' - publishLocation: Container + targetPath: '$(Build.StagingDirectory)/ReleaseConfigs' artifactName: ReleaseConfigs + retryCountOnTaskFailure: 10 # for any files being locked + isProduction: false # just metadata for publishing - ${{ if or(eq(parameters.publishAssetsImmediately, 'true'), eq(parameters.isAssetlessBuild, 'true')) }}: - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml @@ -218,4 +219,5 @@ jobs: - template: /eng/common/core-templates/steps/publish-logs.yml parameters: is1ESPipeline: ${{ parameters.is1ESPipeline }} + StageLabel: 'BuildAssetRegistry' JobLabel: 'Publish_Artifacts_Logs' diff --git a/eng/common/core-templates/job/renovate.yml b/eng/common/core-templates/job/renovate.yml index ab233539b5dc24..ff86c80b468902 100644 --- a/eng/common/core-templates/job/renovate.yml +++ b/eng/common/core-templates/job/renovate.yml @@ -135,7 +135,7 @@ jobs: condition: succeededOrFailed() targetPath: $(Build.ArtifactStagingDirectory) artifactName: $(Agent.JobName)_Logs_Attempt$(System.JobAttempt) - sbomEnabled: false + isProduction: false # logs are non-production artifacts steps: - checkout: self diff --git a/eng/common/core-templates/jobs/jobs.yml b/eng/common/core-templates/jobs/jobs.yml index 01ada747665145..cc8cce452786d4 100644 --- a/eng/common/core-templates/jobs/jobs.yml +++ b/eng/common/core-templates/jobs/jobs.yml @@ -43,6 +43,10 @@ parameters: artifacts: {} is1ESPipeline: '' + + # Publishing version w/default. + publishingVersion: 3 + repositoryAlias: self officialBuildId: '' @@ -102,6 +106,7 @@ jobs: parameters: is1ESPipeline: ${{ parameters.is1ESPipeline }} continueOnError: ${{ parameters.continueOnError }} + publishingVersion: ${{ parameters.publishingVersion }} dependsOn: - ${{ if ne(parameters.publishBuildAssetsDependsOn, '') }}: - ${{ each job in parameters.publishBuildAssetsDependsOn }}: diff --git a/eng/common/core-templates/post-build/common-variables.yml b/eng/common/core-templates/post-build/common-variables.yml index d5627a994ae58f..db298ae16bae64 100644 --- a/eng/common/core-templates/post-build/common-variables.yml +++ b/eng/common/core-templates/post-build/common-variables.yml @@ -11,8 +11,6 @@ variables: - name: MaestroApiVersion value: "2020-02-20" - - name: SourceLinkCLIVersion - value: 3.0.0 - name: SymbolToolVersion value: 1.0.1 - name: BinlogToolVersion diff --git a/eng/common/core-templates/post-build/post-build.yml b/eng/common/core-templates/post-build/post-build.yml index 0994189969f32d..8aa86e30491978 100644 --- a/eng/common/core-templates/post-build/post-build.yml +++ b/eng/common/core-templates/post-build/post-build.yml @@ -9,6 +9,7 @@ parameters: default: 3 values: - 3 + - 4 - name: BARBuildId displayName: BAR Build Id @@ -130,16 +131,30 @@ stages: PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} is1ESPipeline: ${{ parameters.is1ESPipeline }} - - task: DownloadBuildArtifacts@0 - displayName: Download Package Artifacts - inputs: - buildType: specific - buildVersionToDownload: specific - project: $(AzDOProjectName) - pipeline: $(AzDOPipelineId) - buildId: $(AzDOBuildId) - artifactName: PackageArtifacts - checkDownloadedFiles: true + - ${{ if ne(parameters.publishingInfraVersion, 4) }}: + - task: DownloadBuildArtifacts@0 + displayName: Download Package Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + artifactName: PackageArtifacts + checkDownloadedFiles: true + - ${{ if eq(parameters.publishingInfraVersion, 4) }}: + - task: DownloadPipelineArtifact@2 + displayName: Download Pipeline Artifacts (V4) + inputs: + itemPattern: '*/packages/**/*.nupkg' + targetPath: '$(Build.ArtifactStagingDirectory)/PipelineArtifactsDownload' + - task: CopyFiles@2 + displayName: Flatten packages to PackageArtifacts + inputs: + SourceFolder: '$(Build.ArtifactStagingDirectory)/PipelineArtifactsDownload' + Contents: '**/*.nupkg' + TargetFolder: '$(Build.ArtifactStagingDirectory)/PackageArtifacts' + flattenFolders: true - task: PowerShell@2 displayName: Validate @@ -173,16 +188,30 @@ stages: PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} is1ESPipeline: ${{ parameters.is1ESPipeline }} - - task: DownloadBuildArtifacts@0 - displayName: Download Package Artifacts - inputs: - buildType: specific - buildVersionToDownload: specific - project: $(AzDOProjectName) - pipeline: $(AzDOPipelineId) - buildId: $(AzDOBuildId) - artifactName: PackageArtifacts - checkDownloadedFiles: true + - ${{ if ne(parameters.publishingInfraVersion, 4) }}: + - task: DownloadBuildArtifacts@0 + displayName: Download Package Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + artifactName: PackageArtifacts + checkDownloadedFiles: true + - ${{ if eq(parameters.publishingInfraVersion, 4) }}: + - task: DownloadPipelineArtifact@2 + displayName: Download Pipeline Artifacts (V4) + inputs: + itemPattern: '*/packages/**/*.nupkg' + targetPath: '$(Build.ArtifactStagingDirectory)/PipelineArtifactsDownload' + - task: CopyFiles@2 + displayName: Flatten packages to PackageArtifacts + inputs: + SourceFolder: '$(Build.ArtifactStagingDirectory)/PipelineArtifactsDownload' + Contents: '**/*.nupkg' + TargetFolder: '$(Build.ArtifactStagingDirectory)/PackageArtifacts' + flattenFolders: true # This is necessary whenever we want to publish/restore to an AzDO private feed # Since sdk-task.ps1 tries to restore packages we need to do this authentication here @@ -196,7 +225,7 @@ stages: displayName: Validate inputs: filePath: eng\common\sdk-task.ps1 - arguments: -task SigningValidation -restore + arguments: -task SigningValidation -restore -msbuildEngine dotnet /p:PackageBasePath='$(Build.ArtifactStagingDirectory)/PackageArtifacts' /p:SignCheckExclusionsFile='$(System.DefaultWorkingDirectory)/eng/SignCheckExclusionsFile.txt' ${{ parameters.signingValidationAdditionalParameters }} @@ -208,53 +237,20 @@ stages: JobLabel: 'Signing' BinlogToolVersion: $(BinlogToolVersion) - - job: - displayName: SourceLink Validation - condition: eq( ${{ parameters.enableSourceLinkValidation }}, 'true') - pool: - # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) - ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: - name: AzurePipelines-EO - image: 1ESPT-Windows2025 - demands: Cmd - os: windows - # If it's not devdiv, it's dnceng - ${{ else }}: - ${{ if eq(parameters.is1ESPipeline, true) }}: - name: $(DncEngInternalBuildPool) - image: windows.vs2026.amd64 - os: windows - ${{ else }}: - name: $(DncEngInternalBuildPool) - demands: ImageOverride -equals windows.vs2026.amd64 - steps: - - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml - parameters: - BARBuildId: ${{ parameters.BARBuildId }} - PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} - is1ESPipeline: ${{ parameters.is1ESPipeline }} - - - task: DownloadBuildArtifacts@0 - displayName: Download Blob Artifacts - inputs: - buildType: specific - buildVersionToDownload: specific - project: $(AzDOProjectName) - pipeline: $(AzDOPipelineId) - buildId: $(AzDOBuildId) - artifactName: BlobArtifacts - checkDownloadedFiles: true - - - task: PowerShell@2 - displayName: Validate - inputs: - filePath: $(System.DefaultWorkingDirectory)/eng/common/post-build/sourcelink-validation.ps1 - arguments: -InputPath $(Build.ArtifactStagingDirectory)/BlobArtifacts/ - -ExtractPath $(Agent.BuildDirectory)/Extract/ - -GHRepoName $(Build.Repository.Name) - -GHCommit $(Build.SourceVersion) - -SourcelinkCliVersion $(SourceLinkCLIVersion) - continueOnError: true + # SourceLink validation has been removed — the underlying CLI tool + # (targeting netcoreapp2.1) has not functioned for years. + # The enableSourceLinkValidation parameter is kept but ignored so + # existing pipelines that pass it are not broken. + # See https://github.com/dotnet/arcade/issues/16647 + - ${{ if eq(parameters.enableSourceLinkValidation, 'true') }}: + - job: + displayName: 'SourceLink Validation Removed - please remove enableSourceLinkValidation from your pipeline' + pool: server + steps: + - task: Delay@1 + displayName: 'Warning: SourceLink validation removed (see https://github.com/dotnet/arcade/issues/16647)' + inputs: + delayForMinutes: '0' - ${{ if ne(parameters.publishAssetsImmediately, 'true') }}: - stage: publish_using_darc @@ -317,7 +313,7 @@ stages: scriptPath: $(System.DefaultWorkingDirectory)/eng/common/post-build/publish-using-darc.ps1 arguments: > -BuildId $(BARBuildId) - -PublishingInfraVersion ${{ parameters.publishingInfraVersion }} + -PublishingInfraVersion 3 -AzdoToken '$(System.AccessToken)' -WaitPublishingFinish true -RequireDefaultChannels ${{ parameters.requireDefaultChannels }} diff --git a/eng/common/core-templates/post-build/setup-maestro-vars.yml b/eng/common/core-templates/post-build/setup-maestro-vars.yml index a7abd58c4bb609..6dfa99ec5e37fb 100644 --- a/eng/common/core-templates/post-build/setup-maestro-vars.yml +++ b/eng/common/core-templates/post-build/setup-maestro-vars.yml @@ -8,12 +8,11 @@ steps: - 'Illegal entry point, is1ESPipeline is not defined. Repository yaml should not directly reference templates in core-templates folder.': error - ${{ if eq(coalesce(parameters.PromoteToChannelIds, 0), 0) }}: - - task: DownloadBuildArtifacts@0 + - task: DownloadPipelineArtifact@2 displayName: Download Release Configs inputs: - buildType: current artifactName: ReleaseConfigs - checkDownloadedFiles: true + targetPath: '$(Build.StagingDirectory)/ReleaseConfigs' - task: AzureCLI@2 name: setReleaseVars diff --git a/eng/common/core-templates/steps/component-governance.yml b/eng/common/core-templates/steps/component-governance.yml deleted file mode 100644 index cf0649aa95653f..00000000000000 --- a/eng/common/core-templates/steps/component-governance.yml +++ /dev/null @@ -1,16 +0,0 @@ -parameters: - disableComponentGovernance: false - componentGovernanceIgnoreDirectories: '' - is1ESPipeline: false - displayName: 'Component Detection' - -steps: -- ${{ if eq(parameters.disableComponentGovernance, 'true') }}: - - script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true" - displayName: Set skipComponentGovernanceDetection variable -- ${{ if ne(parameters.disableComponentGovernance, 'true') }}: - - task: ComponentGovernanceComponentDetection@0 - continueOnError: true - displayName: ${{ parameters.displayName }} - inputs: - ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} diff --git a/eng/common/core-templates/steps/generate-sbom.yml b/eng/common/core-templates/steps/generate-sbom.yml index 003f7eae0fa5c9..aad0a8aeda33d9 100644 --- a/eng/common/core-templates/steps/generate-sbom.yml +++ b/eng/common/core-templates/steps/generate-sbom.yml @@ -1,54 +1,14 @@ -# BuildDropPath - The root folder of the drop directory for which the manifest file will be generated. -# PackageName - The name of the package this SBOM represents. -# PackageVersion - The version of the package this SBOM represents. -# ManifestDirPath - The path of the directory where the generated manifest files will be placed -# IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector. - parameters: - PackageVersion: 11.0.0 - BuildDropPath: '$(System.DefaultWorkingDirectory)/artifacts' - PackageName: '.NET' - ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom - IgnoreDirectories: '' - sbomContinueOnError: true - is1ESPipeline: false - # disable publishArtifacts if some other step is publishing the artifacts (like job.yml). - publishArtifacts: true + PackageVersion: unused + BuildDropPath: unused + PackageName: unused + ManifestDirPath: unused + IgnoreDirectories: unused + sbomContinueOnError: unused + is1ESPipeline: unused + publishArtifacts: unused steps: -- task: PowerShell@2 - displayName: Prep for SBOM generation in (Non-linux) - condition: or(eq(variables['Agent.Os'], 'Windows_NT'), eq(variables['Agent.Os'], 'Darwin')) - inputs: - filePath: ./eng/common/generate-sbom-prep.ps1 - arguments: ${{parameters.manifestDirPath}} - -# Chmodding is a workaround for https://github.com/dotnet/arcade/issues/8461 - script: | - chmod +x ./eng/common/generate-sbom-prep.sh - ./eng/common/generate-sbom-prep.sh ${{parameters.manifestDirPath}} - displayName: Prep for SBOM generation in (Linux) - condition: eq(variables['Agent.Os'], 'Linux') - continueOnError: ${{ parameters.sbomContinueOnError }} - -- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 - displayName: 'Generate SBOM manifest' - continueOnError: ${{ parameters.sbomContinueOnError }} - inputs: - PackageName: ${{ parameters.packageName }} - BuildDropPath: ${{ parameters.buildDropPath }} - PackageVersion: ${{ parameters.packageVersion }} - ManifestDirPath: ${{ parameters.manifestDirPath }}/$(ARTIFACT_NAME) - ${{ if ne(parameters.IgnoreDirectories, '') }}: - AdditionalComponentDetectorArgs: '--IgnoreDirectories ${{ parameters.IgnoreDirectories }}' - -- ${{ if eq(parameters.publishArtifacts, 'true')}}: - - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml - parameters: - is1ESPipeline: ${{ parameters.is1ESPipeline }} - args: - displayName: Publish SBOM manifest - continueOnError: ${{parameters.sbomContinueOnError}} - targetPath: '${{ parameters.manifestDirPath }}' - artifactName: $(ARTIFACT_NAME) - + echo "##vso[task.logissue type=warning]Including generate-sbom.yml is deprecated, SBOM generation is handled 1ES PT now. Remove this include." + displayName: Issue generate-sbom.yml deprecation warning diff --git a/eng/common/core-templates/steps/publish-logs.yml b/eng/common/core-templates/steps/publish-logs.yml index a9ea99ba6aaa5c..84a1922c73f392 100644 --- a/eng/common/core-templates/steps/publish-logs.yml +++ b/eng/common/core-templates/steps/publish-logs.yml @@ -50,13 +50,15 @@ steps: TargetFolder: '$(Build.ArtifactStagingDirectory)/PostBuildLogs' condition: always() -- template: /eng/common/core-templates/steps/publish-build-artifacts.yml +- template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml parameters: is1ESPipeline: ${{ parameters.is1ESPipeline }} args: displayName: Publish Logs - pathToPublish: '$(Build.ArtifactStagingDirectory)/PostBuildLogs' - publishLocation: Container - artifactName: PostBuildLogs + targetPath: '$(Build.ArtifactStagingDirectory)/PostBuildLogs' + artifactName: PostBuildLogs_${{ parameters.StageLabel }}_${{ parameters.JobLabel }}_Attempt$(System.JobAttempt) continueOnError: true condition: always() + retryCountOnTaskFailure: 10 # for any files being locked + isProduction: false # logs are non-production artifacts + diff --git a/eng/common/core-templates/steps/source-build.yml b/eng/common/core-templates/steps/source-build.yml index acf16ed34963fa..b75f59c428d410 100644 --- a/eng/common/core-templates/steps/source-build.yml +++ b/eng/common/core-templates/steps/source-build.yml @@ -62,4 +62,4 @@ steps: artifactName: BuildLogs_SourceBuild_${{ parameters.platform.name }}_Attempt$(System.JobAttempt) continueOnError: true condition: succeededOrFailed() - sbomEnabled: false # we don't need SBOM for logs + isProduction: false # logs are non-production artifacts diff --git a/eng/common/cross/build-android-rootfs.sh b/eng/common/cross/build-android-rootfs.sh index 09d65eaff91237..fbd8d80848a6ce 100755 --- a/eng/common/cross/build-android-rootfs.sh +++ b/eng/common/cross/build-android-rootfs.sh @@ -21,7 +21,7 @@ usage() exit 1 } -__ApiLevel=28 # The minimum platform for arm64 is API level 24 but the minimum version that supports glob(3) is 28. See $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/glob.h +__ApiLevel=28 # The minimum platform for arm64 is API level 21 but the minimum version that support glob(3) is 28. See $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/glob.h __BuildArch=arm64 __AndroidArch=aarch64 __AndroidToolchain=aarch64-linux-android diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake index 99d6dfe82dde38..ff2dfdb4a5bf60 100644 --- a/eng/common/cross/toolchain.cmake +++ b/eng/common/cross/toolchain.cmake @@ -225,19 +225,13 @@ elseif(ILLUMOS) locate_toolchain_exec(g++ CMAKE_CXX_COMPILER) elseif(HAIKU) set(CMAKE_SYSROOT "${CROSS_ROOTFS}") + set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};${CROSS_ROOTFS}/cross-tools-x86_64/bin") set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}") set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp") set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp") - if ($ENV{CCC_CC} MATCHES ".*gcc.*") - set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};${CROSS_ROOTFS}/cross-tools-x86_64/bin") - locate_toolchain_exec(gcc CMAKE_C_COMPILER) - locate_toolchain_exec(g++ CMAKE_CXX_COMPILER) - else() - set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/cross-tools-x86_64") - set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/cross-tools-x86_64") - set(CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/cross-tools-x86_64") - endif() + locate_toolchain_exec(gcc CMAKE_C_COMPILER) + locate_toolchain_exec(g++ CMAKE_CXX_COMPILER) # let CMake set up the correct search paths include(Platform/Haiku) diff --git a/eng/common/darc-init.ps1 b/eng/common/darc-init.ps1 index e3374310563549..a5be41db6906ca 100644 --- a/eng/common/darc-init.ps1 +++ b/eng/common/darc-init.ps1 @@ -29,11 +29,11 @@ function InstallDarcCli ($darcVersion, $toolpath) { Write-Host "Installing Darc CLI version $darcVersion..." Write-Host 'You may need to restart your command window if this is the first dotnet tool you have installed.' if (-not $toolpath) { - Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity -g" - & "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g + Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --source '$arcadeServicesSource' -v $verbosity -g" + & "$dotnet" tool install $darcCliPackageName --version $darcVersion --source "$arcadeServicesSource" -v $verbosity -g }else { - Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity --tool-path '$toolpath'" - & "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath" + Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --source '$arcadeServicesSource' -v $verbosity --tool-path '$toolpath'" + & "$dotnet" tool install $darcCliPackageName --version $darcVersion --source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath" } } diff --git a/eng/common/darc-init.sh b/eng/common/darc-init.sh index 9f5ad6b763b5df..b56d40e5706cc3 100755 --- a/eng/common/darc-init.sh +++ b/eng/common/darc-init.sh @@ -73,9 +73,9 @@ function InstallDarcCli { echo "Installing Darc CLI version $darcVersion..." echo "You may need to restart your command shell if this is the first dotnet tool you have installed." if [ -z "$toolpath" ]; then - echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g) + echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --source "$arcadeServicesSource" -v $verbosity -g) else - echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath") + echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath") fi } diff --git a/eng/common/generate-sbom-prep.ps1 b/eng/common/generate-sbom-prep.ps1 deleted file mode 100644 index a0c7d792a76fbe..00000000000000 --- a/eng/common/generate-sbom-prep.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -Param( - [Parameter(Mandatory=$true)][string] $ManifestDirPath # Manifest directory where sbom will be placed -) - -. $PSScriptRoot\pipeline-logging-functions.ps1 - -# Normally - we'd listen to the manifest path given, but 1ES templates will overwrite if this level gets uploaded directly -# with their own overwriting ours. So we create it as a sub directory of the requested manifest path. -$ArtifactName = "${env:SYSTEM_STAGENAME}_${env:AGENT_JOBNAME}_SBOM" -$SafeArtifactName = $ArtifactName -replace '["/:<>\\|?@*"() ]', '_' -$SbomGenerationDir = Join-Path $ManifestDirPath $SafeArtifactName - -Write-Host "Artifact name before : $ArtifactName" -Write-Host "Artifact name after : $SafeArtifactName" - -Write-Host "Creating dir $ManifestDirPath" - -# create directory for sbom manifest to be placed -if (!(Test-Path -path $SbomGenerationDir)) -{ - New-Item -ItemType Directory -path $SbomGenerationDir - Write-Host "Successfully created directory $SbomGenerationDir" -} -else{ - Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." -} - -Write-Host "Updating artifact name" -Write-Host "##vso[task.setvariable variable=ARTIFACT_NAME]$SafeArtifactName" diff --git a/eng/common/generate-sbom-prep.sh b/eng/common/generate-sbom-prep.sh deleted file mode 100644 index b8ecca72bbf506..00000000000000 --- a/eng/common/generate-sbom-prep.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -source="${BASH_SOURCE[0]}" - -# resolve $SOURCE until the file is no longer a symlink -while [[ -h $source ]]; do - scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" - source="$(readlink "$source")" - - # if $source was a relative symlink, we need to resolve it relative to the path where the - # symlink file was located - [[ $source != /* ]] && source="$scriptroot/$source" -done -scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" -. $scriptroot/pipeline-logging-functions.sh - - -# replace all special characters with _, some builds use special characters like : in Agent.Jobname, that is not a permissible name while uploading artifacts. -artifact_name=$SYSTEM_STAGENAME"_"$AGENT_JOBNAME"_SBOM" -safe_artifact_name="${artifact_name//["/:<>\\|?@*$" ]/_}" -manifest_dir=$1 - -# Normally - we'd listen to the manifest path given, but 1ES templates will overwrite if this level gets uploaded directly -# with their own overwriting ours. So we create it as a sub directory of the requested manifest path. -sbom_generation_dir="$manifest_dir/$safe_artifact_name" - -if [ ! -d "$sbom_generation_dir" ] ; then - mkdir -p "$sbom_generation_dir" - echo "Sbom directory created." $sbom_generation_dir -else - Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." -fi - -echo "Artifact name before : "$artifact_name -echo "Artifact name after : "$safe_artifact_name -export ARTIFACT_NAME=$safe_artifact_name -echo "##vso[task.setvariable variable=ARTIFACT_NAME]$safe_artifact_name" - -exit 0 diff --git a/eng/common/post-build/redact-logs.ps1 b/eng/common/post-build/redact-logs.ps1 index fc0218a013d16b..672f4e2652edb5 100644 --- a/eng/common/post-build/redact-logs.ps1 +++ b/eng/common/post-build/redact-logs.ps1 @@ -49,8 +49,8 @@ try { Write-Host "Installing Binlog redactor CLI..." Write-Host "'$dotnet' new tool-manifest" & "$dotnet" new tool-manifest - Write-Host "'$dotnet' tool install $packageName --local --add-source '$PackageFeed' -v $verbosity --version $BinlogToolVersion" - & "$dotnet" tool install $packageName --local --add-source "$PackageFeed" -v $verbosity --version $BinlogToolVersion + Write-Host "'$dotnet' tool install $packageName --local --source '$PackageFeed' -v $verbosity --version $BinlogToolVersion" + & "$dotnet" tool install $packageName --local --source "$PackageFeed" -v $verbosity --version $BinlogToolVersion if (Test-Path $TokensFilePath) { Write-Host "Adding additional sensitive data for redaction from file: " $TokensFilePath diff --git a/eng/common/post-build/sourcelink-validation.ps1 b/eng/common/post-build/sourcelink-validation.ps1 deleted file mode 100644 index 1976ef70fb8508..00000000000000 --- a/eng/common/post-build/sourcelink-validation.ps1 +++ /dev/null @@ -1,327 +0,0 @@ -param( - [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where Symbols.NuGet packages to be checked are stored - [Parameter(Mandatory=$true)][string] $ExtractPath, # Full path to directory where the packages will be extracted during validation - [Parameter(Mandatory=$false)][string] $GHRepoName, # GitHub name of the repo including the Org. E.g., dotnet/arcade - [Parameter(Mandatory=$false)][string] $GHCommit, # GitHub commit SHA used to build the packages - [Parameter(Mandatory=$true)][string] $SourcelinkCliVersion # Version of SourceLink CLI to use -) - -$ErrorActionPreference = 'Stop' -Set-StrictMode -Version 2.0 - -# `tools.ps1` checks $ci to perform some actions. Since the post-build -# scripts don't necessarily execute in the same agent that run the -# build.ps1/sh script this variable isn't automatically set. -$ci = $true -$disableConfigureToolsetImport = $true -. $PSScriptRoot\..\tools.ps1 - -# Cache/HashMap (File -> Exist flag) used to consult whether a file exist -# in the repository at a specific commit point. This is populated by inserting -# all files present in the repo at a specific commit point. -$global:RepoFiles = @{} - -# Maximum number of jobs to run in parallel -$MaxParallelJobs = 16 - -$MaxRetries = 5 -$RetryWaitTimeInSeconds = 30 - -# Wait time between check for system load -$SecondsBetweenLoadChecks = 10 - -if (!$InputPath -or !(Test-Path $InputPath)){ - Write-Host "No files to validate." - ExitWithExitCode 0 -} - -$ValidatePackage = { - param( - [string] $PackagePath # Full path to a Symbols.NuGet package - ) - - . $using:PSScriptRoot\..\tools.ps1 - - # Ensure input file exist - if (!(Test-Path $PackagePath)) { - Write-Host "Input file does not exist: $PackagePath" - return [pscustomobject]@{ - result = 1 - packagePath = $PackagePath - } - } - - # Extensions for which we'll look for SourceLink information - # For now we'll only care about Portable & Embedded PDBs - $RelevantExtensions = @('.dll', '.exe', '.pdb') - - Write-Host -NoNewLine 'Validating ' ([System.IO.Path]::GetFileName($PackagePath)) '...' - - $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) - $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageId - $FailedFiles = 0 - - Add-Type -AssemblyName System.IO.Compression.FileSystem - - [System.IO.Directory]::CreateDirectory($ExtractPath) | Out-Null - - try { - $zip = [System.IO.Compression.ZipFile]::OpenRead($PackagePath) - - $zip.Entries | - Where-Object {$RelevantExtensions -contains [System.IO.Path]::GetExtension($_.Name)} | - ForEach-Object { - $FileName = $_.FullName - $Extension = [System.IO.Path]::GetExtension($_.Name) - $FakeName = -Join((New-Guid), $Extension) - $TargetFile = Join-Path -Path $ExtractPath -ChildPath $FakeName - - # We ignore resource DLLs - if ($FileName.EndsWith('.resources.dll')) { - return [pscustomobject]@{ - result = 0 - packagePath = $PackagePath - } - } - - [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile, $true) - - $ValidateFile = { - param( - [string] $FullPath, # Full path to the module that has to be checked - [string] $RealPath, - [ref] $FailedFiles - ) - - $sourcelinkExe = "$env:USERPROFILE\.dotnet\tools" - $sourcelinkExe = Resolve-Path "$sourcelinkExe\sourcelink.exe" - $SourceLinkInfos = & $sourcelinkExe print-urls $FullPath | Out-String - - if ($LASTEXITCODE -eq 0 -and -not ([string]::IsNullOrEmpty($SourceLinkInfos))) { - $NumFailedLinks = 0 - - # We only care about Http addresses - $Matches = (Select-String '(http[s]?)(:\/\/)([^\s,]+)' -Input $SourceLinkInfos -AllMatches).Matches - - if ($Matches.Count -ne 0) { - $Matches.Value | - ForEach-Object { - $Link = $_ - $CommitUrl = "https://raw.githubusercontent.com/${using:GHRepoName}/${using:GHCommit}/" - - $FilePath = $Link.Replace($CommitUrl, "") - $Status = 200 - $Cache = $using:RepoFiles - - $attempts = 0 - - while ($attempts -lt $using:MaxRetries) { - if ( !($Cache.ContainsKey($FilePath)) ) { - try { - $Uri = $Link -as [System.URI] - - if ($Link -match "submodules") { - # Skip submodule links until sourcelink properly handles submodules - $Status = 200 - } - elseif ($Uri.AbsoluteURI -ne $null -and ($Uri.Host -match 'github' -or $Uri.Host -match 'githubusercontent')) { - # Only GitHub links are valid - $Status = (Invoke-WebRequest -Uri $Link -UseBasicParsing -Method HEAD -TimeoutSec 5).StatusCode - } - else { - # If it's not a github link, we want to break out of the loop and not retry. - $Status = 0 - $attempts = $using:MaxRetries - } - } - catch { - Write-Host $_ - $Status = 0 - } - } - - if ($Status -ne 200) { - $attempts++ - - if ($attempts -lt $using:MaxRetries) - { - $attemptsLeft = $using:MaxRetries - $attempts - Write-Warning "Download failed, $attemptsLeft attempts remaining, will retry in $using:RetryWaitTimeInSeconds seconds" - Start-Sleep -Seconds $using:RetryWaitTimeInSeconds - } - else { - if ($NumFailedLinks -eq 0) { - if ($FailedFiles.Value -eq 0) { - Write-Host - } - - Write-Host "`tFile $RealPath has broken links:" - } - - Write-Host "`t`tFailed to retrieve $Link" - - $NumFailedLinks++ - } - } - else { - break - } - } - } - } - - if ($NumFailedLinks -ne 0) { - $FailedFiles.value++ - $global:LASTEXITCODE = 1 - } - } - } - - &$ValidateFile $TargetFile $FileName ([ref]$FailedFiles) - } - } - catch { - Write-Host $_ - } - finally { - $zip.Dispose() - } - - if ($FailedFiles -eq 0) { - Write-Host 'Passed.' - return [pscustomobject]@{ - result = 0 - packagePath = $PackagePath - } - } - else { - Write-PipelineTelemetryError -Category 'SourceLink' -Message "$PackagePath has broken SourceLink links." - return [pscustomobject]@{ - result = 1 - packagePath = $PackagePath - } - } -} - -function CheckJobResult( - $result, - $packagePath, - [ref]$ValidationFailures, - [switch]$logErrors) { - if ($result -ne '0') { - if ($logErrors) { - Write-PipelineTelemetryError -Category 'SourceLink' -Message "$packagePath has broken SourceLink links." - } - $ValidationFailures.Value++ - } -} - -function ValidateSourceLinkLinks { - if ($GHRepoName -ne '' -and !($GHRepoName -Match '^[^\s\/]+/[^\s\/]+$')) { - if (!($GHRepoName -Match '^[^\s-]+-[^\s]+$')) { - Write-PipelineTelemetryError -Category 'SourceLink' -Message "GHRepoName should be in the format / or -. '$GHRepoName'" - ExitWithExitCode 1 - } - else { - $GHRepoName = $GHRepoName -replace '^([^\s-]+)-([^\s]+)$', '$1/$2'; - } - } - - if ($GHCommit -ne '' -and !($GHCommit -Match '^[0-9a-fA-F]{40}$')) { - Write-PipelineTelemetryError -Category 'SourceLink' -Message "GHCommit should be a 40 chars hexadecimal string. '$GHCommit'" - ExitWithExitCode 1 - } - - if ($GHRepoName -ne '' -and $GHCommit -ne '') { - $RepoTreeURL = -Join('http://api.github.com/repos/', $GHRepoName, '/git/trees/', $GHCommit, '?recursive=1') - $CodeExtensions = @('.cs', '.vb', '.fs', '.fsi', '.fsx', '.fsscript') - - try { - # Retrieve the list of files in the repo at that particular commit point and store them in the RepoFiles hash - $Data = Invoke-WebRequest $RepoTreeURL -UseBasicParsing | ConvertFrom-Json | Select-Object -ExpandProperty tree - - foreach ($file in $Data) { - $Extension = [System.IO.Path]::GetExtension($file.path) - - if ($CodeExtensions.Contains($Extension)) { - $RepoFiles[$file.path] = 1 - } - } - } - catch { - Write-Host "Problems downloading the list of files from the repo. Url used: $RepoTreeURL . Execution will proceed without caching." - } - } - elseif ($GHRepoName -ne '' -or $GHCommit -ne '') { - Write-Host 'For using the http caching mechanism both GHRepoName and GHCommit should be informed.' - } - - if (Test-Path $ExtractPath) { - Remove-Item $ExtractPath -Force -Recurse -ErrorAction SilentlyContinue - } - - $ValidationFailures = 0 - - # Process each NuGet package in parallel - Get-ChildItem "$InputPath\*.symbols.nupkg" | - ForEach-Object { - Write-Host "Starting $($_.FullName)" - Start-Job -ScriptBlock $ValidatePackage -ArgumentList $_.FullName | Out-Null - $NumJobs = @(Get-Job -State 'Running').Count - - while ($NumJobs -ge $MaxParallelJobs) { - Write-Host "There are $NumJobs validation jobs running right now. Waiting $SecondsBetweenLoadChecks seconds to check again." - sleep $SecondsBetweenLoadChecks - $NumJobs = @(Get-Job -State 'Running').Count - } - - foreach ($Job in @(Get-Job -State 'Completed')) { - $jobResult = Wait-Job -Id $Job.Id | Receive-Job - CheckJobResult $jobResult.result $jobResult.packagePath ([ref]$ValidationFailures) -LogErrors - Remove-Job -Id $Job.Id - } - } - - foreach ($Job in @(Get-Job)) { - $jobResult = Wait-Job -Id $Job.Id | Receive-Job - CheckJobResult $jobResult.result $jobResult.packagePath ([ref]$ValidationFailures) - Remove-Job -Id $Job.Id - } - if ($ValidationFailures -gt 0) { - Write-PipelineTelemetryError -Category 'SourceLink' -Message "$ValidationFailures package(s) failed validation." - ExitWithExitCode 1 - } -} - -function InstallSourcelinkCli { - $sourcelinkCliPackageName = 'sourcelink' - - $dotnetRoot = InitializeDotNetCli -install:$true - $dotnet = "$dotnetRoot\dotnet.exe" - $toolList = & "$dotnet" tool list --global - - if (($toolList -like "*$sourcelinkCliPackageName*") -and ($toolList -like "*$sourcelinkCliVersion*")) { - Write-Host "SourceLink CLI version $sourcelinkCliVersion is already installed." - } - else { - Write-Host "Installing SourceLink CLI version $sourcelinkCliVersion..." - Write-Host 'You may need to restart your command window if this is the first dotnet tool you have installed.' - & "$dotnet" tool install $sourcelinkCliPackageName --version $sourcelinkCliVersion --verbosity "minimal" --global - } -} - -try { - InstallSourcelinkCli - - foreach ($Job in @(Get-Job)) { - Remove-Job -Id $Job.Id - } - - ValidateSourceLinkLinks -} -catch { - Write-Host $_.Exception - Write-Host $_.ScriptStackTrace - Write-PipelineTelemetryError -Category 'SourceLink' -Message $_ - ExitWithExitCode 1 -} diff --git a/eng/common/sdk-task.ps1 b/eng/common/sdk-task.ps1 index 4017ff15ebf4b4..68119de603efe6 100644 --- a/eng/common/sdk-task.ps1 +++ b/eng/common/sdk-task.ps1 @@ -66,20 +66,7 @@ try { if( $msbuildEngine -eq "vs") { # Ensure desktop MSBuild is available for sdk tasks. - if( -not ($GlobalJson.tools.PSObject.Properties.Name -contains "vs" )) { - $GlobalJson.tools | Add-Member -Name "vs" -Value (ConvertFrom-Json "{ `"version`": `"16.5`" }") -MemberType NoteProperty - } - if( -not ($GlobalJson.tools.PSObject.Properties.Name -match "xcopy-msbuild" )) { - $GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "18.0.0" -MemberType NoteProperty - } - if ($GlobalJson.tools."xcopy-msbuild".Trim() -ine "none") { - $xcopyMSBuildToolsFolder = InitializeXCopyMSBuild $GlobalJson.tools."xcopy-msbuild" -install $true - } - if ($xcopyMSBuildToolsFolder -eq $null) { - throw 'Unable to get xcopy downloadable version of msbuild' - } - - $global:_MSBuildExe = "$($xcopyMSBuildToolsFolder)\MSBuild\Current\Bin\MSBuild.exe" + $global:_MSBuildExe = InitializeVisualStudioMSBuild } $taskProject = GetSdkTaskProject $task diff --git a/eng/common/template-guidance.md b/eng/common/template-guidance.md index cdc62e72b07772..f772aa3d78fa3e 100644 --- a/eng/common/template-guidance.md +++ b/eng/common/template-guidance.md @@ -81,7 +81,6 @@ eng\common\ publish-build-artifacts.yml (logic) publish-pipeline-artifacts.yml (logic) component-governance.yml (shim) - generate-sbom.yml (shim) publish-logs.yml (shim) retain-build.yml (shim) send-to-helix.yml (shim) @@ -104,7 +103,6 @@ eng\common\ setup-maestro-vars.yml (logic) steps\ component-governance.yml (logic) - generate-sbom.yml (logic) publish-build-artifacts.yml (redirect) publish-logs.yml (logic) publish-pipeline-artifacts.yml (redirect) diff --git a/eng/common/templates-official/job/job.yml b/eng/common/templates-official/job/job.yml index f70224eaa456f2..d68e9fbc2656dc 100644 --- a/eng/common/templates-official/job/job.yml +++ b/eng/common/templates-official/job/job.yml @@ -1,24 +1,15 @@ parameters: -# Sbom related params - enableSbom: true runAsPublic: false - PackageVersion: 9.0.0 - BuildDropPath: '$(System.DefaultWorkingDirectory)/artifacts' +# Sbom related params, unused now and can eventually be removed + enableSbom: unused + PackageVersion: unused + BuildDropPath: unused jobs: - template: /eng/common/core-templates/job/job.yml parameters: is1ESPipeline: true - componentGovernanceSteps: - - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}: - - template: /eng/common/templates/steps/generate-sbom.yml - parameters: - PackageVersion: ${{ parameters.packageVersion }} - BuildDropPath: ${{ parameters.buildDropPath }} - ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom - publishArtifacts: false - # publish artifacts # for 1ES managed templates, use the templateContext.output to handle multiple outputs. templateContext: @@ -26,12 +17,19 @@ jobs: outputs: - ${{ if ne(parameters.artifacts.publish, '') }}: - ${{ if and(ne(parameters.artifacts.publish.artifacts, 'false'), ne(parameters.artifacts.publish.artifacts, '')) }}: - - output: buildArtifacts + - output: pipelineArtifact displayName: Publish pipeline artifacts - PathtoPublish: '$(Build.ArtifactStagingDirectory)/artifacts' - ArtifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }} - condition: always() - retryCountOnTaskFailure: 10 # for any logs being locked + targetPath: '$(Build.ArtifactStagingDirectory)/artifacts' + artifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }} + condition: succeeded() + retryCountOnTaskFailure: 10 # for any files being locked + continueOnError: true + - output: pipelineArtifact + displayName: Publish pipeline artifacts + targetPath: '$(Build.ArtifactStagingDirectory)/artifacts' + artifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }}_Attempt$(System.JobAttempt) + condition: not(succeeded()) + retryCountOnTaskFailure: 10 # for any files being locked continueOnError: true - ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }}: - output: pipelineArtifact @@ -40,8 +38,8 @@ jobs: displayName: 'Publish logs' continueOnError: true condition: always() - retryCountOnTaskFailure: 10 # for any logs being locked - sbomEnabled: false # we don't need SBOM for logs + retryCountOnTaskFailure: 10 # for any files being locked + isProduction: false # logs are non-production artifacts - ${{ if eq(parameters.enablePublishBuildArtifacts, true) }}: - output: pipelineArtifact @@ -50,7 +48,8 @@ jobs: artifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)_Attempt$(System.JobAttempt)' ) }} continueOnError: true condition: always() - sbomEnabled: false # we don't need SBOM for logs + retryCountOnTaskFailure: 10 # for any files being locked + isProduction: false # logs are non-production artifacts - ${{ if eq(parameters.enableBuildRetry, 'true') }}: - output: pipelineArtifact @@ -58,14 +57,20 @@ jobs: artifactName: 'BuildConfiguration' displayName: 'Publish build retry configuration' continueOnError: true - sbomEnabled: false # we don't need SBOM for BuildConfiguration + retryCountOnTaskFailure: 10 # for any files being locked + isProduction: false # BuildConfiguration is a non-production artifact - - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}: + # V4 publishing: automatically publish staged artifacts as a pipeline artifact. + # The artifact name matches the SDK's FutureArtifactName ($(System.PhaseName)_Artifacts), + # which is encoded in the asset manifest for downstream publishing to discover. + # Jobs can opt in by setting enablePublishing: true. + - ${{ if and(eq(parameters.publishingVersion, 4), eq(parameters.enablePublishing, 'true')) }}: - output: pipelineArtifact - displayName: Publish SBOM manifest + displayName: 'Publish V4 pipeline artifacts' + targetPath: '$(Build.ArtifactStagingDirectory)/artifacts' + artifactName: '$(System.PhaseName)_Artifacts' continueOnError: true - targetPath: $(Build.ArtifactStagingDirectory)/sbom - artifactName: $(ARTIFACT_NAME) + retryCountOnTaskFailure: 10 # for any files being locked # add any outputs provided via root yaml - ${{ if ne(parameters.templateContext.outputs, '') }}: diff --git a/eng/common/templates-official/steps/component-governance.yml b/eng/common/templates-official/steps/component-governance.yml deleted file mode 100644 index 30bb3985ca2bf4..00000000000000 --- a/eng/common/templates-official/steps/component-governance.yml +++ /dev/null @@ -1,7 +0,0 @@ -steps: -- template: /eng/common/core-templates/steps/component-governance.yml - parameters: - is1ESPipeline: true - - ${{ each parameter in parameters }}: - ${{ parameter.key }}: ${{ parameter.value }} diff --git a/eng/common/templates-official/steps/publish-pipeline-artifacts.yml b/eng/common/templates-official/steps/publish-pipeline-artifacts.yml index 172f9f0fdc9701..9e5981365e5602 100644 --- a/eng/common/templates-official/steps/publish-pipeline-artifacts.yml +++ b/eng/common/templates-official/steps/publish-pipeline-artifacts.yml @@ -24,5 +24,7 @@ steps: artifactName: ${{ parameters.args.artifactName }} ${{ if parameters.args.properties }}: properties: ${{ parameters.args.properties }} - ${{ if parameters.args.sbomEnabled }}: + ${{ if ne(parameters.args.sbomEnabled, '') }}: sbomEnabled: ${{ parameters.args.sbomEnabled }} + ${{ if ne(parameters.args.isProduction, '') }}: + isProduction: ${{ parameters.args.isProduction }} diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml index 7f1b5d97d1abd0..5e261f34db421b 100644 --- a/eng/common/templates/job/job.yml +++ b/eng/common/templates/job/job.yml @@ -1,12 +1,12 @@ parameters: enablePublishBuildArtifacts: false - disableComponentGovernance: '' - componentGovernanceIgnoreDirectories: '' -# Sbom related params - enableSbom: true runAsPublic: false - PackageVersion: 9.0.0 - BuildDropPath: '$(System.DefaultWorkingDirectory)/artifacts' +# CG related params, unused now and can eventually be removed + disableComponentGovernance: unused +# Sbom related params, unused now and can eventually be removed + enableSbom: unused + PackageVersion: unused + BuildDropPath: unused jobs: - template: /eng/common/core-templates/job/job.yml @@ -21,32 +21,34 @@ jobs: - ${{ each step in parameters.steps }}: - ${{ step }} - componentGovernanceSteps: - - template: /eng/common/templates/steps/component-governance.yml - parameters: - ${{ if eq(parameters.disableComponentGovernance, '') }}: - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.runAsPublic, 'false'), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dotnet/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/microsoft/'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))) }}: - disableComponentGovernance: false - ${{ else }}: - disableComponentGovernance: true - ${{ else }}: - disableComponentGovernance: ${{ parameters.disableComponentGovernance }} - componentGovernanceIgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} + # we don't run CG in public + - ${{ if eq(variables['System.TeamProject'], 'public') }}: + - script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true" + displayName: Set skipComponentGovernanceDetection variable artifactPublishSteps: - ${{ if ne(parameters.artifacts.publish, '') }}: - ${{ if and(ne(parameters.artifacts.publish.artifacts, 'false'), ne(parameters.artifacts.publish.artifacts, '')) }}: - - template: /eng/common/core-templates/steps/publish-build-artifacts.yml + - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml parameters: is1ESPipeline: false args: displayName: Publish pipeline artifacts - pathToPublish: '$(Build.ArtifactStagingDirectory)/artifacts' - publishLocation: Container + targetPath: '$(Build.ArtifactStagingDirectory)/artifacts' artifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }} continueOnError: true - condition: always() - retryCountOnTaskFailure: 10 # for any logs being locked + condition: succeeded() + retryCountOnTaskFailure: 10 # for any files being locked + - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml + parameters: + is1ESPipeline: false + args: + displayName: Publish pipeline artifacts + targetPath: '$(Build.ArtifactStagingDirectory)/artifacts' + artifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }}_Attempt$(System.JobAttempt) + continueOnError: true + condition: not(succeeded()) + retryCountOnTaskFailure: 10 # for any files being locked - ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }}: - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml parameters: @@ -57,8 +59,7 @@ jobs: displayName: 'Publish logs' continueOnError: true condition: always() - retryCountOnTaskFailure: 10 # for any logs being locked - sbomEnabled: false # we don't need SBOM for logs + retryCountOnTaskFailure: 10 # for any files being locked - ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}: - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml @@ -70,7 +71,7 @@ jobs: artifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)_Attempt$(System.JobAttempt)' ) }} continueOnError: true condition: always() - sbomEnabled: false + retryCountOnTaskFailure: 10 # for any files being locked - ${{ if eq(parameters.enableBuildRetry, 'true') }}: - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml @@ -81,4 +82,4 @@ jobs: artifactName: 'BuildConfiguration' displayName: 'Publish build retry configuration' continueOnError: true - sbomEnabled: false # we don't need SBOM for BuildConfiguration + retryCountOnTaskFailure: 10 # for any files being locked diff --git a/eng/common/templates/steps/component-governance.yml b/eng/common/templates/steps/component-governance.yml deleted file mode 100644 index c12a5f8d21d765..00000000000000 --- a/eng/common/templates/steps/component-governance.yml +++ /dev/null @@ -1,7 +0,0 @@ -steps: -- template: /eng/common/core-templates/steps/component-governance.yml - parameters: - is1ESPipeline: false - - ${{ each parameter in parameters }}: - ${{ parameter.key }}: ${{ parameter.value }} diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 6710ffb884bb23..65adefc7f26871 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -185,7 +185,11 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) { if ((-not $globalJsonHasRuntimes) -and (-not [string]::IsNullOrEmpty($env:DOTNET_INSTALL_DIR)) -and (Test-Path(Join-Path $env:DOTNET_INSTALL_DIR "sdk\$dotnetSdkVersion"))) { $dotnetRoot = $env:DOTNET_INSTALL_DIR } else { - $dotnetRoot = Join-Path $RepoRoot '.dotnet' + if (-not [string]::IsNullOrEmpty($env:DOTNET_GLOBAL_INSTALL_DIR)) { + $dotnetRoot = $env:DOTNET_GLOBAL_INSTALL_DIR + } else { + $dotnetRoot = Join-Path $RepoRoot '.dotnet' + } if (-not (Test-Path(Join-Path $dotnetRoot "sdk\$dotnetSdkVersion"))) { if ($install) { @@ -375,12 +379,11 @@ function InstallDotNet([string] $dotnetRoot, # # 1. MSBuild from an active VS command prompt # 2. MSBuild from a compatible VS installation -# 3. MSBuild from the xcopy tool package # # Returns full path to msbuild.exe. # Throws on failure. # -function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = $null) { +function InitializeVisualStudioMSBuild([object]$vsRequirements = $null) { if (-not (IsWindowsPlatform)) { throw "Cannot initialize Visual Studio on non-Windows" } @@ -390,13 +393,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = } # Minimum VS version to require. - $vsMinVersionReqdStr = '17.7' - $vsMinVersionReqd = [Version]::new($vsMinVersionReqdStr) - - # If the version of msbuild is going to be xcopied, - # use this version. Version matches a package here: - # https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/Microsoft.DotNet.Arcade.MSBuild.Xcopy/versions/18.0.0 - $defaultXCopyMSBuildVersion = '18.0.0' + $vsMinVersionReqdStr = '18.0' if (!$vsRequirements) { if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') { @@ -426,46 +423,16 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = } } - # Locate Visual Studio installation or download x-copy msbuild. + # Locate Visual Studio installation. $vsInfo = LocateVisualStudio $vsRequirements - if ($vsInfo -ne $null -and $env:ForceUseXCopyMSBuild -eq $null) { + if ($vsInfo -ne $null) { # Ensure vsInstallDir has a trailing slash $vsInstallDir = Join-Path $vsInfo.installationPath "\" $vsMajorVersion = $vsInfo.installationVersion.Split('.')[0] InitializeVisualStudioEnvironmentVariables $vsInstallDir $vsMajorVersion } else { - if (Get-Member -InputObject $GlobalJson.tools -Name 'xcopy-msbuild') { - $xcopyMSBuildVersion = $GlobalJson.tools.'xcopy-msbuild' - $vsMajorVersion = $xcopyMSBuildVersion.Split('.')[0] - } else { - #if vs version provided in global.json is incompatible (too low) then use the default version for xcopy msbuild download - if($vsMinVersion -lt $vsMinVersionReqd){ - Write-Host "Using xcopy-msbuild version of $defaultXCopyMSBuildVersion since VS version $vsMinVersionStr provided in global.json is not compatible" - $xcopyMSBuildVersion = $defaultXCopyMSBuildVersion - $vsMajorVersion = $xcopyMSBuildVersion.Split('.')[0] - } - else{ - # If the VS version IS compatible, look for an xcopy msbuild package - # with a version matching VS. - # Note: If this version does not exist, then an explicit version of xcopy msbuild - # can be specified in global.json. This will be required for pre-release versions of msbuild. - $vsMajorVersion = $vsMinVersion.Major - $vsMinorVersion = $vsMinVersion.Minor - $xcopyMSBuildVersion = "$vsMajorVersion.$vsMinorVersion.0" - } - } - - $vsInstallDir = $null - if ($xcopyMSBuildVersion.Trim() -ine "none") { - $vsInstallDir = InitializeXCopyMSBuild $xcopyMSBuildVersion $install - if ($vsInstallDir -eq $null) { - throw "Could not xcopy msbuild. Please check that package 'Microsoft.DotNet.Arcade.MSBuild.Xcopy @ $xcopyMSBuildVersion' exists on feed 'dotnet-eng'." - } - } - if ($vsInstallDir -eq $null) { - throw 'Unable to find Visual Studio that has required version and components installed' - } + throw 'Unable to find Visual Studio that has required version and components installed' } $msbuildVersionDir = if ([int]$vsMajorVersion -lt 16) { "$vsMajorVersion.0" } else { "Current" } @@ -492,38 +459,6 @@ function InitializeVisualStudioEnvironmentVariables([string] $vsInstallDir, [str } } -function InstallXCopyMSBuild([string]$packageVersion) { - return InitializeXCopyMSBuild $packageVersion -install $true -} - -function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) { - $packageName = 'Microsoft.DotNet.Arcade.MSBuild.Xcopy' - $packageDir = Join-Path $ToolsDir "msbuild\$packageVersion" - $packagePath = Join-Path $packageDir "$packageName.$packageVersion.nupkg" - - if (!(Test-Path $packageDir)) { - if (!$install) { - return $null - } - - Create-Directory $packageDir - - Write-Host "Downloading $packageName $packageVersion" - $ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit - Retry({ - Invoke-WebRequest "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName/$packageVersion/$packageName.$packageVersion.nupkg" -UseBasicParsing -OutFile $packagePath - }) - - if (!(Test-Path $packagePath)) { - Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "See https://dev.azure.com/dnceng/internal/_wiki/wikis/DNCEng%20Services%20Wiki/1074/Updating-Microsoft.DotNet.Arcade.MSBuild.Xcopy-WAS-RoslynTools.MSBuild-(xcopy-msbuild)-generation?anchor=troubleshooting for help troubleshooting issues with XCopy MSBuild" - throw - } - Unzip $packagePath $packageDir - } - - return Join-Path $packageDir 'tools' -} - # # Locates Visual Studio instance that meets the minimal requirements specified by tools.vs object in global.json. # @@ -632,7 +567,7 @@ function InitializeBuildTool() { $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net' } } elseif ($msbuildEngine -eq "vs") { try { - $msbuildPath = InitializeVisualStudioMSBuild -install:$restore + $msbuildPath = InitializeVisualStudioMSBuild } catch { Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ ExitWithExitCode 1 @@ -745,10 +680,20 @@ function InitializeToolset() { ExitWithExitCode 1 } - $downloadArgs = @("package", "download", "Microsoft.DotNet.Arcade.Sdk@$toolsetVersion", "--prerelease", "--output", "$nugetCache") - if ($env:NUGET_CONFIG) { + $downloadArgs = @("package", "download", "Microsoft.DotNet.Arcade.Sdk@$toolsetVersion", "--verbosity", "minimal", "--prerelease", "--output", "$nugetCache") + $nugetConfig = $env:NUGET_CONFIG + if (-not $nugetConfig) { + # Search for any variation of nuget.config in the RepoRoot + $configFile = Get-ChildItem -Path $RepoRoot -File | Where-Object { $_.Name -ieq "nuget.config" } | Select-Object -First 1 + + if ($configFile) { + $nugetConfig = $configFile.FullName + } + } + + if ($nugetConfig) { $downloadArgs += "--configfile" - $downloadArgs += $env:NUGET_CONFIG + $downloadArgs += $nugetConfig } DotNet @downloadArgs diff --git a/eng/common/tools.sh b/eng/common/tools.sh index d2339eb21d5945..95c55ce9b4d914 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -148,7 +148,11 @@ function InitializeDotNetCli { if [[ $global_json_has_runtimes == false && -n "${DOTNET_INSTALL_DIR:-}" && -d "$DOTNET_INSTALL_DIR/sdk/$dotnet_sdk_version" ]]; then dotnet_root="$DOTNET_INSTALL_DIR" else - dotnet_root="${repo_root}.dotnet" + if [[ -n "${DOTNET_GLOBAL_INSTALL_DIR:-}" ]]; then + dotnet_root="$DOTNET_GLOBAL_INSTALL_DIR" + else + dotnet_root="${repo_root}.dotnet" + fi export DOTNET_INSTALL_DIR="$dotnet_root" @@ -426,9 +430,20 @@ function InitializeToolset { ExitWithExitCode 2 fi - local download_args=("package" "download" "Microsoft.DotNet.Arcade.Sdk@$toolset_version" "--prerelease" "--output" "$_GetNuGetPackageCachePath") - if [[ -n "${NUGET_CONFIG:-}" ]]; then - download_args+=("--configfile" "$NUGET_CONFIG") + local download_args=("package" "download" "Microsoft.DotNet.Arcade.Sdk@$toolset_version" "--verbosity" "minimal" "--prerelease" "--output" "$_GetNuGetPackageCachePath") + local nuget_config="${NUGET_CONFIG:-}" + if [[ -z "$nuget_config" ]]; then + # Search for any variation of nuget.config in the RepoRoot + local found_config + found_config=$(find "$repo_root" -maxdepth 1 -type f -iname "nuget.config" -print -quit) + + if [[ -n "$found_config" ]]; then + nuget_config="$found_config" + fi + fi + + if [[ -n "$nuget_config" ]]; then + download_args+=("--configfile" "$nuget_config") fi DotNet "${download_args[@]}" diff --git a/global.json b/global.json index 2a02cd5952b45b..01f9d078a1fb65 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "11.0.100-preview.3.26170.106", + "version": "11.0.100-preview.5.26227.104", "allowPrerelease": true, "rollForward": "major", "paths": [ @@ -10,14 +10,14 @@ "errorMessage": "The required .NET SDK wasn't found. Please run ./eng/common/dotnet.sh (Unix) or eng\\common\\dotnet.cmd (Windows) to install it." }, "tools": { - "dotnet": "11.0.100-preview.3.26170.106" + "dotnet": "11.0.100-preview.5.26227.104" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26211.102", - "Microsoft.DotNet.Helix.Sdk": "11.0.0-beta.26211.102", - "Microsoft.DotNet.SharedFramework.Sdk": "11.0.0-beta.26211.102", + "Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26257.113", + "Microsoft.DotNet.Helix.Sdk": "11.0.0-beta.26257.113", + "Microsoft.DotNet.SharedFramework.Sdk": "11.0.0-beta.26257.113", "Microsoft.Build.NoTargets": "3.7.0", "Microsoft.Build.Traversal": "3.4.0", - "Microsoft.NET.Sdk.IL": "11.0.0-preview.4.26211.102" + "Microsoft.NET.Sdk.IL": "11.0.0-preview.5.26257.113" } } diff --git a/src/coreclr/clrdatadescriptors.cmake b/src/coreclr/clrdatadescriptors.cmake index 86b1b7defbebcb..3a40c12dcc0840 100644 --- a/src/coreclr/clrdatadescriptors.cmake +++ b/src/coreclr/clrdatadescriptors.cmake @@ -94,10 +94,16 @@ function(generate_data_descriptors) # MSVC writes debug info to the default `vc140.pdb`, which does not travel with # the .obj files when they are archived into a static library (e.g. # Runtime.ServerGC.lib). Downstream linkers - notably the NativeAOT publish - # of ILCompiler/crossgen2/ilasm - then emit LNK4099 ("PDB 'vc140.pdb' was not - # found"), which is fatal under /WX. + # of ILCompiler/crossgen2/ilasm/mscordaccore_universal - then emit LNK4099 + # ("PDB ... was not found"), which is fatal under /WX in the VMR build. set_target_properties(${LIBRARY} PROPERTIES COMPILE_PDB_NAME "${LIBRARY}" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$") + # Even with a per-target PDB name, the external PDB stays in the producer's + # binary dir and is not visible to downstream linkers consuming the static lib. + # Embed CodeView debug info directly into each .obj (/Z7) so the debug data + # travels with the object when it is archived into the static library, removing + # the need for the linker to find a separate PDB and silencing LNK4099. + target_compile_options(${LIBRARY} PRIVATE /Z7) endif() endfunction(generate_data_descriptors) diff --git a/src/coreclr/tools/ILTrim.Core/ILTrim.Core.csproj b/src/coreclr/tools/ILTrim.Core/ILTrim.Core.csproj index 95f9c6fd4230be..ff92d4a3df930c 100644 --- a/src/coreclr/tools/ILTrim.Core/ILTrim.Core.csproj +++ b/src/coreclr/tools/ILTrim.Core/ILTrim.Core.csproj @@ -10,9 +10,6 @@ $(ToolsCommonPath)TypeSystem\ $(DefineConstants);ILTRIM - - - diff --git a/src/coreclr/tools/ILTrim/ILTrim.csproj b/src/coreclr/tools/ILTrim/ILTrim.csproj index 252aae8d9b7b79..f767c56001a093 100644 --- a/src/coreclr/tools/ILTrim/ILTrim.csproj +++ b/src/coreclr/tools/ILTrim/ILTrim.csproj @@ -9,7 +9,6 @@ - diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompiler.props b/src/coreclr/tools/aot/ILCompiler/ILCompiler.props index c4882ea694bff8..e3e6d02212c298 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompiler.props +++ b/src/coreclr/tools/aot/ILCompiler/ILCompiler.props @@ -25,9 +25,11 @@ - - PreserveNewest - + @@ -66,6 +68,7 @@ @@ -73,6 +76,7 @@ diff --git a/src/libraries/Common/src/Interop/Interop.Utils.cs b/src/libraries/Common/src/Interop/Interop.Utils.cs index 498236c4ac4608..6d83fde5eeee35 100644 --- a/src/libraries/Common/src/Interop/Interop.Utils.cs +++ b/src/libraries/Common/src/Interop/Interop.Utils.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -11,7 +11,7 @@ internal static partial class Interop /// the correct size of buffer to make. So invoke the interop call with an /// increasing buffer until the size is big enough. /// - internal static bool CallStringMethod( + internal static unsafe bool CallStringMethod( SpanFunc interopCall, TArg1 arg1, TArg2 arg2, TArg3 arg3, out string? result) diff --git a/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs b/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs index d967b2375aaa23..88aafae7c4ecd7 100644 --- a/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs +++ b/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -379,7 +379,7 @@ private static bool TryFindCGroupPathForSubsystem(CGroupVersion cgroupVersion, s /// The subsystem, e.g. "memory". /// The found path, or null if it couldn't be found. /// true if a cgroup path for the subsystem is found. - internal static bool TryFindCGroupPathForSubsystem(CGroupVersion cgroupVersion, string procCGroupFilePath, string subsystem, [NotNullWhen(true)] out string? path) + internal static unsafe bool TryFindCGroupPathForSubsystem(CGroupVersion cgroupVersion, string procCGroupFilePath, string subsystem, [NotNullWhen(true)] out string? path) { if (File.Exists(procCGroupFilePath)) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs index 3b14a4076caaac..2c169132f4e844 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -29,7 +29,7 @@ internal static partial class Sys /// /// The path to the symlink. /// Returns the link to the target path on success; and null otherwise. - internal static string? ReadLink(ReadOnlySpan path) + internal static unsafe string? ReadLink(ReadOnlySpan path) { const int StackBufferSize = 256; diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs index a7fa684d3ceda1..9c95ab07365ad4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -349,7 +349,7 @@ internal static void UpdateClientCertificate(SafeSslHandle ssl, SslAuthenticatio } // This essentially wraps SSL* SSL_new() - internal static SafeSslHandle AllocateSslHandle(SslAuthenticationOptions sslAuthenticationOptions) + internal static unsafe SafeSslHandle AllocateSslHandle(SslAuthenticationOptions sslAuthenticationOptions) { SafeSslHandle? sslHandle = null; bool cacheSslContext = sslAuthenticationOptions.AllowTlsResume && !LocalAppContextSwitches.DisableTlsResume && sslAuthenticationOptions.EncryptionPolicy == EncryptionPolicy.RequireEncryption && sslAuthenticationOptions.CipherSuitesPolicy == null; diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs index af4eb0f78a8b01..fd5f3608bbd9df 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -86,7 +86,7 @@ internal static unsafe ReadOnlySpan SslGetAlpnSelected(SafeSslHandle ssl) [LibraryImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetDefaultSignatureAlgorithms")] private static unsafe partial int GetDefaultSignatureAlgorithms(Span algorithms, ref int algorithmCount); - internal static ushort[] GetDefaultSignatureAlgorithms() + internal static unsafe ushort[] GetDefaultSignatureAlgorithms() { // 256 algorithms should be more than enough for any use case. Span algorithms = stackalloc ushort[256]; diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs index 8d43a18a7c331a..d8d67227817e64 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -14,7 +14,7 @@ internal static partial class Kernel32 // maximum length of the NETBIOS name (not including NULL) private const int MAX_COMPUTERNAME_LENGTH = 15; - internal static string? GetComputerName() + internal static unsafe string? GetComputerName() { Span buffer = stackalloc char[MAX_COMPUTERNAME_LENGTH + 1]; uint length = (uint)buffer.Length; diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs index 61635c50767301..9806713fcf1ff8 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -29,7 +29,7 @@ private static partial ErrorCode NCryptDeriveKey( /// Derive key material from a hash or HMAC KDF /// /// - private static byte[] DeriveKeyMaterial( + private static unsafe byte[] DeriveKeyMaterial( SafeNCryptSecretHandle secretAgreement, string kdf, string hashAlgorithm, diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs index 5a0123c4bf561b..b7228335881595 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -239,7 +239,7 @@ public static bool QueryBlittableContextAttributes(ISSPIInterface secModule, return true; } - public static string? QueryStringContextAttributes(ISSPIInterface secModule, SafeDeleteContext securityContext, Interop.SspiCli.ContextAttribute contextAttribute) + public static unsafe string? QueryStringContextAttributes(ISSPIInterface secModule, SafeDeleteContext securityContext, Interop.SspiCli.ContextAttribute contextAttribute) { Debug.Assert( contextAttribute == Interop.SspiCli.ContextAttribute.SECPKG_ATTR_NAMES || diff --git a/src/libraries/Common/src/System/Diagnostics/DiagnosticsHelper.cs b/src/libraries/Common/src/System/Diagnostics/DiagnosticsHelper.cs index eb29b39698cd5a..c668523fdfe6d0 100644 --- a/src/libraries/Common/src/System/Diagnostics/DiagnosticsHelper.cs +++ b/src/libraries/Common/src/System/Diagnostics/DiagnosticsHelper.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; @@ -19,7 +19,7 @@ internal static class DiagnosticsHelper /// we avoid the allocation of a new array by using the second collection as is and not converting it to an array. the reason /// is we call this every time we try to create a meter or instrument and we don't want to allocate a new array every time. /// - internal static bool CompareTags(IList>? sortedTags, IEnumerable>? tags2) + internal static unsafe bool CompareTags(IList>? sortedTags, IEnumerable>? tags2) { if (sortedTags == tags2) { diff --git a/src/libraries/Common/src/System/Drawing/ColorConverterCommon.cs b/src/libraries/Common/src/System/Drawing/ColorConverterCommon.cs index bf69d5cc5fe3b5..729b368fc6d781 100644 --- a/src/libraries/Common/src/System/Drawing/ColorConverterCommon.cs +++ b/src/libraries/Common/src/System/Drawing/ColorConverterCommon.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -9,7 +9,7 @@ namespace System.Drawing // Minimal color conversion functionality, without a dependency on TypeConverter itself. internal static class ColorConverterCommon { - public static Color ConvertFromString(string strValue, CultureInfo culture) + public static unsafe Color ConvertFromString(string strValue, CultureInfo culture) { Debug.Assert(culture != null); diff --git a/src/libraries/Common/src/System/HexConverter.cs b/src/libraries/Common/src/System/HexConverter.cs index 0ff09f1bc94fe0..10316e0c610325 100644 --- a/src/libraries/Common/src/System/HexConverter.cs +++ b/src/libraries/Common/src/System/HexConverter.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -216,7 +216,7 @@ public static void EncodeToUtf16(ReadOnlySpan source, Span destinati } } - public static string ToString(ReadOnlySpan bytes, Casing casing = Casing.Upper) + public static unsafe string ToString(ReadOnlySpan bytes, Casing casing = Casing.Upper) { #if NET SpanCasingPair args = new() { Bytes = bytes, Casing = casing }; diff --git a/src/libraries/Common/src/System/IO/PathInternal.Windows.cs b/src/libraries/Common/src/System/IO/PathInternal.Windows.cs index e0aff52855590c..25e4182a645907 100644 --- a/src/libraries/Common/src/System/IO/PathInternal.Windows.cs +++ b/src/libraries/Common/src/System/IO/PathInternal.Windows.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; @@ -315,7 +315,7 @@ internal static bool IsDirectorySeparator(char c) /// 4. Isn't a cross-plat friendly concept/behavior /// [return: NotNullIfNotNull(nameof(path))] - internal static string? NormalizeDirectorySeparators(string? path) + internal static unsafe string? NormalizeDirectorySeparators(string? path) { if (string.IsNullOrEmpty(path)) return path; diff --git a/src/libraries/Common/src/System/IO/PathInternal.cs b/src/libraries/Common/src/System/IO/PathInternal.cs index 1cd11d94204202..897f7c7d2b9816 100644 --- a/src/libraries/Common/src/System/IO/PathInternal.cs +++ b/src/libraries/Common/src/System/IO/PathInternal.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -95,7 +95,7 @@ internal static bool AreRootsEqual(string? first, string? second, StringComparis /// /// Input path /// The length of the root of the given path - internal static string RemoveRelativeSegments(string path, int rootLength) + internal static unsafe string RemoveRelativeSegments(string path, int rootLength) { var sb = new ValueStringBuilder(stackalloc char[260 /* PathInternal.MaxShortPath */]); diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackEncoder.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackEncoder.cs index dab588146dc2af..45bb2a6b106c18 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackEncoder.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackEncoder.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable @@ -596,7 +596,7 @@ public static bool EncodeStringLiterals(ReadOnlySpan values, byte[]? sep /// Encodes a "Literal Header Field without Indexing" to a new array, but only the index portion; /// a subsequent call to EncodeStringLiteral must be used to encode the associated value. /// - public static byte[] EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(int index) + public static unsafe byte[] EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(int index) { Span span = stackalloc byte[256]; bool success = EncodeLiteralHeaderFieldWithoutIndexing(index, span, out int length); @@ -608,7 +608,7 @@ public static byte[] EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(int /// Encodes a "Literal Header Field without Indexing - New Name" to a new array, but only the name portion; /// a subsequent call to EncodeStringLiteral must be used to encode the associated value. /// - public static byte[] EncodeLiteralHeaderFieldWithoutIndexingNewNameToAllocatedArray(string name) + public static unsafe byte[] EncodeLiteralHeaderFieldWithoutIndexingNewNameToAllocatedArray(string name) { Span span = stackalloc byte[256]; bool success = EncodeLiteralHeaderFieldWithoutIndexingNewName(name, span, out int length); @@ -617,7 +617,7 @@ public static byte[] EncodeLiteralHeaderFieldWithoutIndexingNewNameToAllocatedAr } /// Encodes a "Literal Header Field without Indexing" to a new array. - public static byte[] EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(int index, string value) + public static unsafe byte[] EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(int index, string value) { Span span = #if DEBUG diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/Helpers/VariableLengthIntegerHelper.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/Helpers/VariableLengthIntegerHelper.cs index c7f1ec908d0f45..f1f6890511c4e0 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/Helpers/VariableLengthIntegerHelper.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/Helpers/VariableLengthIntegerHelper.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -96,7 +96,7 @@ public static bool TryRead(ref SequenceReader reader, out long value) // Cold path: copy to a temporary buffer before calling span-based read. return TryReadSlow(ref reader, out value); - static bool TryReadSlow(ref SequenceReader reader, out long value) + static unsafe bool TryReadSlow(ref SequenceReader reader, out long value) { ReadOnlySpan span = reader.CurrentSpan; diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncoder.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncoder.cs index 5d96530b457d0c..07ff802959a2ae 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncoder.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncoder.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable @@ -34,7 +34,7 @@ public static bool EncodeStaticIndexedHeaderField(int index, Span destinat } } - public static byte[] EncodeStaticIndexedHeaderFieldToArray(int index) + public static unsafe byte[] EncodeStaticIndexedHeaderFieldToArray(int index) { Span buffer = stackalloc byte[IntegerEncoder.MaxInt32EncodedLength]; @@ -88,7 +88,7 @@ public static bool EncodeLiteralHeaderFieldWithStaticNameReference(int index, st /// /// Encodes just the name part of a Literal Header Field With Static Name Reference. Must call after to encode the header's value. /// - public static byte[] EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(int index) + public static unsafe byte[] EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(int index) { Span temp = stackalloc byte[IntegerEncoder.MaxInt32EncodedLength]; @@ -99,7 +99,7 @@ public static byte[] EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(int return temp.Slice(0, headerBytesWritten).ToArray(); } - public static byte[] EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(int index, string value) + public static unsafe byte[] EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(int index, string value) { Span temp = value.Length < 256 ? stackalloc byte[256 + IntegerEncoder.MaxInt32EncodedLength * 2] : new byte[value.Length + IntegerEncoder.MaxInt32EncodedLength * 2]; bool res = EncodeLiteralHeaderFieldWithStaticNameReference(index, value, temp, out int bytesWritten); @@ -159,7 +159,7 @@ public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, Rea /// /// Encodes just the value part of a Literawl Header Field Without Static Name Reference. Must call after to encode the header's value. /// - public static byte[] EncodeLiteralHeaderFieldWithoutNameReferenceToArray(string name) + public static unsafe byte[] EncodeLiteralHeaderFieldWithoutNameReferenceToArray(string name) { Span temp = name.Length < 256 ? stackalloc byte[256 + IntegerEncoder.MaxInt32EncodedLength] : new byte[name.Length + IntegerEncoder.MaxInt32EncodedLength]; @@ -169,7 +169,7 @@ public static byte[] EncodeLiteralHeaderFieldWithoutNameReferenceToArray(string return temp.Slice(0, nameLength).ToArray(); } - public static byte[] EncodeLiteralHeaderFieldWithoutNameReferenceToArray(string name, string value) + public static unsafe byte[] EncodeLiteralHeaderFieldWithoutNameReferenceToArray(string name, string value) { Span temp = (name.Length + value.Length) < 256 ? stackalloc byte[256 + IntegerEncoder.MaxInt32EncodedLength * 2] : new byte[name.Length + value.Length + IntegerEncoder.MaxInt32EncodedLength * 2]; diff --git a/src/libraries/Common/src/System/Net/IPEndPointExtensions.cs b/src/libraries/Common/src/System/Net/IPEndPointExtensions.cs index 87a66da4637d4c..a1dfdf2eb63a8a 100644 --- a/src/libraries/Common/src/System/Net/IPEndPointExtensions.cs +++ b/src/libraries/Common/src/System/Net/IPEndPointExtensions.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -8,7 +8,7 @@ namespace System.Net.Sockets { internal static partial class IPEndPointExtensions { - public static IPAddress GetIPAddress(ReadOnlySpan socketAddressBuffer) + public static unsafe IPAddress GetIPAddress(ReadOnlySpan socketAddressBuffer) { AddressFamily family = SocketAddressPal.GetAddressFamily(socketAddressBuffer); @@ -29,7 +29,7 @@ public static IPAddress GetIPAddress(ReadOnlySpan socketAddressBuffer) throw new SocketException((int)SocketError.AddressFamilyNotSupported); } - public static void SetIPAddress(Span socketAddressBuffer, IPAddress address) + public static unsafe void SetIPAddress(Span socketAddressBuffer, IPAddress address) { SocketAddressPal.SetAddressFamily(socketAddressBuffer, address.AddressFamily); SocketAddressPal.SetPort(socketAddressBuffer, 0); @@ -61,7 +61,7 @@ public static void Serialize(this IPEndPoint endPoint, Span destination) SocketAddressPal.SetPort(destination, (ushort)endPoint.Port); } - public static bool Equals(this IPEndPoint endPoint, ReadOnlySpan socketAddressBuffer) + public static unsafe bool Equals(this IPEndPoint endPoint, ReadOnlySpan socketAddressBuffer) { if (socketAddressBuffer.Length >= SocketAddress.GetMaximumAddressSize(endPoint.AddressFamily) && endPoint.AddressFamily == SocketAddressPal.GetAddressFamily(socketAddressBuffer) && diff --git a/src/libraries/Common/src/System/Net/IPv4AddressHelper.Common.cs b/src/libraries/Common/src/System/Net/IPv4AddressHelper.Common.cs index 575d7ed2ec7d6d..7b3a6916b015c9 100644 --- a/src/libraries/Common/src/System/Net/IPv4AddressHelper.Common.cs +++ b/src/libraries/Common/src/System/Net/IPv4AddressHelper.Common.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers.Binary; @@ -31,7 +31,7 @@ internal static ushort ToUShort(TChar value) } // Only called from the IPv6Helper, only parse the canonical format - internal static int ParseHostNumber(ReadOnlySpan str, int start, int end) + internal static unsafe int ParseHostNumber(ReadOnlySpan str, int start, int end) where TChar : unmanaged, IBinaryInteger { Debug.Assert(typeof(TChar) == typeof(char) || typeof(TChar) == typeof(byte)); diff --git a/src/libraries/Common/src/System/Net/Security/MD4.cs b/src/libraries/Common/src/System/Net/Security/MD4.cs index 6b7acd98f2f8a0..cba52297c7b1cd 100644 --- a/src/libraries/Common/src/System/Net/Security/MD4.cs +++ b/src/libraries/Common/src/System/Net/Security/MD4.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // @@ -60,7 +60,7 @@ internal sealed class MD4 private const int S33 = 11; private const int S34 = 15; - internal static void HashData(ReadOnlySpan source, Span destination) + internal static unsafe void HashData(ReadOnlySpan source, Span destination) { Debug.Assert(destination.Length == 128 >> 3); @@ -186,7 +186,7 @@ private static void Decode(Span output, ReadOnlySpan input) } } - private static void MD4Transform(Span state, ReadOnlySpan block) + private static unsafe void MD4Transform(Span state, ReadOnlySpan block) { uint a = state[0]; uint b = state[1]; diff --git a/src/libraries/Common/src/System/Net/Security/SslKeyLogger.cs b/src/libraries/Common/src/System/Net/Security/SslKeyLogger.cs index aa7885420c9ef8..30381c287b093b 100644 --- a/src/libraries/Common/src/System/Net/Security/SslKeyLogger.cs +++ b/src/libraries/Common/src/System/Net/Security/SslKeyLogger.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -56,7 +56,7 @@ public static void WriteLineRaw(ReadOnlySpan data) } } - public static void WriteSecrets( + public static unsafe void WriteSecrets( ReadOnlySpan clientRandom, ReadOnlySpan clientHandshakeTrafficSecret, ReadOnlySpan serverHandshakeTrafficSecret, @@ -95,7 +95,7 @@ public static void WriteSecrets( } } - private static void WriteSecretCore(ReadOnlySpan labelUtf8, ReadOnlySpan clientRandomUtf8, ReadOnlySpan secret) + private static unsafe void WriteSecretCore(ReadOnlySpan labelUtf8, ReadOnlySpan clientRandomUtf8, ReadOnlySpan secret) { if (secret.Length == 0) { diff --git a/src/libraries/Common/src/System/Net/SocketAddress.cs b/src/libraries/Common/src/System/Net/SocketAddress.cs index bd4172ace9b106..e64670a6704457 100644 --- a/src/libraries/Common/src/System/Net/SocketAddress.cs +++ b/src/libraries/Common/src/System/Net/SocketAddress.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -92,7 +92,7 @@ public SocketAddress(AddressFamily family, int size) SocketAddressPal.SetAddressFamily(_buffer, family); } - internal SocketAddress(IPAddress ipAddress) + internal unsafe SocketAddress(IPAddress ipAddress) : this(ipAddress.AddressFamily, ((ipAddress.AddressFamily == AddressFamily.InterNetwork) ? IPv4AddressSize : IPv6AddressSize)) { @@ -150,7 +150,7 @@ public override int GetHashCode() return hash.ToHashCode(); } - public override string ToString() + public override unsafe string ToString() { // Get the address family string. In almost all cases, this should be a cached string // from the enum and won't actually allocate. diff --git a/src/libraries/Common/src/System/Reflection/AssemblyNameFormatter.cs b/src/libraries/Common/src/System/Reflection/AssemblyNameFormatter.cs index 5b066c81926bc4..090c864a3dfe5e 100644 --- a/src/libraries/Common/src/System/Reflection/AssemblyNameFormatter.cs +++ b/src/libraries/Common/src/System/Reflection/AssemblyNameFormatter.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; @@ -10,7 +10,7 @@ namespace System.Reflection { internal static class AssemblyNameFormatter { - public static string ComputeDisplayName(string name, Version? version, string? cultureName, byte[]? pkt, AssemblyNameFlags flags = 0, AssemblyContentType contentType = 0, byte[]? pk = null) + public static unsafe string ComputeDisplayName(string name, Version? version, string? cultureName, byte[]? pkt, AssemblyNameFlags flags = 0, AssemblyContentType contentType = 0, byte[]? pk = null) { ValueStringBuilder vsb = new(stackalloc char[256]); AppendDisplayName(ref vsb, name, version, cultureName, pkt, flags, contentType, pk); diff --git a/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs b/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs index 3638ab05166344..246d3f75fd0f7c 100644 --- a/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs +++ b/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -244,7 +244,7 @@ private bool TryParse(ref AssemblyNameParts result) private static bool IsAttribute(string candidate, string attributeKind) => candidate.Equals(attributeKind, StringComparison.OrdinalIgnoreCase); - private static bool TryParseVersion(string attributeValue, ref Version? version) + private static unsafe bool TryParseVersion(string attributeValue, ref Version? version) { #if NET ReadOnlySpan attributeValueSpan = attributeValue; @@ -364,7 +364,7 @@ private bool TryGetNextChar(out char ch) // Return the next token in assembly name. If the result is Token.String, // sets "tokenString" to the tokenized string. // - private bool TryGetNextToken(out string tokenString, out Token token) + private unsafe bool TryGetNextToken(out string tokenString, out Token token) { tokenString = string.Empty; char c; diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/PfxAsn.manual.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/PfxAsn.manual.cs index 6503281168a310..41926fd84a6736 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/PfxAsn.manual.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/PfxAsn.manual.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -12,7 +12,7 @@ namespace System.Security.Cryptography.Asn1.Pkcs12 { internal partial struct PfxAsn { - internal bool VerifyMac( + internal unsafe bool VerifyMac( ReadOnlySpan macPassword, ReadOnlySpan authSafeContents) { diff --git a/src/libraries/Common/src/System/Security/Cryptography/CngPkcs8.cs b/src/libraries/Common/src/System/Security/Cryptography/CngPkcs8.cs index fd6347176e7c69..91d400654e0233 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/CngPkcs8.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/CngPkcs8.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -268,7 +268,7 @@ internal static Pkcs8Response ImportEncryptedPkcs8PrivateKey( } } - private static AsnWriter RewriteEncryptedPkcs8PrivateKey( + private static unsafe AsnWriter RewriteEncryptedPkcs8PrivateKey( AsymmetricAlgorithm key, ReadOnlySpan passwordBytes, PbeParameters pbeParameters) @@ -407,7 +407,7 @@ private static AsnWriter RewriteEncryptedPkcs8PrivateKey( } } - private static void FillRandomAsciiString(Span destination) + private static unsafe void FillRandomAsciiString(Span destination) { Debug.Assert(destination.Length < 128); Span randomKey = stackalloc byte[destination.Length]; diff --git a/src/libraries/Common/src/System/Security/Cryptography/DSAAndroid.cs b/src/libraries/Common/src/System/Security/Cryptography/DSAAndroid.cs index 3207cd0df937b4..63fda373c0e851 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/DSAAndroid.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/DSAAndroid.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -202,7 +202,7 @@ protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm) protected override bool TryHashData(ReadOnlySpan data, Span destination, HashAlgorithmName hashAlgorithm, out int bytesWritten) => CryptographicOperations.TryHashData(hashAlgorithm, data, destination, out bytesWritten); - public override byte[] CreateSignature(byte[] rgbHash) + public override unsafe byte[] CreateSignature(byte[] rgbHash) { ArgumentNullException.ThrowIfNull(rgbHash); @@ -227,7 +227,7 @@ public override bool TryCreateSignature( out bytesWritten); } - protected override bool TryCreateSignatureCore( + protected override unsafe bool TryCreateSignatureCore( ReadOnlySpan hash, Span destination, DSASignatureFormat signatureFormat, diff --git a/src/libraries/Common/src/System/Security/Cryptography/DSACng.SignVerify.cs b/src/libraries/Common/src/System/Security/Cryptography/DSACng.SignVerify.cs index b2ec1a976fa6d5..26d1cf353a8b49 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/DSACng.SignVerify.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/DSACng.SignVerify.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -17,7 +17,7 @@ public sealed partial class DSACng : DSA // https://learn.microsoft.com/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_dsa_key_blob_v2 private const int WindowsMaxQSize = 32; - public override byte[] CreateSignature(byte[] rgbHash) + public override unsafe byte[] CreateSignature(byte[] rgbHash) { ArgumentNullException.ThrowIfNull(rgbHash); @@ -78,7 +78,7 @@ public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature) return VerifySignatureCore(rgbHash, rgbSignature, DSASignatureFormat.IeeeP1363FixedFieldConcatenation); } - protected override bool VerifySignatureCore( + protected override unsafe bool VerifySignatureCore( ReadOnlySpan hash, ReadOnlySpan signature, DSASignatureFormat signatureFormat) diff --git a/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs index 699d9faa1af235..2077a7c886ef56 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -193,7 +193,7 @@ private SafeDsaHandle GenerateKey() return key; } - public override byte[] CreateSignature(byte[] rgbHash) + public override unsafe byte[] CreateSignature(byte[] rgbHash) { ArgumentNullException.ThrowIfNull(rgbHash); @@ -218,7 +218,7 @@ public override bool TryCreateSignature( out bytesWritten); } - protected override bool TryCreateSignatureCore( + protected override unsafe bool TryCreateSignatureCore( ReadOnlySpan hash, Span destination, DSASignatureFormat signatureFormat, diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAndroid.Derive.cs b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAndroid.Derive.cs index b284584acf2b9c..555ed51df0177f 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAndroid.Derive.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAndroid.Derive.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -85,7 +85,7 @@ public override byte[] DeriveRawSecretAgreement(ECDiffieHellmanPublicKey otherPa /// /// Get the secret agreement generated between two parties /// - private byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher) + private unsafe byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher) { Debug.Assert(otherPartyPublicKey != null); Debug.Assert(_key is not null); // Callers should have checked for null diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAppleCrypto.cs b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAppleCrypto.cs index 6b27d84f3a30b2..abc66f212aeaba 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAppleCrypto.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAppleCrypto.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -175,7 +175,7 @@ public override byte[] DeriveRawSecretAgreement(ECDiffieHellmanPublicKey otherPa return secretAgreement; } - private byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher) + private unsafe byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher) { if (!(otherPartyPublicKey is ECDiffieHellmanAppleCryptoPublicKey secTransPubKey)) { diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs index a064f682ca65c6..1f65d98a5bfa92 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -83,7 +83,7 @@ public override byte[] DeriveRawSecretAgreement(ECDiffieHellmanPublicKey otherPa /// /// Get the secret agreement generated between two parties /// - private byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher) + private unsafe byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher) { Debug.Assert(otherPartyPublicKey != null); Debug.Assert(_key is not null); // Callers should validate prior. diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECDsaAndroid.cs b/src/libraries/Common/src/System/Security/Cryptography/ECDsaAndroid.cs index 5061cbba1ed6ae..53730c2c7ca431 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECDsaAndroid.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECDsaAndroid.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -71,7 +71,7 @@ private void ForceSetKeySize(int newKeySize) // Return the three sizes that can be explicitly set (for backwards compatibility) public override KeySizes[] LegalKeySizes => s_defaultKeySizes.CloneKeySizesArray(); - public override byte[] SignHash(byte[] hash) + public override unsafe byte[] SignHash(byte[] hash) { ArgumentNullException.ThrowIfNull(hash); @@ -95,7 +95,7 @@ public override bool TrySignHash(ReadOnlySpan hash, Span destination out bytesWritten); } - protected override bool TrySignHashCore( + protected override unsafe bool TrySignHashCore( ReadOnlySpan hash, Span destination, DSASignatureFormat signatureFormat, @@ -189,7 +189,7 @@ public override bool VerifyHash(byte[] hash, byte[] signature) public override bool VerifyHash(ReadOnlySpan hash, ReadOnlySpan signature) => VerifyHashCore(hash, signature, DSASignatureFormat.IeeeP1363FixedFieldConcatenation); - protected override bool VerifyHashCore( + protected override unsafe bool VerifyHashCore( ReadOnlySpan hash, ReadOnlySpan signature, DSASignatureFormat signatureFormat) diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs index f399895d490f57..9c247641886752 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -79,7 +79,7 @@ private void ForceSetKeySize(int newKeySize) // Return the three sizes that can be explicitly set (for backwards compatibility) public override KeySizes[] LegalKeySizes => s_defaultKeySizes.CloneKeySizesArray(); - public override byte[] SignHash(byte[] hash) + public override unsafe byte[] SignHash(byte[] hash) { ArgumentNullException.ThrowIfNull(hash); ThrowIfDisposed(); @@ -103,7 +103,7 @@ public override bool TrySignHash(ReadOnlySpan hash, Span destination out bytesWritten); } - protected override bool TrySignHashCore( + protected override unsafe bool TrySignHashCore( ReadOnlySpan hash, Span destination, DSASignatureFormat signatureFormat, @@ -163,7 +163,7 @@ public override bool VerifyHash(byte[] hash, byte[] signature) public override bool VerifyHash(ReadOnlySpan hash, ReadOnlySpan signature) => VerifyHashCore(hash, signature, DSASignatureFormat.IeeeP1363FixedFieldConcatenation); - protected override bool VerifyHashCore( + protected override unsafe bool VerifyHashCore( ReadOnlySpan hash, ReadOnlySpan signature, DSASignatureFormat signatureFormat) diff --git a/src/libraries/Common/src/System/Security/Cryptography/KeyFormatHelper.Encrypted.cs b/src/libraries/Common/src/System/Security/Cryptography/KeyFormatHelper.Encrypted.cs index 01ae208960261d..629a13ac803fcd 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/KeyFormatHelper.Encrypted.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/KeyFormatHelper.Encrypted.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -139,7 +139,7 @@ internal static AsnWriter WriteEncryptedPkcs8( pbeParameters); } - private static AsnWriter WriteEncryptedPkcs8( + private static unsafe AsnWriter WriteEncryptedPkcs8( ReadOnlySpan password, ReadOnlySpan passwordBytes, AsnWriter pkcs8Writer, diff --git a/src/libraries/Common/src/System/Security/Cryptography/PasswordBasedEncryption.cs b/src/libraries/Common/src/System/Security/Cryptography/PasswordBasedEncryption.cs index 0ede657ed960f5..f9d87a1ce19947 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/PasswordBasedEncryption.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/PasswordBasedEncryption.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -841,7 +841,7 @@ private static unsafe Rfc2898DeriveBytes OpenPbkdf2( } } - private static int Pbes1Decrypt( + private static unsafe int Pbes1Decrypt( OptionalReadOnlySpan algorithmParameters, ReadOnlySpan password, IncrementalHash hasher, @@ -1015,7 +1015,7 @@ private static unsafe int Decrypt( } } - private static void Pbkdf1( + private static unsafe void Pbkdf1( IncrementalHash hasher, ReadOnlySpan password, ReadOnlySpan salt, diff --git a/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12Builder.cs b/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12Builder.cs index c8dc35a5980910..44580c87521742 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12Builder.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12Builder.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -145,7 +145,7 @@ public void SealWithMac( iterationCount); } - public void SealWithMac( + public unsafe void SealWithMac( ReadOnlySpan password, HashAlgorithmName hashAlgorithm, int iterationCount) diff --git a/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12SafeContents.cs b/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12SafeContents.cs index c6c4b225a845a7..f9b1fbd1b42b8f 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12SafeContents.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Pkcs/Pkcs12SafeContents.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; @@ -411,7 +411,7 @@ private static List ReadBagsCore( return bags; } - internal byte[] Encrypt( + internal unsafe byte[] Encrypt( ReadOnlySpan password, ReadOnlySpan passwordBytes, PbeParameters pbeParameters) diff --git a/src/libraries/Common/src/System/Security/Cryptography/Pkcs12Kdf.cs b/src/libraries/Common/src/System/Security/Cryptography/Pkcs12Kdf.cs index cfda2b57cad316..e8af4553efa4b1 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Pkcs12Kdf.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Pkcs12Kdf.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; @@ -74,7 +74,7 @@ internal static void DeriveMacKey( destination); } - private static void Derive( + private static unsafe void Derive( ReadOnlySpan password, HashAlgorithmName hashAlgorithm, int iterationCount, diff --git a/src/libraries/Common/src/System/Security/Cryptography/PqcBlobHelpers.cs b/src/libraries/Common/src/System/Security/Cryptography/PqcBlobHelpers.cs index 21d2e00a78a6c6..6ebd7ef45d4560 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/PqcBlobHelpers.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/PqcBlobHelpers.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -96,7 +96,7 @@ internal static ReadOnlySpan DecodeMLDsaBlob( return data; } - private static TResult EncodePQDsaBlob( + private static unsafe TResult EncodePQDsaBlob( KeyBlobMagicNumber magic, ReadOnlySpan parameterSet, ReadOnlySpan data, diff --git a/src/libraries/Common/src/System/Security/Cryptography/RSAAndroid.cs b/src/libraries/Common/src/System/Security/Cryptography/RSAAndroid.cs index 6c0a8da998dc42..98cf22419b7dd2 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/RSAAndroid.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/RSAAndroid.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -105,7 +105,7 @@ public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding) } } - public override bool TryDecrypt( + public override unsafe bool TryDecrypt( ReadOnlySpan data, Span destination, RSAEncryptionPadding padding, diff --git a/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs index 060f002ebb527f..767c0ac160d582 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -104,7 +104,7 @@ public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding) } } - public override bool TryDecrypt( + public override unsafe bool TryDecrypt( ReadOnlySpan data, Span destination, RSAEncryptionPadding padding, diff --git a/src/libraries/Common/src/System/Security/Cryptography/RsaPaddingProcessor.cs b/src/libraries/Common/src/System/Security/Cryptography/RsaPaddingProcessor.cs index d4d493f3daca54..e40fcf54ac1c7c 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/RsaPaddingProcessor.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/RsaPaddingProcessor.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -285,7 +285,7 @@ internal static void PadPkcs1Signature( source.CopyTo(destination.Slice(paddingLength + 3 + digestInfoPrefix.Length)); } - internal static void PadOaep( + internal static unsafe void PadOaep( HashAlgorithmName hashAlgorithmName, ReadOnlySpan source, Span destination) @@ -380,7 +380,7 @@ internal static void PadOaep( } } - internal static void EncodePss(HashAlgorithmName hashAlgorithmName, ReadOnlySpan mHash, Span destination, int keySize) + internal static unsafe void EncodePss(HashAlgorithmName hashAlgorithmName, ReadOnlySpan mHash, Span destination, int keySize) { int hLen = HashLength(hashAlgorithmName); @@ -469,7 +469,7 @@ internal static void EncodePss(HashAlgorithmName hashAlgorithmName, ReadOnlySpan CryptoPool.Return(dbMaskRented, clearSize: 0); } - internal static bool VerifyPss(HashAlgorithmName hashAlgorithmName, ReadOnlySpan mHash, ReadOnlySpan em, int keySize) + internal static unsafe bool VerifyPss(HashAlgorithmName hashAlgorithmName, ReadOnlySpan mHash, ReadOnlySpan em, int keySize) { int hLen = HashLength(hashAlgorithmName); @@ -585,7 +585,7 @@ internal static bool VerifyPss(HashAlgorithmName hashAlgorithmName, ReadOnlySpan } // https://tools.ietf.org/html/rfc3447#appendix-B.2.1 - private static void Mgf1(IncrementalHash hasher, ReadOnlySpan mgfSeed, Span mask) + private static unsafe void Mgf1(IncrementalHash hasher, ReadOnlySpan mgfSeed, Span mask) { int hLen = hasher.HashLengthInBytes; Span writePtr = mask; diff --git a/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdfImplementationCng.cs b/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdfImplementationCng.cs index e02a47a072ada2..f6d8d7cb889b1b 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdfImplementationCng.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdfImplementationCng.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -85,7 +85,7 @@ internal override unsafe void DeriveBytes(ReadOnlySpan label, ReadOnlySpan } } - internal override void DeriveBytes(ReadOnlySpan label, ReadOnlySpan context, Span destination) + internal override unsafe void DeriveBytes(ReadOnlySpan label, ReadOnlySpan context, Span destination) { using (Utf8DataEncoding labelData = new Utf8DataEncoding(label, stackalloc byte[CharToBytesStackBufferSize])) using (Utf8DataEncoding contextData = new Utf8DataEncoding(context, stackalloc byte[CharToBytesStackBufferSize])) @@ -109,7 +109,7 @@ internal static void DeriveBytesOneShot( } } - internal static void DeriveBytesOneShot( + internal static unsafe void DeriveBytesOneShot( ReadOnlySpan key, HashAlgorithmName hashAlgorithm, ReadOnlySpan label, diff --git a/src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs b/src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs index d8ed8f1aaaf7f0..9d3892fc926521 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -648,7 +648,7 @@ public bool TryExportPkcs8PrivateKey(Span destination, out int bytesWritte /// /// An error occurred while exporting the key. /// - protected virtual bool TryExportPkcs8PrivateKeyCore(Span destination, out int bytesWritten) + protected virtual unsafe bool TryExportPkcs8PrivateKeyCore(Span destination, out int bytesWritten) { // Private key size for SLH-DSA is at most 128 bytes so we can stack allocate it. int privateKeySizeInBytes = Algorithm.PrivateKeySizeInBytes; @@ -1862,7 +1862,7 @@ protected virtual void Dispose(bool disposing) /// protected abstract void ExportSlhDsaPrivateKeyCore(Span destination); - private AsnWriter ExportSubjectPublicKeyInfoCore() + private unsafe AsnWriter ExportSubjectPublicKeyInfoCore() { // Public key size for SLH-DSA is at most 64 bytes so we can stack allocate it. int publicKeySizeInBytes = Algorithm.PublicKeySizeInBytes; diff --git a/src/libraries/Common/src/System/Security/Cryptography/SlhDsaImplementation.cs b/src/libraries/Common/src/System/Security/Cryptography/SlhDsaImplementation.cs index 80b5c95ce9f1c8..b5405fc7e05f58 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/SlhDsaImplementation.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/SlhDsaImplementation.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; @@ -20,7 +20,7 @@ internal sealed partial class SlhDsaImplementation : SlhDsa /// Duplicates an SLH-DSA private key by export/import. /// Only intended to be used when the key type is unknown. /// - internal static SlhDsaImplementation DuplicatePrivateKey(SlhDsa key) + internal static unsafe SlhDsaImplementation DuplicatePrivateKey(SlhDsa key) { Debug.Assert(key is not SlhDsaImplementation); Debug.Assert(key.Algorithm.PrivateKeySizeInBytes <= 128); diff --git a/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.Pkcs12.cs b/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.Pkcs12.cs index edc52dc82367ca..a4aebb41952028 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.Pkcs12.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.Pkcs12.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -1192,11 +1192,7 @@ internal void UnshroudKeys(ref ReadOnlySpan password) } } - internal -#if !NET - unsafe -#endif - ArraySegment ToPfx(ReadOnlySpan password) + internal unsafe ArraySegment ToPfx(ReadOnlySpan password) { Debug.Assert(_certBags is not null); Debug.Assert(_keyBags is not null); diff --git a/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.cs b/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.cs index 4f801a56862bb6..58a4a96f36be3d 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/X509Certificates/X509CertificateLoader.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; @@ -580,7 +580,7 @@ private static T LoadFromFile( } } - private static (byte[]?, int, MemoryManager?) ReadAllBytesIfBerSequence(string path) + private static unsafe (byte[]?, int, MemoryManager?) ReadAllBytesIfBerSequence(string path) { // The expected header in a PFX is 30 82 XX XX, but since it's BER-encoded // it could be up to 30 FE 00 00 00 .. XX YY ZZ AA and still be within the diff --git a/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs b/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs index fa42ba627247e4..eda3f3552ae0e5 100644 --- a/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs +++ b/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers.Binary; @@ -24,7 +24,7 @@ internal struct Sha1ForNonSecretPurposes /// /// The data to hash. /// The buffer to receive the hash value. - public static void HashData(ReadOnlySpan source, Span destination) + public static unsafe void HashData(ReadOnlySpan source, Span destination) { Debug.Assert(destination.Length == 20); diff --git a/src/libraries/Microsoft.Extensions.Diagnostics/src/Microsoft.Extensions.Diagnostics.csproj b/src/libraries/Microsoft.Extensions.Diagnostics/src/Microsoft.Extensions.Diagnostics.csproj index d56673fdeda709..7d2267b7d4fe34 100644 --- a/src/libraries/Microsoft.Extensions.Diagnostics/src/Microsoft.Extensions.Diagnostics.csproj +++ b/src/libraries/Microsoft.Extensions.Diagnostics/src/Microsoft.Extensions.Diagnostics.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + true true true This package includes the default implementation of IMeterFactory and additional extension methods to easily register it with the Dependency Injection framework. diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/tests/Microsoft.Extensions.Hosting.Abstractions.Tests.csproj b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/tests/Microsoft.Extensions.Hosting.Abstractions.Tests.csproj index 6e3037bad5e40a..86468f5456b163 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/tests/Microsoft.Extensions.Hosting.Abstractions.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/tests/Microsoft.Extensions.Hosting.Abstractions.Tests.csproj @@ -3,6 +3,8 @@ $(NetCoreAppCurrent);$(NetFrameworkCurrent) true + + $(NoWarn);NU1511 diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/TrimmingTests/Microsoft.Extensions.Hosting.TrimmingTests.proj b/src/libraries/Microsoft.Extensions.Hosting/tests/TrimmingTests/Microsoft.Extensions.Hosting.TrimmingTests.proj index 61e8e1a7596653..3f609b484f1a01 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/tests/TrimmingTests/Microsoft.Extensions.Hosting.TrimmingTests.proj +++ b/src/libraries/Microsoft.Extensions.Hosting/tests/TrimmingTests/Microsoft.Extensions.Hosting.TrimmingTests.proj @@ -2,7 +2,7 @@ - Microsoft.Extensions.Hosting.Abstractions;Microsoft.Extensions.DependencyInjection + Microsoft.Extensions.DependencyInjection diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs index e80953f33b84ee..0991b45ea6b2bf 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs @@ -925,7 +925,9 @@ protected override void OnEventWritten(EventWrittenEventArgs eventWrittenArgs) } else { +#pragma warning disable IL2026 // https://github.com/dotnet/runtime/issues/126862 string serializedComplexValue = JsonConvert.SerializeObject(eventWrittenArgs.Payload[i]); +#pragma warning restore IL2026 writer.WriteRawValue(serializedComplexValue); } } diff --git a/src/libraries/Microsoft.Extensions.Options/tests/TrimmingTests/Microsoft.Extensions.Options.TrimmingTests.proj b/src/libraries/Microsoft.Extensions.Options/tests/TrimmingTests/Microsoft.Extensions.Options.TrimmingTests.proj index 15b6dc0a6ea0e2..db94e9ac4d54bd 100644 --- a/src/libraries/Microsoft.Extensions.Options/tests/TrimmingTests/Microsoft.Extensions.Options.TrimmingTests.proj +++ b/src/libraries/Microsoft.Extensions.Options/tests/TrimmingTests/Microsoft.Extensions.Options.TrimmingTests.proj @@ -3,7 +3,6 @@ - Microsoft.Extensions.Options; Microsoft.Extensions.DependencyInjection diff --git a/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.cs b/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.cs index 5da1144cd2e94a..6f77b489ebe2cb 100644 --- a/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.cs +++ b/src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.cs @@ -755,7 +755,7 @@ public static RegistryKey FromHandle(SafeRegistryHandle handle, RegistryView vie /// Retrieves an array of strings containing all the subkey names. /// All subkey names. - public string[] GetSubKeyNames() + public unsafe string[] GetSubKeyNames() { int subkeys = SubKeyCount; diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs index 8af41f5b5b5079..33f34d7552a6e3 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs @@ -1363,7 +1363,7 @@ public bool Overlaps(IEnumerable other) /// An earlier implementation used delegates to perform these checks rather than returning /// an ElementCount struct; however this was changed due to the perf overhead of delegates. /// - private ElementCount CheckUniqueAndUnfoundElements(IEnumerable other, bool returnIfUnfound) + private unsafe ElementCount CheckUniqueAndUnfoundElements(IEnumerable other, bool returnIfUnfound) { ElementCount result; diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs index 3bf597d297aa65..6d371bf88819ac 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs @@ -88,7 +88,7 @@ public CharDescriptor(int maskPos, CharType charType) CharType = charType; } - public override string ToString() => + public override unsafe string ToString() => string.Create( CultureInfo.InvariantCulture, stackalloc char[256], diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs index 2eb67b204463eb..bf69e52414a17e 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs @@ -22,7 +22,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen( return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType); } - public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + public override unsafe object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { if (value is string strValue) { diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs index a4f1b489e43ec7..4a27a012b1d309 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs @@ -22,7 +22,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen( return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType); } - public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + public override unsafe object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { if (value is string strValue) { diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs index 24b8cec971c98e..74d189c26bf902 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs @@ -22,7 +22,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen( return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType); } - public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + public override unsafe object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { if (value is string strValue) { diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs index 27e9935194bf95..c53054b30fe73c 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs @@ -22,7 +22,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen( return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType); } - public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + public override unsafe object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { if (value is string strValue) { diff --git a/src/libraries/System.Console/src/System/ConsolePal.Unix.cs b/src/libraries/System.Console/src/System/ConsolePal.Unix.cs index 5ddf6b1e737353..a0f7d10e728577 100644 --- a/src/libraries/System.Console/src/System/ConsolePal.Unix.cs +++ b/src/libraries/System.Console/src/System/ConsolePal.Unix.cs @@ -436,7 +436,7 @@ public static (int Left, int Top) GetCursorPosition() /// Cursor column. /// Cursor row. /// Indicates whether this method is called as part of a on-going Read operation. - internal static bool TryGetCursorPosition(out int left, out int top, bool reinitializeForRead = false) + internal static unsafe bool TryGetCursorPosition(out int left, out int top, bool reinitializeForRead = false) { Debug.Assert(!Console.IsInputRedirected); @@ -1122,7 +1122,7 @@ internal static void WriteTerminalAnsiColorString(string? value) /// The string to write. /// Handle to use instead of s_terminalHandle. /// Writing this value may change the cursor position. - internal static void WriteTerminalAnsiString(string? value, SafeFileHandle? handle = null, bool mayChangeCursorPosition = true) + internal static unsafe void WriteTerminalAnsiString(string? value, SafeFileHandle? handle = null, bool mayChangeCursorPosition = true) { if (string.IsNullOrEmpty(value)) return; diff --git a/src/libraries/System.Console/src/System/ConsolePal.Windows.cs b/src/libraries/System.Console/src/System/ConsolePal.Windows.cs index 64b1acc8e83966..c1e813cd1f697d 100644 --- a/src/libraries/System.Console/src/System/ConsolePal.Windows.cs +++ b/src/libraries/System.Console/src/System/ConsolePal.Windows.cs @@ -621,7 +621,7 @@ public static bool CursorVisible } } - public static (int Left, int Top) GetCursorPosition() + public static unsafe (int Left, int Top) GetCursorPosition() { Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); return (csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y); @@ -683,7 +683,7 @@ public static unsafe string Title } } - public static void Beep() + public static unsafe void Beep() { if (!Console.IsOutputRedirected) { diff --git a/src/libraries/System.Console/src/System/IO/CachedConsoleStream.cs b/src/libraries/System.Console/src/System/IO/CachedConsoleStream.cs index d59bd2057c2c32..642a7c744e9c93 100644 --- a/src/libraries/System.Console/src/System/IO/CachedConsoleStream.cs +++ b/src/libraries/System.Console/src/System/IO/CachedConsoleStream.cs @@ -22,7 +22,7 @@ public CachedConsoleStream(Encoding encoding) : base(FileAccess.Write) public override int Read(Span buffer) => throw Error.GetReadNotSupported(); - public override void Write(ReadOnlySpan buffer) + public override unsafe void Write(ReadOnlySpan buffer) { int maxCharCount = _encoding.GetMaxCharCount(buffer.Length); char[]? pooledBuffer = null; diff --git a/src/libraries/System.Console/src/System/IO/StdInReader.cs b/src/libraries/System.Console/src/System/IO/StdInReader.cs index 97b3d35cd06732..b2aabb5fc74a6d 100644 --- a/src/libraries/System.Console/src/System/IO/StdInReader.cs +++ b/src/libraries/System.Console/src/System/IO/StdInReader.cs @@ -51,7 +51,7 @@ internal bool IsUnprocessedBufferEmpty() return _startIndex >= _endIndex; // Everything has been processed; } - internal void AppendExtraBuffer(ReadOnlySpan buffer) + internal unsafe void AppendExtraBuffer(ReadOnlySpan buffer) { // Most inputs to this will have a buffer length of one. // The cases where it is larger than one only occur in ReadKey @@ -376,7 +376,7 @@ private unsafe ConsoleKeyInfo ReadKey() /// Gets whether there's input waiting on stdin. internal static bool StdinReady => Interop.Sys.StdinReady(); - private void EchoToTerminal(char c) + private unsafe void EchoToTerminal(char c) { Span bytes = stackalloc byte[32]; // 32 bytes seems ample int bytesWritten = 1; diff --git a/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs b/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs index 7ae7cc51e76de3..8ece8748073d93 100644 --- a/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs +++ b/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs @@ -100,7 +100,7 @@ private static bool TryOpen(string filePath, [NotNullWhen(true)] out SafeFileHan /// The identifier for the terminal. /// The path to the directory containing terminfo database files. /// The database, or null if it could not be found. - internal static Database? ReadDatabase(string? term, string? directoryPath) + internal static unsafe Database? ReadDatabase(string? term, string? directoryPath) { if (string.IsNullOrEmpty(term) || string.IsNullOrEmpty(directoryPath)) { diff --git a/src/libraries/System.Console/src/System/TermInfo.cs b/src/libraries/System.Console/src/System/TermInfo.cs index 32e4aa1cbfcab5..3dfbc92672ca60 100644 --- a/src/libraries/System.Console/src/System/TermInfo.cs +++ b/src/libraries/System.Console/src/System/TermInfo.cs @@ -97,7 +97,7 @@ public static string Evaluate(string format, params FormatParam[] args) /// The evaluation stack will have a 1 at the top if all processing was completed at invoked level /// of recursion, and a 0 at the top if we're still inside of a conditional that requires more processing. /// - private static string EvaluateInternal( + private static unsafe string EvaluateInternal( string format, ref int pos, FormatParam[] args, Stack stack, ref FormatParam[]? dynamicVars, ref FormatParam[]? staticVars) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs index b985e7ce88a186..66d5b5d4b19e0e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs @@ -477,7 +477,7 @@ private SqlDecimal(bool _) _data4 = s_uiZero; } - public SqlDecimal(decimal value) + public unsafe SqlDecimal(decimal value) { // set the null bit _bStatus = s_bNotNull; @@ -920,7 +920,7 @@ public byte[] BinData } } - public override string ToString() + public override unsafe string ToString() { if (IsNull) return SQLResource.NullString; @@ -1418,7 +1418,7 @@ public static explicit operator decimal(SqlDecimal x) // add to the next multiplicand UI4. Until the end of the multiplier data // array is reached. // - public static SqlDecimal operator *(SqlDecimal x, SqlDecimal y) + public static unsafe SqlDecimal operator *(SqlDecimal x, SqlDecimal y) { x.AssertValid(); y.AssertValid(); @@ -1657,7 +1657,7 @@ public static explicit operator decimal(SqlDecimal x) // Call general purpose arbitrary precision division routine with scale = 0. // Scale,prec adjusted later. // - public static SqlDecimal operator /(SqlDecimal x, SqlDecimal y) + public static unsafe SqlDecimal operator /(SqlDecimal x, SqlDecimal y) { if (x.IsNull || y.IsNull) return Null; diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs index 712300038479c8..08e5c72973fa43 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs @@ -110,7 +110,7 @@ public static SqlGuid Parse(string s) } // Comparison operators - private static EComparison Compare(SqlGuid x, SqlGuid y) + private static unsafe EComparison Compare(SqlGuid x, SqlGuid y) { // Comparison orders. ReadOnlySpan rgiGuidOrder = [10, 11, 12, 13, 14, 15, 8, 9, 6, 7, 4, 5, 0, 1, 2, 3]; diff --git a/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs b/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs index 3b8dc4033611ca..f4f2c3549eaece 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs @@ -294,7 +294,7 @@ private static NameType FindNameType(string name) private static readonly NameType s_enumerationNameType = FindNameType("enumeration"); [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] - private static Type ParseDataType(string dt, string dtValues) + private static unsafe Type ParseDataType(string dt, string dtValues) { string strType = dt; diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.GenerateRootId.netcoreapp.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.GenerateRootId.netcoreapp.cs index 80d282e1988359..9cdfd8be578eed 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.GenerateRootId.netcoreapp.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.GenerateRootId.netcoreapp.cs @@ -8,7 +8,7 @@ namespace System.Diagnostics { partial class Activity { - private static string GenerateRootId() + private static unsafe string GenerateRootId() { // It is important that the part that changes frequently be first, because // some sampling functions don't sample from the high entropy part of their hash function. diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs index 850670ce83bb05..2978ccfa4e7e1e 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs @@ -234,7 +234,7 @@ public string DisplayName /// - '|a000b421-5d183ab6.1.8e2d4c28_' - Id of the grand child activity. It was started in another process and ends with '_' /// 'a000b421-5d183ab6' is a for the first Activity and all its children /// - public string? Id + public unsafe string? Id { get { @@ -266,7 +266,7 @@ public string? Id /// /// See for more details /// - public string? ParentId + public unsafe string? ParentId { get { @@ -1952,7 +1952,7 @@ public enum ActivityIdFormat /// /// Create a new TraceId with at random number in it (very likely to be unique) /// - public static ActivityTraceId CreateRandom() + public static unsafe ActivityTraceId CreateRandom() { Span span = stackalloc byte[sizeof(ulong) * 2]; SetToRandomBytes(span); @@ -2019,7 +2019,7 @@ public override int GetHashCode() /// This is exposed as CreateFromUtf8String, but we are modifying fields, so the code needs to be in a constructor. /// /// - private ActivityTraceId(ReadOnlySpan idData) + private unsafe ActivityTraceId(ReadOnlySpan idData) { if (idData.Length != 32) throw new ArgumentOutOfRangeException(nameof(idData)); diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DsesSamplerBuilder.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DsesSamplerBuilder.cs index e10016a02c1026..3f224062ba3056 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DsesSamplerBuilder.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DsesSamplerBuilder.cs @@ -36,7 +36,7 @@ public static DsesSampleActivityFunc CreateParentRatioSampler(double ratio) }; } - public static ActivitySamplingResult ParentRatioSampler(long idUpperBound, in ActivityContext parentContext, ActivityTraceId traceId) + public static unsafe ActivitySamplingResult ParentRatioSampler(long idUpperBound, in ActivityContext parentContext, ActivityTraceId traceId) { if (parentContext.TraceId != default) { diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj index a7b648278a2a18..6aaa4ad2e062aa 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj +++ b/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser;$(NetFrameworkCurrent) + true true NU1511 true diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/src/System/Diagnostics/FileVersionInfo.Unix.cs b/src/libraries/System.Diagnostics.FileVersionInfo/src/System/Diagnostics/FileVersionInfo.Unix.cs index 7e6078c0c8a04f..87733d2985d5dd 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/src/System/Diagnostics/FileVersionInfo.Unix.cs +++ b/src/libraries/System.Diagnostics.FileVersionInfo/src/System/Diagnostics/FileVersionInfo.Unix.cs @@ -188,7 +188,7 @@ private void LoadManagedAssemblyMetadata(MetadataReader metadataReader, bool isE } /// Parses the version into its constituent parts. - private static void ParseVersion(string? versionString, out int major, out int minor, out int build, out int priv) + private static unsafe void ParseVersion(string? versionString, out int major, out int minor, out int build, out int priv) { // Relatively-forgiving parsing of a version: // - If there are more than four parts (separated by periods), all results are deemed 0 diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs index 74715a03aaa9e6..4b22d5bbd8e088 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs @@ -231,7 +231,7 @@ private void SetWorkingSetLimitsCore(IntPtr? newMin, IntPtr? newMax, out IntPtr /// Gets the name that was used to start the process, or null if it could not be retrieved. /// The pid for the target process. /// The stat for the target process. - internal static string GetUntruncatedProcessName(Interop.procfs.ProcPid procPid, ref Interop.procfs.ParsedStat stat) + internal static unsafe string GetUntruncatedProcessName(Interop.procfs.ProcPid procPid, ref Interop.procfs.ParsedStat stat) { string cmdLineFilePath = Interop.procfs.GetCmdLinePathForProcess(procPid); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Multiplexing.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Multiplexing.Unix.cs index d48cc914a766b6..4b4354c45bf6ec 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Multiplexing.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Multiplexing.Unix.cs @@ -261,7 +261,7 @@ private static void HandlePipeLineRead( /// Reads from both standard output and standard error pipes using Unix poll-based multiplexing /// with non-blocking reads. /// - private static void ReadPipes( + private static unsafe void ReadPipes( SafePipeHandle outputHandle, SafePipeHandle errorHandle, int timeoutMs, diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs index 068d68e36563db..87f4ac0d864e8e 100644 --- a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs +++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs @@ -387,7 +387,7 @@ private void InternalWrite(ReadOnlySpan message) _writer?.Write(message); } - private void InternalWrite(T message) where T : ISpanFormattable + private unsafe void InternalWrite(T message) where T : ISpanFormattable { Debug.Assert(typeof(T) == typeof(int) || typeof(T) == typeof(uint) || typeof(T) == typeof(long), "We only currently stackalloc enough space for these types."); @@ -401,7 +401,7 @@ private void InternalWrite(T message) where T : ISpanFormattable } } - private void InternalWrite(Guid message) + private unsafe void InternalWrite(Guid message) { EnsureWriter(); if (_writer is TextWriter writer) @@ -413,7 +413,7 @@ private void InternalWrite(Guid message) } } - private void InternalWrite(DateTime message) + private unsafe void InternalWrite(DateTime message) { EnsureWriter(); if (_writer is TextWriter writer) diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs index a23cab3659aa3f..8615808c8aa1d1 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs @@ -383,7 +383,7 @@ private void WriteHeader(string source, TraceEventType eventType, int id) Write(string.Create(CultureInfo.InvariantCulture, stackalloc char[256], $"{source} {eventType}: {id} : ")); } - private void WriteFooter(TraceEventCache? eventCache) + private unsafe void WriteFooter(TraceEventCache? eventCache) { if (eventCache == null) return; diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.GeneralizedTime.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.GeneralizedTime.cs index f5d8ed869dd55f..a2e6f0d7896e46 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.GeneralizedTime.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.GeneralizedTime.cs @@ -45,7 +45,7 @@ public static partial class AsnDecoder /// . is not correct for /// the method. /// - public static DateTimeOffset ReadGeneralizedTime( + public static unsafe DateTimeOffset ReadGeneralizedTime( ReadOnlySpan source, AsnEncodingRules ruleSet, out int bytesConsumed, diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.NamedBitList.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.NamedBitList.cs index 613d589d05e6ee..43f67d2f080388 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.NamedBitList.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.NamedBitList.cs @@ -174,7 +174,7 @@ public static TFlagsEnum ReadNamedBitListValue( /// is /// /// - public static Enum ReadNamedBitListValue( + public static unsafe Enum ReadNamedBitListValue( ReadOnlySpan source, AsnEncodingRules ruleSet, Type flagsEnumType, diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Oid.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Oid.cs index da03e2ccfab3dc..3708d9f6561583 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Oid.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Oid.cs @@ -76,7 +76,7 @@ public static string ReadObjectIdentifier( return ret; } - private static void ReadSubIdentifier( + private static unsafe void ReadSubIdentifier( ReadOnlySpan source, out int bytesRead, out long? smallValue, diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.UtcTime.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.UtcTime.cs index dc8b67fefc1261..a2b8b582f8399a 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.UtcTime.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.UtcTime.cs @@ -53,7 +53,7 @@ public static partial class AsnDecoder /// the method. /// /// - public static DateTimeOffset ReadUtcTime( + public static unsafe DateTimeOffset ReadUtcTime( ReadOnlySpan source, AsnEncodingRules ruleSet, out int bytesConsumed, diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.GeneralizedTime.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.GeneralizedTime.cs index 96d9d36571a002..195742965d3473 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.GeneralizedTime.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.GeneralizedTime.cs @@ -41,7 +41,7 @@ public void WriteGeneralizedTime( // T-REC-X.680-201508 sec 46 // T-REC-X.690-201508 sec 11.7 - private void WriteGeneralizedTimeCore( + private unsafe void WriteGeneralizedTimeCore( Asn1Tag tag, DateTimeOffset value, bool omitFractionalSeconds) diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.NamedBitList.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.NamedBitList.cs index 9dbe389f5d1df5..3af7ac487a2626 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.NamedBitList.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.NamedBitList.cs @@ -144,7 +144,7 @@ private void WriteNamedBitList(Asn1Tag? tag, Type tEnum, Enum value) // T-REC-X.680-201508 sec 22 // T-REC-X.690-201508 sec 8.6, 11.2.2 - private void WriteNamedBitList(Asn1Tag? tag, ulong integralValue) + private unsafe void WriteNamedBitList(Asn1Tag? tag, ulong integralValue) { Span temp = stackalloc byte[sizeof(ulong)]; // Reset to all zeros, since we're just going to or-in bits we need. diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs index 25d90ba867faff..22dc8a01235977 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs @@ -19,7 +19,7 @@ internal sealed partial class TarHeader // Attempts to retrieve the next header from the specified tar archive stream. // Throws if end of stream is reached or if any data type conversion fails. // Returns a valid TarHeader object if the attributes were read successfully, null otherwise. - internal static TarHeader? TryGetNextHeader(Stream archiveStream, bool copyData, TarEntryFormat initialFormat, bool processDataBlock) + internal static unsafe TarHeader? TryGetNextHeader(Stream archiveStream, bool copyData, TarEntryFormat initialFormat, bool processDataBlock) { // The four supported formats have a header that fits in the default record size Span buffer = stackalloc byte[TarHelpers.RecordSize]; diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs index 06c9d8ea52a459..c3d166da29389f 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs @@ -576,7 +576,7 @@ private int WriteName(Span buffer) // 'https://www.freebsd.org/cgi/man.cgi?tar(5)' // If the path name is too long to fit in the 100 bytes provided by the standard format, // it can be split at any / character with the first portion going into the prefix field. - private int WriteUstarName(Span buffer) + private unsafe int WriteUstarName(Span buffer) { // We can have a path name as big as 256, prefix + '/' + name, // the separator in between can be neglected as the reader will append it when it joins both fields. @@ -807,7 +807,7 @@ private void WriteData(Stream archiveStream, Stream dataStream) } // Calculates the padding for the current entry and writes it after the data. - private void WriteEmptyPadding(Stream archiveStream) + private unsafe void WriteEmptyPadding(Stream archiveStream) { int paddingAfterData = TarHelpers.CalculatePadding(_size); if (paddingAfterData != 0) @@ -861,7 +861,7 @@ private async Task WriteDataAsync(Stream archiveStream, Stream dataStream, Cance // Generates a data stream (seekable) containing the extended attribute metadata of the entry it precedes. // Returns a null stream if the extended attributes dictionary is empty. - private static MemoryStream? GenerateExtendedAttributesDataStream(Dictionary extendedAttributes) + private static unsafe MemoryStream? GenerateExtendedAttributesDataStream(Dictionary extendedAttributes) { MemoryStream? dataStream = null; @@ -955,7 +955,7 @@ private void CollectExtendedAttributesFromStandardFieldsIfNeeded(Dictionary buffer) + private static unsafe int WriteChecksum(int checksum, Span buffer) { // The checksum field is also counted towards the total sum // but as an array filled with spaces @@ -1117,7 +1117,7 @@ private int FormatNumeric(long value, Span destination) } // Writes the specified decimal number as a right-aligned octal number and returns its checksum. - private static int FormatOctal(long value, Span destination) + private static unsafe int FormatOctal(long value, Span destination) { ulong remaining = (ulong)value; Span digits = stackalloc byte[32]; // longer than any possible octal formatting of a ulong diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs index 209bbc0c1e7bdb..31a860cd993a26 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs @@ -314,7 +314,7 @@ public Task WriteEntryAsync(TarEntry entry, CancellationToken cancellationToken } // Portion of the WriteEntry(entry) method that rents a buffer and writes to the archive. - private void WriteEntryInternal(TarEntry entry) + private unsafe void WriteEntryInternal(TarEntry entry) { Span buffer = stackalloc byte[TarHelpers.RecordSize]; buffer.Clear(); @@ -379,7 +379,7 @@ private async Task WriteEntryAsyncInternal(TarEntry entry, CancellationToken can // The spec indicates that the end of the archive is indicated // by two records consisting entirely of zero bytes. - private void WriteFinalRecords() + private unsafe void WriteFinalRecords() { Span emptyRecord = stackalloc byte[TarHelpers.RecordSize]; emptyRecord.Clear(); diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/HuffmanTree.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/HuffmanTree.cs index a4f1f621df37ee..10b903b6918c4b 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/HuffmanTree.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/HuffmanTree.cs @@ -112,7 +112,7 @@ private static uint BitReverse(uint code, int length) // Calculate the huffman code for each character based on the code length for each character. // This algorithm is described in standard RFC 1951 - private uint[] CalculateHuffmanCode() + private unsafe uint[] CalculateHuffmanCode() { Span bitLengthCount = stackalloc uint[17]; bitLengthCount.Clear(); diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs index 9140a200898d95..e84666144c9379 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs @@ -667,7 +667,7 @@ private void WriteCentralDirectoryFileHeaderPrepare(Span cdStaticHeader, u } // should only throw an exception in extremely exceptional cases because it is called from dispose - internal void WriteCentralDirectoryFileHeader(bool forceWrite) + internal unsafe void WriteCentralDirectoryFileHeader(bool forceWrite) { if (WriteCentralDirectoryFileHeaderInitialize(forceWrite, out Zip64ExtraField? zip64ExtraField, out uint compressedSizeTruncated, out uint uncompressedSizeTruncated, out ushort extraFieldLength, out uint offsetOfLocalHeaderTruncated)) { @@ -1062,7 +1062,7 @@ private static BitFlagValues MapDeflateCompressionOption(BitFlagValues generalPu private bool ShouldUseZIP64 => AreSizesTooLarge || IsOffsetTooLarge; - private bool WriteLocalFileHeaderInitialize(bool isEmptyFile, bool forceWrite, bool preserveDataDescriptor, out Zip64ExtraField? zip64ExtraField, out uint compressedSizeTruncated, out uint uncompressedSizeTruncated, out ushort extraFieldLength, out uint crc32ToWrite) + private unsafe bool WriteLocalFileHeaderInitialize(bool isEmptyFile, bool forceWrite, bool preserveDataDescriptor, out Zip64ExtraField? zip64ExtraField, out uint compressedSizeTruncated, out uint uncompressedSizeTruncated, out ushort extraFieldLength, out uint crc32ToWrite) { // _entryname only gets set when we read in or call moveTo. MoveTo does a check, and // reading in should not be able to produce an entryname longer than ushort.MaxValue @@ -1200,7 +1200,7 @@ private void WriteLocalFileHeaderPrepare(Span lfStaticHeader, uint crc32, } // return value is true if we allocated an extra field for 64 bit headers, un/compressed size - private bool WriteLocalFileHeader(bool isEmptyFile, bool forceWrite, bool preserveDataDescriptor = false) + private unsafe bool WriteLocalFileHeader(bool isEmptyFile, bool forceWrite, bool preserveDataDescriptor = false) { if (WriteLocalFileHeaderInitialize(isEmptyFile, forceWrite, preserveDataDescriptor, out Zip64ExtraField? zip64ExtraField, out uint compressedSizeTruncated, out uint uncompressedSizeTruncated, out ushort extraFieldLength, out uint crc32ToWrite)) { @@ -1304,7 +1304,7 @@ private void WriteLocalFileHeaderAndDataIfNeeded(bool forceWrite) // Using _offsetOfLocalHeader, seeks back to where CRC and sizes should be in the header, // writes them, then seeks back to where you started // Assumes that the stream is currently at the end of the data - private void WriteCrcAndSizesInLocalHeader(bool zip64HeaderUsed) + private unsafe void WriteCrcAndSizesInLocalHeader(bool zip64HeaderUsed) { // Buffer has been sized to the largest data payload required: the 64-bit data descriptor. Span writeBuffer = stackalloc byte[Zip64DataDescriptorCrcAndSizesBufferLength]; @@ -1428,7 +1428,7 @@ private void WriteCrcAndSizesInLocalHeaderPrepareForWritingDataDescriptor(Span dataDescriptor = stackalloc byte[MaxSizeOfDataDescriptor]; int bytesToWrite = PrepareToWriteDataDescriptor(dataDescriptor); diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs index 5e70cf29fc5eaa..ee5bd67e21f65c 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs @@ -27,7 +27,7 @@ internal sealed partial class ZipGenericExtraField public ushort Size => _size; public byte[] Data => _data ??= []; - public void WriteBlock(Stream stream) + public unsafe void WriteBlock(Stream stream) { Span extraFieldHeader = stackalloc byte[SizeOfHeader]; WriteBlockCore(extraFieldHeader); @@ -395,7 +395,7 @@ public void WriteBlockCore(Span extraFieldData) } } - public void WriteBlock(Stream stream) + public unsafe void WriteBlock(Stream stream) { Span extraFieldData = stackalloc byte[TotalSize]; WriteBlockCore(extraFieldData); @@ -434,7 +434,7 @@ private static bool TryReadBlockCore(Span blockContents, int bytesRead, [N return true; } - public static Zip64EndOfCentralDirectoryLocator TryReadBlock(Stream stream) + public static unsafe Zip64EndOfCentralDirectoryLocator TryReadBlock(Stream stream) { Span blockContents = stackalloc byte[TotalSize]; int bytesRead = stream.ReadAtLeast(blockContents, blockContents.Length, throwOnEndOfStream: false); @@ -456,7 +456,7 @@ private static void WriteBlockCore(Span blockContents, long zip64EOCDRecor } - public static void WriteBlock(Stream stream, long zip64EOCDRecordStart) + public static unsafe void WriteBlock(Stream stream, long zip64EOCDRecordStart) { Span blockContents = stackalloc byte[TotalSize]; WriteBlockCore(blockContents, zip64EOCDRecordStart); @@ -513,7 +513,7 @@ private static bool TryReadBlockCore(Span blockContents, int bytesRead, [N return true; } - public static Zip64EndOfCentralDirectoryRecord TryReadBlock(Stream stream) + public static unsafe Zip64EndOfCentralDirectoryRecord TryReadBlock(Stream stream) { Span blockContents = stackalloc byte[BlockConstantSectionSize]; int bytesRead = stream.ReadAtLeast(blockContents, blockContents.Length, throwOnEndOfStream: false); @@ -545,7 +545,7 @@ private static void WriteBlockCore(Span blockContents, long numberOfEntrie BinaryPrimitives.WriteInt64LittleEndian(blockContents[FieldLocations.OffsetOfCentralDirectory..], startOfCentralDirectory); } - public static void WriteBlock(Stream stream, long numberOfEntries, long startOfCentralDirectory, long sizeOfCentralDirectory) + public static unsafe void WriteBlock(Stream stream, long numberOfEntries, long startOfCentralDirectory, long sizeOfCentralDirectory) { Span blockContents = stackalloc byte[BlockConstantSectionSize]; WriteBlockCore(blockContents, numberOfEntries, startOfCentralDirectory, sizeOfCentralDirectory); @@ -583,7 +583,7 @@ private static List GetExtraFieldPostReadWork(Span e return list; } - public static List GetExtraFields(Stream stream, out byte[] trailingData) + public static unsafe List GetExtraFields(Stream stream, out byte[] trailingData) { // assumes that TrySkipBlock has already been called, so we don't have to validate twice @@ -658,7 +658,7 @@ private static bool TrySkipBlockFinalize(Stream stream, Span blockBytes, i } // will not throw end of stream exception - public static bool TrySkipBlock(Stream stream) + public static unsafe bool TrySkipBlock(Stream stream) { Span blockBytes = stackalloc byte[FieldLengths.Signature]; long currPosition = stream.Position; @@ -897,7 +897,7 @@ private static void WriteBlockInitialize(Span blockContents, long numberOf BinaryPrimitives.WriteUInt16LittleEndian(blockContents[FieldLocations.ArchiveCommentLength..], (ushort)archiveComment.Length); } - public static void WriteBlock(Stream stream, long numberOfEntries, long startOfCentralDirectory, long sizeOfCentralDirectory, byte[] archiveComment) + public static unsafe void WriteBlock(Stream stream, long numberOfEntries, long startOfCentralDirectory, long sizeOfCentralDirectory, byte[] archiveComment) { Span blockContents = stackalloc byte[TotalSize]; @@ -956,7 +956,7 @@ private static bool TryReadBlockInitialize(Stream stream, Span blockConten return true; } - public static ZipEndOfCentralDirectoryBlock ReadBlock(Stream stream) + public static unsafe ZipEndOfCentralDirectoryBlock ReadBlock(Stream stream) { Span blockContents = stackalloc byte[TotalSize]; int bytesRead = stream.ReadAtLeast(blockContents, blockContents.Length, throwOnEndOfStream: false); diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardStream.Decompress.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardStream.Decompress.cs index 12f53f0ecf3ee8..092d7f413e2906 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardStream.Decompress.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardStream.Decompress.cs @@ -261,7 +261,7 @@ public override int EndRead(IAsyncResult asyncResult) /// The data is in an invalid format. /// The stream is disposed. /// Failed to decompress data from the underlying stream. - public override int ReadByte() + public override unsafe int ReadByte() { Span singleByte = stackalloc byte[1]; int bytesRead = Read(singleByte); diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs index 07edfcf2e2a2d0..90cff17d868040 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs @@ -513,7 +513,7 @@ private void ProcessEvents() } } - private bool ProcessEvent(NotifyEvent nextEvent, ref int movedFromWatchCount, ref string movedFromName, ref uint movedFromCookie, ref bool movedFromIsDir) + private unsafe bool ProcessEvent(NotifyEvent nextEvent, ref int movedFromWatchCount, ref string movedFromName, ref uint movedFromCookie, ref bool movedFromIsDir) { // Subset of EventMask that are emitted conditionally based on NotifyFilters.DirectoryName/FileName. const Interop.Sys.NotifyEvents FileDirEvents = diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.Unix.cs b/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.Unix.cs index 43f05c94272a8e..3bdb95dc70ec69 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.Unix.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.Unix.cs @@ -242,7 +242,7 @@ private static SafeFileHandle CreateSharedBackingObject(Interop.Sys.MemoryMapped } } - private static string GenerateMapName() + private static unsafe string GenerateMapName() { // macOS shm_open documentation says that the sys-call can fail with ENAMETOOLONG if the name exceeds SHM_NAME_MAX characters. // The problem is that SHM_NAME_MAX is not defined anywhere and is not consistent amongst macOS versions (arm64 vs x64 for example). diff --git a/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj b/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj index 92d5773be1dc15..0153a1de4f8437 100644 --- a/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj +++ b/src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + true false true Single producer single consumer byte buffer management. diff --git a/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/PipeReaderStream.cs b/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/PipeReaderStream.cs index 798defa268f313..e6b451feeac1ca 100644 --- a/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/PipeReaderStream.cs +++ b/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/PipeReaderStream.cs @@ -55,7 +55,7 @@ public override int Read(byte[] buffer, int offset, int count) return ReadInternal(new Span(buffer, offset, count)); } - public override int ReadByte() + public override unsafe int ReadByte() { Span oneByte = stackalloc byte[1]; return ReadInternal(oneByte) == 0 ? -1 : oneByte[0]; diff --git a/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj b/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj index 3a26aaa9d4aa3d..3823ac7617da78 100644 --- a/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj +++ b/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent) + true $(DefineConstants);FEATURE_FAST_CREATE $(NoWarn);CA1859