diff --git a/NuGet.config b/NuGet.config index dc5a8ecb5664..3421aba79000 100644 --- a/NuGet.config +++ b/NuGet.config @@ -8,7 +8,7 @@ - + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 375162d1662c..d904caf43e0c 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,161 +1,161 @@ - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/android - 2c84312ffbf3225df1148e8f6c7cfdf4b31f8afa + d7f90faae8e11b59d6be85902d01136643bc848b https://github.com/dotnet/android d549e1dc4e2a083b08b4f24cb5495e81b99d79b5 - + https://github.com/dotnet/macios - a04ce3e59e7cdacfc2d9dfd6af6f75971be0841a + 9f5d610822e4dc76ba3b786a1112bb7bd2fc5ba1 - + https://github.com/dotnet/macios - a04ce3e59e7cdacfc2d9dfd6af6f75971be0841a + 9f5d610822e4dc76ba3b786a1112bb7bd2fc5ba1 - + https://github.com/dotnet/macios - a04ce3e59e7cdacfc2d9dfd6af6f75971be0841a + 9f5d610822e4dc76ba3b786a1112bb7bd2fc5ba1 - + https://github.com/dotnet/macios - a04ce3e59e7cdacfc2d9dfd6af6f75971be0841a + 9f5d610822e4dc76ba3b786a1112bb7bd2fc5ba1 - + https://github.com/dotnet/macios - 02e58e4268861b149cdbadb06b7e1aef6c939670 + e9727264cfecafbedcd0fbd0c89eac245058812a - + https://github.com/dotnet/macios - 02e58e4268861b149cdbadb06b7e1aef6c939670 + e9727264cfecafbedcd0fbd0c89eac245058812a - + https://github.com/dotnet/macios - 02e58e4268861b149cdbadb06b7e1aef6c939670 + e9727264cfecafbedcd0fbd0c89eac245058812a - + https://github.com/dotnet/macios - 02e58e4268861b149cdbadb06b7e1aef6c939670 + e9727264cfecafbedcd0fbd0c89eac245058812a https://dev.azure.com/microsoft/ProjectReunion/_git/ProjectReunionInternal - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 https://github.com/dotnet/templating 3f4da9ced34942d83054e647f3b1d9d7dde281e8 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 https://github.com/dotnet/xharness @@ -175,37 +175,37 @@ - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 - + https://github.com/dotnet/dotnet - cb8306a63c5cf24e9381108a3a9eb58907fd0f60 + ab4a9a5f25db0b29e980a7acfab46bc4eca924c3 diff --git a/eng/Versions.props b/eng/Versions.props index 0d7d43f4d245..472b35c831e3 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -31,10 +31,10 @@ 10.0.20 - 11.0.100-preview.7.26365.101 + 11.0.100-preview.7.26378.106 $(MicrosoftNETSdkPackageVersion) - 11.0.0-preview.7.26365.101 + 11.0.0-preview.7.26378.106 $(MicrosoftNETCoreAppRefPackageVersion) $(MicrosoftNETCoreAppRefPackageVersion) $(MicrosoftNETCoreAppRefPackageVersion) @@ -42,18 +42,18 @@ 1.0.0-prerelease.26317.1 $(MicrosoftNETCoreAppRefPackageVersion) - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 10.3.0 10.3.0 11.0.0-preview.2.26103.111 @@ -63,41 +63,41 @@ 1.0.0-rc2 1.0.0-preview.260225.1 - 37.0.0-ci.main.2139 + 37.0.0-preview.7.2129 36.1.69 $(MicrosoftNetSdkAndroidManifest100100PackageVersion) - 26.5.11989-net11-p7 - 26.5.11989-net11-p7 - 26.5.11989-net11-p7 - 26.5.11989-net11-p7 + 26.5.11991-net11-p7 + 26.5.11991-net11-p7 + 26.5.11991-net11-p7 + 26.5.11991-net11-p7 - 26.5.10309 - 26.5.10309 - 26.5.10309 - 26.5.10309 + 26.5.10310 + 26.5.10310 + 26.5.10310 + 26.5.10310 8.0.148 0.5.0 - 2.3.1 - 10.0.28000.2526 - 1.4.0 - 1.0.4078.44 + 1.8.251106002 + 10.0.26100.4654 + 1.3.2 + 1.0.3179.45 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 - 11.0.0-preview.7.26365.101 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 + 11.0.0-preview.7.26378.106 10.0.2 $(MicrosoftAspNetCorePackageVersion) @@ -147,13 +147,14 @@ 0.9.0 4.2.3 9.0.0 - 11.0.0-beta.26365.101 - 11.0.0-beta.26365.101 - 11.0.0-beta.26365.101 - 11.0.0-beta.26365.101 + 11.0.0-beta.26378.106 + 11.0.0-beta.26378.106 + 11.0.0-beta.26378.106 + 11.0.0-beta.26378.106 1.1.87-gba258badda - 11.0.0-beta.26365.101 - 11.0.0-beta.26365.101 + 11.0.0-beta.26378.106 + 11.0.0-beta.26378.106 + 6.0.3-dotnet.4 17.6.0 diff --git a/eng/common/build.ps1 b/eng/common/build.ps1 index 2cbb725323e8..dd84699f500c 100644 --- a/eng/common/build.ps1 +++ b/eng/common/build.ps1 @@ -23,6 +23,7 @@ Param( [switch] $clean, [switch][Alias('pb')]$productBuild, [switch]$fromVMR, + [switch]$disablePipelineSetResult, [switch][Alias('bl')]$binaryLog, [string][Alias('bln')]$binaryLogName = '', [switch][Alias('nobl')]$excludeCIBinarylog, @@ -80,6 +81,7 @@ function Print-Usage() { Write-Host " -nodeReuse Sets nodereuse msbuild parameter ('true' or 'false')" Write-Host " -buildCheck Sets /check msbuild parameter" Write-Host " -fromVMR Set when building from within the VMR" + Write-Host " -disablePipelineSetResult Set to disable masking the actual exit code in the pipeline when the build fails" Write-Host "" Write-Host "Command line arguments not listed above are passed thru to msbuild." diff --git a/eng/common/build.sh b/eng/common/build.sh index 3a9fdcfd0f59..e37edd6cff34 100755 --- a/eng/common/build.sh +++ b/eng/common/build.sh @@ -40,12 +40,14 @@ usage() echo " --projects Project or solution file(s) to build" echo " --ci Set when running on CI server" echo " --excludeCIBinarylog Don't output binary log (short: -nobl)" + echo " --pipelinesLog Promote msbuild errors/warnings to Azure Pipelines timeline issues; defaults to on in CI (short: -pl)" echo " --prepareMachine Prepare machine for CI run, clean up processes after build" echo " --nodeReuse Sets nodereuse msbuild parameter ('true' or 'false')" echo " --warnAsError Sets warnaserror msbuild parameter ('true' or 'false')" echo " --warnNotAsError Sets a semi-colon delimited list of warning codes that should not be treated as errors" echo " --buildCheck Sets /check msbuild parameter" echo " --fromVMR Set when building from within the VMR" + echo " --disablePipelineSetResult Set to disable masking the actual exit code in the pipeline when the build fails" echo "" echo "Command line arguments not listed above are passed thru to msbuild." echo "Arguments can also be passed in with a single hyphen." @@ -68,6 +70,7 @@ build=false source_build=false product_build=false from_vmr=false +disable_pipeline_set_result=false rebuild=false test=false integration_test=false @@ -86,6 +89,7 @@ build_check=false binary_log=false binary_log_name='' exclude_ci_binary_log=false +pipelines_log=false projects='' configuration='' @@ -124,6 +128,9 @@ while [[ $# -gt 0 ]]; do -excludecibinarylog|-nobl) exclude_ci_binary_log=true ;; + -pipelineslog|-pl) + pipelines_log=true + ;; -restore|-r) restore=true ;; @@ -152,6 +159,9 @@ while [[ $# -gt 0 ]]; do -fromvmr|-from-vmr) from_vmr=true ;; + -disablepipelinesetresult|-disable-pipeline-set-result) + disable_pipeline_set_result=true + ;; -test|-t) test=true ;; @@ -213,6 +223,7 @@ if [[ -z "$configuration" ]]; then fi if [[ "$ci" == true ]]; then + pipelines_log=true # Disable node reuse on CI unless explicitly opted in via MSBUILD_NODEREUSE_ENABLED. # Internal testing only; this env var will be replaced with a switch (https://github.com/dotnet/arcade/issues/17013) and must not be depended on. if [[ "${MSBUILD_NODEREUSE_ENABLED:-}" != "1" ]]; then diff --git a/eng/common/core-templates/job/helix-job-monitor.yml b/eng/common/core-templates/job/helix-job-monitor.yml index 96287e55a15b..0da13cf69dbc 100644 --- a/eng/common/core-templates/job/helix-job-monitor.yml +++ b/eng/common/core-templates/job/helix-job-monitor.yml @@ -65,6 +65,14 @@ parameters: type: boolean default: true +# When true, test results are reported to Azure DevOps using the fully qualified test name +# (Namespace.Type.Method) as the stable automatedTestName and the visible title is qualified as +# well (--use-fully-qualified-test-name). Opt-in because it changes AzDO test identity and display; +# primarily useful for frameworks like MSTest whose display name is only the method name. +- name: useFullyQualifiedTestName + type: boolean + default: false + # Advanced: optional pipeline artifact (produced earlier in this run) that contains the tool # nupkg. When set, the artifact is downloaded and the tool is installed from the nupkg into # a local tool-path; this bypasses the repo's .config/dotnet-tools.json manifest and is @@ -176,11 +184,12 @@ jobs: set -euo pipefail toolArgs=( - --helix-base-uri '${{ parameters.helixBaseUri }}' - --polling-interval-seconds '${{ parameters.pollingIntervalSeconds }}' - --fail-on-failed-tests '${{ parameters.failWorkItemsWithFailedTests }}' - --max-wait-minutes "$((${{ parameters.timeoutInMinutes }} - 5))" # Set the tool's timeout slightly lower than the Azure DevOps job timeout to allow it to exit gracefully. - --stage-name '$(System.StageName)' + --helix-base-uri '${{ parameters.helixBaseUri }}' + --polling-interval-seconds '${{ parameters.pollingIntervalSeconds }}' + --fail-on-failed-tests '${{ parameters.failWorkItemsWithFailedTests }}' + --use-fully-qualified-test-name '${{ parameters.useFullyQualifiedTestName }}' + --max-wait-minutes "$((${{ parameters.timeoutInMinutes }} - 5))" # Set the tool's timeout slightly lower than the Azure DevOps job timeout to allow it to exit gracefully. + --stage-name '$(System.StageName)' ) organization='${{ parameters.organization }}' diff --git a/eng/common/core-templates/job/onelocbuild.yml b/eng/common/core-templates/job/onelocbuild.yml index 86ea9f635042..2816d2905a06 100644 --- a/eng/common/core-templates/job/onelocbuild.yml +++ b/eng/common/core-templates/job/onelocbuild.yml @@ -8,6 +8,12 @@ parameters: CeapexPat: $(dn-bot-ceapex-package-r) # PAT for the loc AzDO instance https://dev.azure.com/ceapex GithubPat: $(BotAccount-dotnet-bot-repo-PAT) + # Service connection for WIF-based Entra authentication to ceapex feeds (replaces CeapexPat). + # When set, dnceng/internal builds acquire a federated Entra token instead of using a PAT. + # All other projects (e.g. DevDiv, public), where this dnceng-scoped service connection does not + # exist, and any pipeline that sets this to '' fall back to PAT-based auth via the CeapexPat parameter. + CeapexServiceConnection: 'dnceng-onelocbuild-ceapex' + SourcesDirectory: $(System.DefaultWorkingDirectory) CreatePr: true AutoCompletePr: false @@ -74,6 +80,15 @@ jobs: displayName: Generate LocProject.json condition: ${{ parameters.condition }} + # Acquire an Entra token for ceapex feed access via WIF (dnceng/internal only). + # All other projects use PAT-based auth, since the ceapex service connection is scoped to dnceng/internal. + - ${{ if and(ne(parameters.CeapexServiceConnection, ''), eq(variables['System.TeamProject'], 'internal')) }}: + - template: /eng/common/templates/steps/get-federated-access-token.yml + parameters: + federatedServiceConnection: ${{ parameters.CeapexServiceConnection }} + outputVariableName: 'CeapexEntraToken' + condition: ${{ parameters.condition }} + - task: OneLocBuild@2 displayName: OneLocBuild env: @@ -89,7 +104,10 @@ jobs: isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }} isShouldReusePrSelected: ${{ parameters.ReusePr }} packageSourceAuth: patAuth - patVariable: ${{ parameters.CeapexPat }} + ${{ if and(ne(parameters.CeapexServiceConnection, ''), eq(variables['System.TeamProject'], 'internal')) }}: + patVariable: $(CeapexEntraToken) + ${{ if or(eq(parameters.CeapexServiceConnection, ''), ne(variables['System.TeamProject'], 'internal')) }}: + patVariable: ${{ parameters.CeapexPat }} ${{ if eq(parameters.RepoType, 'gitHub') }}: repoType: ${{ parameters.RepoType }} gitHubPatVariable: "${{ parameters.GithubPat }}" diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh index 453bb1ba5b1e..38a3512f148d 100755 --- a/eng/common/cross/build-rootfs.sh +++ b/eng/common/cross/build-rootfs.sh @@ -453,9 +453,12 @@ case "$__AlpineVersion" in elif [[ "$__AlpineArch" == "x86" ]]; then __AlpineVersion=3.17 # minimum version that supports lldb-dev __AlpinePackages+=" llvm15-libs" - elif [[ "$__AlpineArch" == "riscv64" || "$__AlpineArch" == "loongarch64" ]]; then + elif [[ "$__AlpineArch" == "loongarch64" ]]; then __AlpineVersion=3.21 # minimum version that supports lldb-dev __AlpinePackages+=" llvm19-libs" + elif [[ "$__AlpineArch" == "riscv64" ]]; then + __AlpineVersion=3.22 # lldb-dev requires 3.21+, but 3.22+ provides the newer linux-headers needed for RISC-V extension probes + __AlpinePackages+=" llvm20-libs" elif [[ -n "$__AlpineMajorVersion" ]]; then # use whichever alpine version is provided and select the latest toolchain libs __AlpineLlvmLibsLookup=1 diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake index ead7fe3ef263..70b71395e3ba 100644 --- a/eng/common/cross/toolchain.cmake +++ b/eng/common/cross/toolchain.cmake @@ -87,6 +87,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "ppc64le") set(CMAKE_SYSTEM_PROCESSOR ppc64le) if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/powerpc64le-alpine-linux-musl) set(TOOLCHAIN "powerpc64le-alpine-linux-musl") + elseif(FREEBSD) + set(TOOLCHAIN "powerpc64le-unknown-freebsd14") else() set(TOOLCHAIN "powerpc64le-linux-gnu") endif() diff --git a/eng/common/native/init-os-and-arch.sh b/eng/common/native/init-os-and-arch.sh index 38921d4338f7..62d62fed522a 100644 --- a/eng/common/native/init-os-and-arch.sh +++ b/eng/common/native/init-os-and-arch.sh @@ -27,6 +27,10 @@ if [ "$os" = "sunos" ]; then os="solaris" fi CPUName=$(isainfo -n) +elif [ "$os" = "freebsd" ]; then + # FreeBSD's `uname -m` is the machine class ("powerpc" for every PowerPC + # variant); `uname -p` gives the specific processor (e.g. powerpc64le). + CPUName=$(uname -p) else # For the rest of the operating systems, use uname(1) to determine what the CPU is. CPUName=$(uname -m) @@ -75,7 +79,7 @@ case "$CPUName" in arch=s390x ;; - ppc64le) + ppc64le|powerpc64le) arch=ppc64le ;; *) diff --git a/eng/common/sdk-task.ps1 b/eng/common/sdk-task.ps1 index 68119de603ef..8d72d803dd2a 100644 --- a/eng/common/sdk-task.ps1 +++ b/eng/common/sdk-task.ps1 @@ -4,7 +4,9 @@ Param( [string] $task, [string] $verbosity = 'minimal', [string] $msbuildEngine = $null, - [switch] $restore, + # Restore defaults to on; -restore is retained only so existing consumers that pass it don't break. Use -norestore to opt out. + [switch] $restore = $true, + [switch] $norestore, [switch] $prepareMachine, [switch][Alias('nobl')]$excludeCIBinaryLog, [switch]$noWarnAsError, @@ -18,12 +20,23 @@ $ci = $true $binaryLog = if ($excludeCIBinaryLog) { $false } else { $true } $warnAsError = if ($noWarnAsError) { $false } else { $true } +# Reconcile the restore state before importing tools.ps1: it reads $restore at import time to +# decide whether toolset/SDK acquisition installs. -norestore must win so that skipping restore +# also skips toolset initialization, not just the explicit Restore build below. +if ($norestore) { $restore = $false } + +# sdk-task runs a standalone Arcade SDK task and does not need repo-specific toolset setup. +# Skip importing configure-toolset.ps1 so its side effects (e.g. a repo's configure-toolset.ps1 +# calling exit) don't terminate this script before the task runs. +$disableConfigureToolsetImport = $true + . $PSScriptRoot\tools.ps1 function Print-Usage() { Write-Host "Common settings:" Write-Host " -task Name of Arcade task (name of a project in toolset directory of the Arcade SDK package)" - Write-Host " -restore Restore dependencies" + Write-Host " -restore (Legacy) Restore runs by default; retained for backward compatibility. Use -norestore to skip" + Write-Host " -norestore Skip restoring dependencies" Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" Write-Host " -help Print help and exit" Write-Host "" diff --git a/eng/common/sdk-task.sh b/eng/common/sdk-task.sh index 1cf71bb2aea4..a7f1ba060d73 100644 --- a/eng/common/sdk-task.sh +++ b/eng/common/sdk-task.sh @@ -3,7 +3,8 @@ show_usage() { echo "Common settings:" echo " --task Name of Arcade task (name of a project in toolset directory of the Arcade SDK package)" - echo " --restore Restore dependencies" + echo " --restore (Legacy) Restore runs by default; retained for backward compatibility. Use --norestore to skip" + echo " --norestore Skip restoring dependencies" echo " --verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" echo " --help Print help and exit" echo "" @@ -50,10 +51,11 @@ binary_log=true configuration="Debug" verbosity="minimal" exclude_ci_binary_log=false -restore=false +# restore defaults to on; --restore is retained only so existing consumers that pass it don't break. Use --norestore to opt out. +restore=true help=false properties='' -warnAsError=true +warn_as_error=true while (($# > 0)); do lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" @@ -63,7 +65,10 @@ while (($# > 0)); do shift 2 ;; --restore) - restore=true + shift 1 + ;; + --norestore) + restore=false shift 1 ;; --verbosity) @@ -75,8 +80,8 @@ while (($# > 0)); do exclude_ci_binary_log=true shift 1 ;; - --noWarnAsError) - warnAsError=false + --nowarnaserror) + warn_as_error=false shift 1 ;; --help) @@ -97,6 +102,11 @@ if $help; then exit 0 fi +# sdk-task runs a standalone Arcade SDK task and does not need repo-specific toolset setup. +# Skip importing configure-toolset.sh so its side effects (e.g. a repo's configure-toolset.sh +# calling exit) don't terminate this script before the task runs. +disable_configure_toolset_import=1 + . "$scriptroot/tools.sh" InitializeToolset diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 6f664ad890ba..da07386ff1fe 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -13,6 +13,12 @@ # Set to true to output binary log from msbuild. Note that emitting binary log slows down the build. [bool]$binaryLog = if (Test-Path variable:binaryLog) { $binaryLog } else { $ci -and !$excludeCIBinarylog } +# Set to true to use the pipelines logger which will enable Azure logging output. +# https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md +# This flag is meant as a temporary opt-in for the feature while validating it across +# our consumers. It will be deleted in the future. +[bool]$pipelinesLog = if (Test-Path variable:pipelinesLog) { $pipelinesLog } else { $ci } + # Turns on machine preparation/clean up code that changes the machine state (e.g. kills build processes). [bool]$prepareMachine = if (Test-Path variable:prepareMachine) { $prepareMachine } else { $false } @@ -65,6 +71,8 @@ $ErrorActionPreference = 'Stop' # True when the build is running within the VMR. [bool]$fromVMR = if (Test-Path variable:fromVMR) { $fromVMR } else { $false } +[bool]$disablePipelineSetResult = if (Test-Path variable:disablePipelineSetResult) { $disablePipelineSetResult } else { $false } + function Create-Directory ([string[]] $path) { New-Item -Path $path -Force -ItemType 'Directory' | Out-Null } @@ -713,7 +721,17 @@ function InitializeToolset() { $downloadArgs += "--configfile" $downloadArgs += $nugetConfig } - DotNet @downloadArgs + + # 'dotnet package download' fails outright if any source in the repo's NuGet.config is + # unavailable (for example a transport feed that was decommissioned after a release). The + # Arcade SDK is always published to the public dotnet-eng feed, so if the config-driven + # download fails, retry once against that feed directly (which ignores the other sources) + # before giving up, so a single dead source doesn't block the build. + $downloadExitCode = DotNet -ignoreFailure @downloadArgs + if ($downloadExitCode) { + Write-Host "Restoring the Arcade SDK from the configured sources failed; retrying from the public dotnet-eng feed." + DotNet @downloadArgs --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" + } $packageDir = Join-Path $nugetPackageCachePath (Join-Path 'microsoft.dotnet.arcade.sdk' $toolsetVersion) $packageToolsetDir = Join-Path $packageDir 'toolset' @@ -775,6 +793,19 @@ function MSBuild() { $buildTool = InitializeBuildTool + if ($pipelinesLog) { + $toolsetBuildProject = InitializeToolset + $basePath = Split-Path -parent $toolsetBuildProject + $selectedPath = Join-Path $basePath (Join-Path 'net' 'Microsoft.DotNet.ArcadeLogging.dll') + + # Only inject the logger when it's present. A last-known-good Arcade used to bootstrap + # the build may not ship the logger yet, so its absence must not be a hard error. + # Specify the logger type explicitly so loading is deterministic. + if (Test-Path $selectedPath) { + $args += "/logger:Microsoft.DotNet.ArcadeLogging.PipelinesLogger,$selectedPath" + } + } + $cmdArgs = "$($buildTool.Command) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse /p:ContinuousIntegrationBuild=$ci" # Add -mt flag for MSBuild multithreaded mode if enabled via environment variable @@ -790,7 +821,8 @@ function MSBuild() { } if ($warnAsError -and $warnNotAsError) { - $cmdArgs += " /warnnotaserror:$warnNotAsError /p:AdditionalWarningsNotAsErrors=$warnNotAsError" + $escapedWarnNotAsError = $warnNotAsError -replace ';', '%3B' + $cmdArgs += " /warnnotaserror:$warnNotAsError /p:AdditionalWarningsNotAsErrors=$escapedWarnNotAsError" } foreach ($arg in $args) { @@ -813,8 +845,8 @@ function MSBuild() { Write-Host "Build failed with exit code $exitCode. Check errors above." -ForegroundColor Red # When running on Azure Pipelines, override the returned exit code to avoid double logging. - # Skip this when the build is a child of the VMR build. - if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR) { + # Skip this when the build is a child of the VMR build, or when -disablePipelineSetResult is set so the real exit code propagates. + if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR -and !$disablePipelineSetResult) { Write-PipelineSetResult -Result "Failed" -Message "msbuild execution failed." # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error @@ -829,7 +861,7 @@ function MSBuild() { # Executes a dotnet command with arguments passed to the function. # Terminates the script if the command fails. # -function DotNet() { +function DotNet([switch]$ignoreFailure) { $dotnetRoot = InitializeDotNetCli -install:$restore $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet') @@ -848,9 +880,15 @@ function DotNet() { $exitCode = Exec-Process $dotnetPath $cmdArgs if ($exitCode -ne 0) { + # When -ignoreFailure is set, return the exit code to the caller so it can implement + # its own fallback logic instead of terminating the script. + if ($ignoreFailure) { + return $exitCode + } + Write-Host "dotnet command failed with exit code $exitCode. Check errors above." -ForegroundColor Red - if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR) { + if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR -and !$disablePipelineSetResult) { Write-PipelineSetResult -Result "Failed" -Message "dotnet command execution failed." ExitWithExitCode 0 } else { diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 347a29b8884f..20f791c11dee 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -8,6 +8,16 @@ ci=${ci:-false} # Build mode source_build=${source_build:-false} +# Set to true to use the pipelines logger which will enable Azure logging output. +# https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md +# This flag is meant as a temporary opt-in for the feature while validating it across +# our consumers. It will be deleted in the future. +if [[ "$ci" == true ]]; then + pipelines_log=${pipelines_log:-true} +else + pipelines_log=${pipelines_log:-false} +fi + # Build configuration. Common values include 'Debug' and 'Release', but the repository may use other names. configuration=${configuration:-'Debug'} @@ -68,6 +78,8 @@ runtime_source_feed_key=${runtime_source_feed_key:-''} # True when the build is running within the VMR. from_vmr=${from_vmr:-false} +disable_pipeline_set_result=${disable_pipeline_set_result:-false} + # Resolve any symlinks in the given path. function ResolvePath { local path=$1 @@ -442,7 +454,16 @@ function InitializeToolset { if [[ -n "$nuget_config" ]]; then download_args+=("--configfile" "$nuget_config") fi - DotNet "${download_args[@]}" + + # 'dotnet package download' fails outright if any source in the repo's NuGet.config is + # unavailable (for example a transport feed that was decommissioned after a release). The + # Arcade SDK is always published to the public dotnet-eng feed, so if the config-driven + # download fails, retry once against that feed directly (which ignores the other sources) + # before giving up, so a single dead source doesn't block the build. + if ! DotNet true "${download_args[@]}"; then + echo "Restoring the Arcade SDK from the configured sources failed; retrying from the public dotnet-eng feed." + DotNet "${download_args[@]}" --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" + fi local package_dir="$_InitializeNuGetPackageCachePath/microsoft.dotnet.arcade.sdk/$toolset_version" @@ -481,6 +502,15 @@ function StopProcesses { } function DotNet { + # When the first argument is 'true' or 'false' it controls the exit behavior on failure: + # 'true' returns the dotnet exit code to the caller (so it can implement its own fallback), + # while the default terminates the script. Any other first argument is treated as a dotnet argument. + local ignore_failure=false + if [[ "$1" == 'true' || "$1" == 'false' ]]; then + ignore_failure="$1" + shift + fi + InitializeDotNetCli $restore local dotnet_path="$_InitializeDotNetCli/dotnet" @@ -489,9 +519,14 @@ function DotNet { "$dotnet_path" "$@" || { local exit_code=$? + + if [[ "$ignore_failure" == true ]]; then + return $exit_code + fi + echo "dotnet command failed with exit code $exit_code. Check errors above." - if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true ]]; then + if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true && "$disable_pipeline_set_result" != true ]]; then Write-PipelineSetResult -result "Failed" -message "dotnet command execution failed." ExitWithExitCode 0 else @@ -510,6 +545,21 @@ function MSBuild { InitializeBuildTool + local logger_switch=() + if [[ "$pipelines_log" == true ]]; then + InitializeToolset + + local toolset_dir="${_InitializeToolset%/*}" + local selectedPath="$toolset_dir/net/Microsoft.DotNet.ArcadeLogging.dll" + + # Only inject the logger when it's present. A last-known-good Arcade used to bootstrap + # the build may not ship the logger yet, so its absence must not be a hard error. + # Specify the logger type explicitly so loading is deterministic. + if [[ -f "$selectedPath" ]]; then + logger_switch=("-logger:Microsoft.DotNet.ArcadeLogging.PipelinesLogger,$selectedPath") + fi + fi + local warnaserror_switch="" if [[ $warn_as_error == true ]]; then warnaserror_switch="/warnaserror" @@ -525,8 +575,8 @@ function MSBuild { echo "Build failed with exit code $exit_code. Check errors above." # When running on Azure Pipelines, override the returned exit code to avoid double logging. - # Skip this when the build is a child of the VMR build. - if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true ]]; then + # Skip this when the build is a child of the VMR build, or when -disablePipelineSetResult is set so the real exit code propagates. + if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true && "$disable_pipeline_set_result" != true ]]; then Write-PipelineSetResult -result "Failed" -message "msbuild execution failed." # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error @@ -545,10 +595,10 @@ function MSBuild { local warnnotaserror_switch="" if [[ -n "$warn_not_as_error" && "$warn_as_error" == true ]]; then - warnnotaserror_switch="/warnnotaserror:$warn_not_as_error /p:AdditionalWarningsNotAsErrors=$warn_not_as_error" + warnnotaserror_switch="/warnnotaserror:$warn_not_as_error /p:AdditionalWarningsNotAsErrors=${warn_not_as_error//;/%3B}" fi - RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch $mt_switch $warnnotaserror_switch /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@" + RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch $mt_switch $warnnotaserror_switch ${logger_switch[@]+"${logger_switch[@]}"} /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@" } function GetDarc { diff --git a/global.json b/global.json index c1d546d17859..8033d239b26e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "11.0.100-preview.7.26365.101" + "dotnet": "11.0.100-preview.7.26378.106" }, "sdk": { "paths": [ @@ -11,7 +11,7 @@ "msbuild-sdks": { "MSBuild.Sdk.Extras": "3.0.44", "Microsoft.Build.NoTargets": "3.7.0", - "Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26365.101", - "Microsoft.DotNet.Helix.Sdk": "11.0.0-beta.26365.101" + "Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26378.106", + "Microsoft.DotNet.Helix.Sdk": "11.0.0-beta.26378.106" } } diff --git a/src/Controls/src/Build.Tasks/CompiledConverters/StrokeShapeTypeConverter.cs b/src/Controls/src/Build.Tasks/CompiledConverters/StrokeShapeTypeConverter.cs index 540afc94c762..4696d3c4deed 100644 --- a/src/Controls/src/Build.Tasks/CompiledConverters/StrokeShapeTypeConverter.cs +++ b/src/Controls/src/Build.Tasks/CompiledConverters/StrokeShapeTypeConverter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using Microsoft.Maui.Controls.Build.Tasks; using Microsoft.Maui.Controls.Shapes; using Microsoft.Maui.Controls.Xaml; @@ -190,9 +191,9 @@ public IEnumerable ConvertFromString(string value, ILContext contex yield break; } - if (double.TryParse(value, out double radius)) + if (double.TryParse(value, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out double radius)) { - yield return Instruction.Create(OpCodes.Newobj, module.ImportCtorReference(context.Cache, ("Microsoft.Maui.Controls", "Microsoft.Maui.Controls.Shapes", "Rectangle"), parameterTypes: null)); + yield return Instruction.Create(OpCodes.Newobj, module.ImportCtorReference(context.Cache, ("Microsoft.Maui.Controls", "Microsoft.Maui.Controls.Shapes", "RoundRectangle"), parameterTypes: null)); yield return Instruction.Create(OpCodes.Dup); yield return Instruction.Create(OpCodes.Ldc_R8, radius); diff --git a/src/Controls/src/Core/BindablePropertyConverter.cs b/src/Controls/src/Core/BindablePropertyConverter.cs index 23e89cb3b7e6..a6a34d6b61f9 100644 --- a/src/Controls/src/Core/BindablePropertyConverter.cs +++ b/src/Controls/src/Core/BindablePropertyConverter.cs @@ -1,4 +1,3 @@ -#nullable disable using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; @@ -9,161 +8,246 @@ using Microsoft.Extensions.Logging; using Microsoft.Maui.Controls.Xaml; -namespace Microsoft.Maui.Controls +namespace Microsoft.Maui.Controls; + +/// A TypeConverter that converts strings to instances. +[Xaml.ProvideCompiled("Microsoft.Maui.Controls.XamlC.BindablePropertyConverter")] +public sealed class BindablePropertyConverter : TypeConverter, IExtendedTypeConverter { - /// A TypeConverter that converts strings to instances. - [Xaml.ProvideCompiled("Microsoft.Maui.Controls.XamlC.BindablePropertyConverter")] - public sealed class BindablePropertyConverter : TypeConverter, IExtendedTypeConverter + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) + => sourceType == typeof(string); + + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) + => true; + + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - => sourceType == typeof(string); - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - => true; - - object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider) - { - if (string.IsNullOrWhiteSpace(value)) - return null; - if (serviceProvider == null) - return null; - if (!(serviceProvider.GetService(typeof(IXamlTypeResolver)) is IXamlTypeResolver typeResolver)) - return null; - IXmlLineInfo lineinfo = null; - if (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) is IXmlLineInfoProvider xmlLineInfoProvider) - lineinfo = xmlLineInfoProvider.XmlLineInfo; - string[] parts = value.Split('.'); - Type type = null; - if (parts.Length == 1) - { - if (!(serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideParentValues parentValuesProvider)) - { - string msg = string.Format("Can't resolve {0}", parts[0]); - throw new XamlParseException(msg, lineinfo); - } - object parent = parentValuesProvider.ParentObjects.Skip(1).FirstOrDefault(); - if (parentValuesProvider.TargetObject is Setter) - { - if (parent is Style style) - type = style.TargetType; - else if (parent is TriggerBase triggerBase) - type = triggerBase.TargetType; - else if (parent is VisualState visualState) - type = FindTypeForVisualState(parentValuesProvider, lineinfo); - } - else if (parentValuesProvider.TargetObject is Trigger) - type = (parentValuesProvider.TargetObject as Trigger).TargetType; - else if (parentValuesProvider.TargetObject is PropertyCondition && parent is TriggerBase) - type = (parent as TriggerBase).TargetType; - if (type == null) - throw new XamlParseException($"Can't resolve {parts[0]}", lineinfo); + var strValue = value?.ToString() ?? string.Empty; - return ConvertFrom(type, parts[0], lineinfo); - } - if (parts.Length == 2) - { - if (!typeResolver.TryResolve(parts[0], out type)) - { - string msg = string.Format("Can't resolve {0}", parts[0]); - throw new XamlParseException(msg, lineinfo); - } - return ConvertFrom(type, parts[1], lineinfo); - } - throw new XamlParseException($"Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyName.", lineinfo); + if (string.IsNullOrWhiteSpace(strValue)) + { + return null; } - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + if (strValue.IndexOf(":", StringComparison.Ordinal) != -1) + { + MauiLogger.Log(LogLevel.Warning, "Can't resolve properties with xml namespace prefix."); + return null; + } + string[] parts = strValue.Split('.'); + if (parts.Length != 2) { - var strValue = value?.ToString(); + MauiLogger.Log(LogLevel.Warning, $"Can't resolve {value}. Accepted syntax is Type.PropertyName."); + return null; + } + Type? type = GetControlType(parts[0]); + if (type == null) + { + MauiLogger.Log(LogLevel.Warning, $"Can't resolve {parts[0]}."); + return null; + } - if (string.IsNullOrWhiteSpace(strValue)) - return null; - if (strValue.IndexOf(":", StringComparison.Ordinal) != -1) - { - MauiLogger.Log(LogLevel.Warning, "Can't resolve properties with xml namespace prefix."); - return null; - } - string[] parts = strValue.Split('.'); - if (parts.Length != 2) - { - MauiLogger.Log(LogLevel.Warning, $"Can't resolve {value}. Accepted syntax is Type.PropertyName."); - return null; - } - Type type = GetControlType(parts[0]); - return ConvertFrom(type, parts[1], null); + return ConvertFrom(type, parts[1], null); + } + + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) + { + if (value is not BindableProperty bp) + { + throw new NotSupportedException(); + } + + return $"{bp.DeclaringType.Name}.{bp.PropertyName}"; + } + +#nullable disable + BindableProperty ConvertFrom(Type type, string propertyName, IXmlLineInfo lineinfo) + { + var name = propertyName + "Property"; + FieldInfo bpinfo = GetPropertyField(type, name); + if (bpinfo == null || bpinfo.FieldType != typeof(BindableProperty)) + { + throw new XamlParseException($"Can't resolve {name} on {type.Name}", lineinfo); + } + + var bp = bpinfo.GetValue(null) as BindableProperty; + if (bp == null) + { + throw new XamlParseException($"Can't resolve {name} on {type.Name}", lineinfo); + } + + var isObsolete = GetObsoleteAttribute(bpinfo) != null; + if (bp.PropertyName != propertyName && !isObsolete) + { + throw new XamlParseException($"The PropertyName of {type.Name}.{name} is not {propertyName}", lineinfo); + } + + return bp; + } + + [UnconditionalSuppressMessage("TrimAnalysis", "IL2045:AttributeRemoval", + Justification = "ObsoleteAttribute instances are removed by the trimmer in production builds.")] + static ObsoleteAttribute GetObsoleteAttribute(FieldInfo fieldInfo) + => fieldInfo.GetCustomAttribute(); + + [UnconditionalSuppressMessage("TrimAnalysis", "IL2057:TypeGetType", + Justification = "The converter is only used when parsing XAML at runtime. The developer will receive a warning " + + "saying that parsing XAML at runtime may not work as expected when trimming.")] +#nullable enable + static Type? GetControlType(string typeName) + => Type.GetType("Microsoft.Maui.Controls." + typeName); +#nullable disable + + [UnconditionalSuppressMessage("TrimAnalysis", "IL2070:UnrecognizedReflectionPattern", + Justification = "The converter is only used when parsing XAML at runtime. The developer will receive a warning " + + "saying that parsing XAML at runtime may not work as expected when trimming.")] + static FieldInfo GetPropertyField(Type type, string fieldName) + => type.GetField(fieldName, BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); + + Type FindTypeForVisualState(IProvideParentValues parentValueProvider, IXmlLineInfo lineInfo) + { + var parents = parentValueProvider.ParentObjects.ToList(); + + // Skip 0; we would not be making this check if TargetObject were not a Setter + // Skip 1; we would not be making this check if the immediate parent were not a VisualState + + if (parents.Count <= 2) + { + throw new XamlParseException($"Unable to find a TargetType for the Bindable Property. Try prefixing it with the TargetType.", lineInfo); } - BindableProperty ConvertFrom(Type type, string propertyName, IXmlLineInfo lineinfo) + // VisualStates must be in a VisualStateGroup + if (parents[2] is not VisualStateGroup) { - var name = propertyName + "Property"; - FieldInfo bpinfo = GetPropertyField(type, name); - if (bpinfo == null || bpinfo.FieldType != typeof(BindableProperty)) - throw new XamlParseException($"Can't resolve {name} on {type.Name}", lineinfo); - var bp = bpinfo.GetValue(null) as BindableProperty; - var isObsolete = GetObsoleteAttribute(bpinfo) != null; - if (bp.PropertyName != propertyName && !isObsolete) - throw new XamlParseException($"The PropertyName of {type.Name}.{name} is not {propertyName}", lineinfo); - return bp; + throw new XamlParseException($"Expected {nameof(VisualStateGroup)} but found {parents[2]}.", lineInfo); } - [UnconditionalSuppressMessage("TrimAnalysis", "IL2045:AttributeRemoval", - Justification = "ObsoleteAttribute instances are removed by the trimmer in production builds.")] - static ObsoleteAttribute GetObsoleteAttribute(FieldInfo fieldInfo) - => fieldInfo.GetCustomAttribute(); + if (parents.Count <= 3) + { + throw new XamlParseException($"Unable to find a TargetType for the Bindable Property. Try prefixing it with the TargetType.", lineInfo); + } - [UnconditionalSuppressMessage("TrimAnalysis", "IL2057:TypeGetType", - Justification = "The converter is only used when parsing XAML at runtime. The developer will receive a warning " + - "saying that parsing XAML at runtime may not work as expected when trimming.")] - static Type GetControlType(string typeName) - => Type.GetType("Microsoft.Maui.Controls." + typeName); + // Are these Visual States directly on a VisualElement? + if (parents[3] is VisualElement vsTarget) + { + return vsTarget.GetType(); + } - [UnconditionalSuppressMessage("TrimAnalysis", "IL2070:UnrecognizedReflectionPattern", - Justification = "The converter is only used when parsing XAML at runtime. The developer will receive a warning " + - "saying that parsing XAML at runtime may not work as expected when trimming.")] - static FieldInfo GetPropertyField(Type type, string fieldName) - => type.GetField(fieldName, BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); + if (parents[3] is not VisualStateGroupList) + { + throw new XamlParseException($"Expected {nameof(VisualStateGroupList)} but found {parents[3]}.", lineInfo); + } - Type FindTypeForVisualState(IProvideParentValues parentValueProvider, IXmlLineInfo lineInfo) + if (parents.Count <= 4) { - var parents = parentValueProvider.ParentObjects.ToList(); + throw new XamlParseException($"Unable to find a TargetType for the Bindable Property. Try prefixing it with the TargetType.", lineInfo); + } - // Skip 0; we would not be making this check if TargetObject were not a Setter - // Skip 1; we would not be making this check if the immediate parent were not a VisualState + if (parents[4] is VisualElement veTarget) + { + return veTarget.GetType(); + } - // VisualStates must be in a VisualStateGroup - if (parents[2] is not VisualStateGroup) - throw new XamlParseException($"Expected {nameof(VisualStateGroup)} but found {parents[2]}.", lineInfo); + if (parents[4] is not Setter) + { + throw new XamlParseException($"Expected {nameof(Setter)} but found {parents[4]}.", lineInfo); + } - // Are these Visual States directly on a VisualElement? - if (parents[3] is VisualElement vsTarget) - return vsTarget.GetType(); + if (parents.Count <= 5) + { + throw new XamlParseException($"Unable to find a TargetType for the Bindable Property. Try prefixing it with the TargetType.", lineInfo); + } - if (parents[3] is not VisualStateGroupList) - throw new XamlParseException($"Expected {nameof(VisualStateGroupList)} but found {parents[3]}.", lineInfo); + if (parents[5] is TriggerBase trigger) + { + return trigger.TargetType; + } - if (parents[4] is VisualElement veTarget) - return veTarget.GetType(); + // These must be part of a Style; verify that + if (parents[5] is Style style) + { + return style.TargetType; + } - if (parents[4] is not Setter) - throw new XamlParseException($"Expected {nameof(Setter)} but found {parents[4]}.", lineInfo); + throw new XamlParseException($"Unable to find a TargetType for the Bindable Property. Try prefixing it with the TargetType.", lineInfo); - if (parents[5] is TriggerBase trigger) - return trigger.TargetType; + } - // These must be part of a Style; verify that - if (parents[5] is Style style) - return style.TargetType; + object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider) + { + if (string.IsNullOrWhiteSpace(value)) + { + return null; + } - throw new XamlParseException($"Unable to find a TragetType for the Bindable Property. Try prefixing it with the TargetType.", lineInfo); + if (serviceProvider == null) + { + return null; + } + if (!(serviceProvider.GetService(typeof(IXamlTypeResolver)) is IXamlTypeResolver typeResolver)) + { + return null; } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + IXmlLineInfo lineinfo = null; + if (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) is IXmlLineInfoProvider xmlLineInfoProvider) { - if (value is not BindableProperty bp) - throw new NotSupportedException(); - return $"{bp.DeclaringType.Name}.{bp.PropertyName}"; + lineinfo = xmlLineInfoProvider.XmlLineInfo; } + + string[] parts = value.Split('.'); + Type type = null; + if (parts.Length == 1) + { + if (!(serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideParentValues parentValuesProvider)) + { + string msg = string.Format("Can't resolve {0}", parts[0]); + throw new XamlParseException(msg, lineinfo); + } + object parent = parentValuesProvider.ParentObjects.Skip(1).FirstOrDefault(); + if (parentValuesProvider.TargetObject is Setter) + { + if (parent is Style style) + { + type = style.TargetType; + } + else if (parent is TriggerBase triggerBase) + { + type = triggerBase.TargetType; + } + else if (parent is VisualState visualState) + { + type = FindTypeForVisualState(parentValuesProvider, lineinfo); + } + } + else if (parentValuesProvider.TargetObject is Trigger) + { + type = (parentValuesProvider.TargetObject as Trigger).TargetType; + } + else if (parentValuesProvider.TargetObject is PropertyCondition && parent is TriggerBase) + { + type = (parent as TriggerBase).TargetType; + } + + if (type == null) + { + throw new XamlParseException($"Can't resolve {parts[0]}", lineinfo); + } + + return ConvertFrom(type, parts[0], lineinfo); + } + if (parts.Length == 2) + { + if (!typeResolver.TryResolve(parts[0], out type)) + { + string msg = string.Format("Can't resolve {0}", parts[0]); + throw new XamlParseException(msg, lineinfo); + } + return ConvertFrom(type, parts[1], lineinfo); + } + throw new XamlParseException($"Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyName.", lineinfo); } + } diff --git a/src/Controls/src/Core/Button/Button.cs b/src/Controls/src/Core/Button/Button.cs index cc87be1f60c8..c3486e2901d4 100644 --- a/src/Controls/src/Core/Button/Button.cs +++ b/src/Controls/src/Core/Button/Button.cs @@ -565,29 +565,29 @@ public ButtonContentLayout(ImagePosition position, double spacing) /// Prints out the values of and . public override string ToString() => $"Image Position = {Position}, Spacing = {Spacing}"; } - +#nullable enable /// /// A converter to convert a string to a object. /// public sealed class ButtonContentTypeConverter : TypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(string); - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => false; - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { // IMPORTANT! Update ButtonContentDesignTypeConverter.IsValid if making changes here - var strValue = value?.ToString(); - if (strValue == null) - throw new InvalidOperationException($"Cannot convert null into {typeof(ButtonContentLayout)}"); + var strValue = (value?.ToString()) ?? throw new InvalidOperationException($"Cannot convert null into {typeof(ButtonContentLayout)}"); string[] parts = strValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 1 && parts.Length != 2) + { throw new InvalidOperationException($"Cannot convert \"{strValue}\" into {typeof(ButtonContentLayout)}"); + } double spacing = DefaultSpacing; var position = ButtonContentLayout.ImagePosition.Left; @@ -598,17 +598,22 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c int spacingIndex = spacingFirst ? 0 : (parts.Length == 2 ? 1 : -1); if (spacingIndex > -1) + { spacing = double.Parse(parts[spacingIndex], CultureInfo.InvariantCulture); + } if (positionIndex > -1) + { position = (ButtonContentLayout.ImagePosition)Enum.Parse(typeof(ButtonContentLayout.ImagePosition), parts[positionIndex], true); + } return new ButtonContentLayout(position, spacing); } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) => throw new NotSupportedException(); } +#nullable disable private protected override string GetDebuggerDisplay() { diff --git a/src/Controls/src/Core/FontAttributes.cs b/src/Controls/src/Core/FontAttributes.cs index bbf9d6bee7b5..6d04bd7591f1 100644 --- a/src/Controls/src/Core/FontAttributes.cs +++ b/src/Controls/src/Core/FontAttributes.cs @@ -1,80 +1,104 @@ -#nullable disable using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; -namespace Microsoft.Maui.Controls +namespace Microsoft.Maui.Controls; + +/// Enumerates values that describe font styles. +[Flags] +public enum FontAttributes +{ + /// The font is unmodified. + None = 0, + /// The font is bold. + Bold = 1 << 0, + /// The font is italic. + Italic = 1 << 1 +} + +/// Converts a string into a object. +public sealed class FontAttributesConverter : TypeConverter { - /// Enumerates values that describe font styles. - [Flags] - public enum FontAttributes + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) + => sourceType == typeof(string); + + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) + => destinationType == typeof(string); + + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) { - /// The font is unmodified. - None = 0, - /// The font is bold. - Bold = 1 << 0, - /// The font is italic. - Italic = 1 << 1 + var strValue = value?.ToString()?.Trim() ?? string.Empty; + + if (string.IsNullOrEmpty(strValue)) + { + return FontAttributes.None; + } + + FontAttributes attributes = FontAttributes.None; + if (strValue.IndexOf(",", StringComparison.Ordinal) != -1) + { + // Xaml + foreach (var part in strValue.Split(',')) + { + attributes |= ParseSingleAttribute(part, strValue); + } + } + else + { + // CSS or single value + foreach (var part in strValue.Split(' ')) + { + attributes |= ParseSingleAttribute(part, strValue); + } + } + return attributes; } - /// Converts a string into a object. - public sealed class FontAttributesConverter : TypeConverter + static FontAttributes ParseSingleAttribute(string part, string originalValue) { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - => sourceType == typeof(string); + part = part.Trim(); + if (Enum.TryParse(part, true, out FontAttributes attr)) + { + return attr; + } - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - => destinationType == typeof(string); + if (part.Equals("normal", StringComparison.OrdinalIgnoreCase)) + { + return FontAttributes.None; + } - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + if (part.Equals("oblique", StringComparison.OrdinalIgnoreCase)) { - var strValue = value?.ToString(); + return FontAttributes.Italic; + } - if (string.IsNullOrEmpty(strValue)) - return FontAttributes.None; + throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", originalValue, typeof(FontAttributes))); + } - FontAttributes attributes = FontAttributes.None; - strValue = strValue.Trim(); - if (strValue.IndexOf(",", StringComparison.Ordinal) != -1) - { //Xaml - foreach (var part in strValue.Split(',')) - attributes |= ParseSingleAttribute(part, strValue); + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) + { + if (value is not FontAttributes attr) + { + throw new NotSupportedException(); + } - } - else - { //CSS or single value - foreach (var part in strValue.Split(' ')) - attributes |= ParseSingleAttribute(part, strValue); - } - return attributes; + if (attr == FontAttributes.None) + { + return ""; } - static FontAttributes ParseSingleAttribute(string part, string originalvalue) + var parts = new List(); + if ((attr & FontAttributes.Bold) == FontAttributes.Bold) { - part = part.Trim(); - if (Enum.TryParse(part, true, out FontAttributes attr)) - return attr; - if (part.Equals("normal", StringComparison.OrdinalIgnoreCase)) - return FontAttributes.None; - if (part.Equals("oblique", StringComparison.OrdinalIgnoreCase)) - return FontAttributes.Italic; - - throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", originalvalue, typeof(FontAttributes))); + parts.Add(nameof(FontAttributes.Bold)); } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + if ((attr & FontAttributes.Italic) == FontAttributes.Italic) { - if (value is not FontAttributes attr) - throw new NotSupportedException(); - if (attr == FontAttributes.None) - return ""; - var parts = new List(); - if ((attr & FontAttributes.Bold) == FontAttributes.Bold) - parts.Add(nameof(FontAttributes.Bold)); - if ((attr & FontAttributes.Italic) == FontAttributes.Italic) - parts.Add(nameof(FontAttributes.Italic)); - return string.Join("' ", parts); + parts.Add(nameof(FontAttributes.Italic)); } + + return string.Join(", ", parts); } } diff --git a/src/Controls/src/Core/FormattedString.cs b/src/Controls/src/Core/FormattedString.cs index 396005f6cf6b..e5e12ad2558b 100644 --- a/src/Controls/src/Core/FormattedString.cs +++ b/src/Controls/src/Core/FormattedString.cs @@ -96,15 +96,16 @@ protected override void ClearItems() } } +#nullable enable private sealed class FormattedStringConverter : TypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(string); - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => destinationType == typeof(string); - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { if (value is string strValue) { @@ -114,7 +115,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, System.Global throw new NotSupportedException(); } - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType) { if (value is FormattedString formattedStr) { @@ -125,4 +126,4 @@ public override object ConvertTo(ITypeDescriptorContext context, System.Globaliz } } } -} \ No newline at end of file +} diff --git a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt index 1a9ac9b2f833..b4ba16d36955 100644 --- a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -203,6 +203,35 @@ override Microsoft.Maui.Controls.Handlers.ShellSectionWrapperFragment.OnCreate(A override Microsoft.Maui.Controls.Handlers.ShellSectionWrapperFragment.OnCreateView(Android.Views.LayoutInflater! inflater, Android.Views.ViewGroup? container, Android.OS.Bundle? savedInstanceState) -> Android.Views.View! override Microsoft.Maui.Controls.Handlers.ShellSectionWrapperFragment.OnResume() -> void override Microsoft.Maui.Controls.Handlers.ShellSectionWrapperFragment.OnViewCreated(Android.Views.View! view, Android.OS.Bundle? savedInstanceState) -> void +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Ellipse = "Ellipse" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Line = "Line" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Path = "Path" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polygon = "Polygon" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polyline = "Polyline" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Rectangle = "Rectangle" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.RoundRectangle = "RoundRectangle" -> string! +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? Microsoft.Maui.Controls.Platform.IGesturePlatformManager Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory.CreateGesturePlatformManager(Microsoft.Maui.IViewHandler! handler) -> Microsoft.Maui.Controls.Platform.IGesturePlatformManager! diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 95f16fc091bb..f8a10d96b887 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -122,6 +122,35 @@ Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Contr Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty! override Microsoft.Maui.Controls.SwipeItemView.IsEnabledCore.get -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Ellipse = "Ellipse" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Line = "Line" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Path = "Path" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polygon = "Polygon" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polyline = "Polyline" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Rectangle = "Rectangle" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.RoundRectangle = "RoundRectangle" -> string! +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? Microsoft.Maui.Controls.Platform.IGesturePlatformManager Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory.CreateGesturePlatformManager(Microsoft.Maui.IViewHandler! handler) -> Microsoft.Maui.Controls.Platform.IGesturePlatformManager! diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 95f16fc091bb..f8a10d96b887 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -122,6 +122,35 @@ Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Contr Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty! override Microsoft.Maui.Controls.SwipeItemView.IsEnabledCore.get -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Ellipse = "Ellipse" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Line = "Line" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Path = "Path" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polygon = "Polygon" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polyline = "Polyline" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Rectangle = "Rectangle" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.RoundRectangle = "RoundRectangle" -> string! +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? Microsoft.Maui.Controls.Platform.IGesturePlatformManager Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory.CreateGesturePlatformManager(Microsoft.Maui.IViewHandler! handler) -> Microsoft.Maui.Controls.Platform.IGesturePlatformManager! diff --git a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 1c5cd4c15333..8f80aad1f3b9 100644 --- a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -114,6 +114,35 @@ virtual Microsoft.Maui.Controls.LongPressingEventArgs.GetPosition(Microsoft.Maui ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextProperty -> Microsoft.Maui.Controls.BindableProperty +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Ellipse = "Ellipse" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Line = "Line" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Path = "Path" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polygon = "Polygon" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polyline = "Polyline" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Rectangle = "Rectangle" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.RoundRectangle = "RoundRectangle" -> string! +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt index d176ba63fa29..0718428b8887 100644 --- a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -161,6 +161,35 @@ virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2.Up ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextProperty -> Microsoft.Maui.Controls.BindableProperty +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Ellipse = "Ellipse" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Line = "Line" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Path = "Path" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polygon = "Polygon" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polyline = "Polyline" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Rectangle = "Rectangle" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.RoundRectangle = "RoundRectangle" -> string! +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt index be3b56b2ed46..17361feef279 100644 --- a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt @@ -137,6 +137,35 @@ static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextProperty -> Microsoft.Maui.Controls.BindableProperty +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Ellipse = "Ellipse" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Line = "Line" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Path = "Path" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polygon = "Polygon" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polyline = "Polyline" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Rectangle = "Rectangle" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.RoundRectangle = "RoundRectangle" -> string! +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? Microsoft.Maui.Controls.Platform.IGesturePlatformManager Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory.CreateGesturePlatformManager(Microsoft.Maui.IViewHandler! handler) -> Microsoft.Maui.Controls.Platform.IGesturePlatformManager! diff --git a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt index e7cef5dc3914..9b7c5f71d4a3 100644 --- a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -128,6 +128,35 @@ static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextColorProperty -> Microsoft.Maui.Controls.BindableProperty ~static readonly Microsoft.Maui.Controls.ToolbarItem.BadgeTextProperty -> Microsoft.Maui.Controls.BindableProperty +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.BindablePropertyConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.Button.ButtonContentTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.FontAttributesConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Ellipse = "Ellipse" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Line = "Line" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Path = "Path" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polygon = "Polygon" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Polyline = "Polyline" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.Rectangle = "Rectangle" -> string! +const Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.RoundRectangle = "RoundRectangle" -> string! +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? +override Microsoft.Maui.Controls.TextAlignmentConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? Microsoft.Maui.Controls.Platform.IGesturePlatformManager Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory Microsoft.Maui.Controls.Platform.IGesturePlatformManagerFactory.CreateGesturePlatformManager(Microsoft.Maui.IViewHandler! handler) -> Microsoft.Maui.Controls.Platform.IGesturePlatformManager! diff --git a/src/Controls/src/Core/ResourceDictionary.cs b/src/Controls/src/Core/ResourceDictionary.cs index c7762128e2b0..b8e1faf8a2ae 100644 --- a/src/Controls/src/Core/ResourceDictionary.cs +++ b/src/Controls/src/Core/ResourceDictionary.cs @@ -365,7 +365,7 @@ internal IEnumerable MergedResourcesKeys if (_mergedInstance != null) foreach (var key in _mergedInstance.MergedResourcesKeys) yield return key; - + foreach (var key in _innerDictionary.Keys) yield return key; } @@ -524,7 +524,7 @@ public LazyResource(Func factory, bool shared) public object GetValue() { _invocationCount++; - + if (!_shared) return _factory(); @@ -572,11 +572,11 @@ static object ResolveValue(object value) internal ResourceDiagnostics GetDiagnostics() { var diag = new ResourceDiagnostics(); - + foreach (var kvp in _innerDictionary) { diag.TotalCount++; - + if (kvp.Value is LazyResource lazy) { diag.LazyCount++; @@ -597,7 +597,7 @@ internal ResourceDiagnostics GetDiagnostics() diag.EagerKeys.Add(kvp.Key); } } - + return diag; } @@ -617,15 +617,30 @@ internal class ResourceDiagnostics } #endif +#nullable enable [Xaml.ProvideCompiled("Microsoft.Maui.Controls.XamlC.RDSourceTypeConverter")] public class RDSourceTypeConverter : TypeConverter, IExtendedTypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(string); - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => true; + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + => throw new NotImplementedException(); + + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) + { + if (value is not Uri uri) + { + throw new NotSupportedException(); + } + + return uri.ToString(); + } +#nullable disable + object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider) { if (serviceProvider == null) @@ -675,15 +690,6 @@ internal static string GetResourcePath(Uri uri, string rootTargetPath) return resourceUri.AbsolutePath.Substring(1); } - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - => throw new NotImplementedException(); - - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) - { - if (value is not Uri uri) - throw new NotSupportedException(); - return uri.ToString(); - } } } } diff --git a/src/Controls/src/Core/Shapes/StrokeShapeTypeConverter.cs b/src/Controls/src/Core/Shapes/StrokeShapeTypeConverter.cs index 1c0b9c40ff76..352525d05c2a 100644 --- a/src/Controls/src/Core/Shapes/StrokeShapeTypeConverter.cs +++ b/src/Controls/src/Core/Shapes/StrokeShapeTypeConverter.cs @@ -1,137 +1,155 @@ -#nullable disable -using System; +using System; using System.ComponentModel; using System.Globalization; using Microsoft.Maui.Controls.Xaml; using Microsoft.Maui.Converters; using Microsoft.Maui.Graphics; -namespace Microsoft.Maui.Controls.Shapes +namespace Microsoft.Maui.Controls.Shapes; + +[ProvideCompiled("Microsoft.Maui.Controls.XamlC.StrokeShapeTypeConverter")] +public class StrokeShapeTypeConverter : TypeConverter { - [ProvideCompiled("Microsoft.Maui.Controls.XamlC.StrokeShapeTypeConverter")] - public class StrokeShapeTypeConverter : TypeConverter - { - public const string Ellipse = nameof(Ellipse); - public const string Line = nameof(Line); - public const string Path = nameof(Path); - public const string Polygon = nameof(Polygon); - public const string Polyline = nameof(Polyline); - public const string Rectangle = nameof(Rectangle); - public const string RoundRectangle = nameof(RoundRectangle); + public const string Ellipse = nameof(Ellipse); + public const string Line = nameof(Line); + public const string Path = nameof(Path); + public const string Polygon = nameof(Polygon); + public const string Polyline = nameof(Polyline); + public const string Rectangle = nameof(Rectangle); + public const string RoundRectangle = nameof(RoundRectangle); + + internal static readonly char[] Delimiter = [' ']; - internal static readonly char[] Delimiter = { ' ' }; + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) + => sourceType == typeof(string); - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - => sourceType == typeof(string); + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + { + var strValue = value?.ToString(); - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + if (strValue is not null) { - var strValue = value?.ToString(); + strValue = strValue.Trim(); + culture ??= CultureInfo.CurrentCulture; - if (strValue != null) + if (strValue.StartsWith(Ellipse, true, culture)) { - strValue = strValue.Trim(); + return new Ellipse(); + } - if (strValue.StartsWith(Ellipse, true, culture)) + if (strValue.StartsWith(Line, true, culture)) + { + var parts = strValue.Split(Delimiter, 2); + if (parts.Length != 2) { - return new Ellipse(); + return new Line(); } - if (strValue.StartsWith(Line, true, culture)) - { - var parts = strValue.Split(Delimiter, 2); - if (parts.Length != 2) - return new Line(); + PointCollectionConverter pointCollectionConverter = new PointCollectionConverter(); - PointCollectionConverter pointCollectionConverter = new PointCollectionConverter(); - PointCollection points = pointCollectionConverter.ConvertFromString(parts[1]) as PointCollection; + if (pointCollectionConverter.ConvertFromString(parts[1]) is not PointCollection points || points.Count == 0) + { + return new Line(); + } - if (points == null || points.Count == 0) - return new Line(); + Point p1 = points[0]; - Point p1 = points[0]; + if (points.Count == 1) + { + return new Line { X1 = p1.X, Y1 = p1.Y }; + } - if (points.Count == 1) - return new Line { X1 = p1.X, Y1 = p1.Y }; + Point p2 = points[1]; - Point p2 = points[1]; + return new Line { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y }; + } - return new Line { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y }; + if (strValue.StartsWith(Path, true, culture)) + { + var parts = strValue.Split(Delimiter, 2); + if (parts.Length != 2) + { + return new Path(); } - if (strValue.StartsWith(Path, true, culture)) - { - var parts = strValue.Split(Delimiter, 2); - if (parts.Length != 2) - return new Path(); + PathGeometryConverter pathGeometryConverter = new PathGeometryConverter(); - PathGeometryConverter pathGeometryConverter = new PathGeometryConverter(); - Geometry pathGeometry = pathGeometryConverter.ConvertFromInvariantString(parts[1]) as Geometry; + if (pathGeometryConverter.ConvertFromInvariantString(parts[1]) is not Geometry pathGeometry) + { + return new Path(); + } - if (pathGeometry == null) - return new Path(); + return new Path { Data = pathGeometry }; + } - return new Path { Data = pathGeometry }; + if (strValue.StartsWith(Polygon, true, culture)) + { + var parts = strValue.Split(Delimiter, 2); + if (parts.Length != 2) + { + return new Polygon(); } - if (strValue.StartsWith(Polygon, true, culture)) - { - var parts = strValue.Split(Delimiter, 2); - if (parts.Length != 2) - return new Polygon(); + PointCollectionConverter pointCollectionConverter = new PointCollectionConverter(); - PointCollectionConverter pointCollectionConverter = new PointCollectionConverter(); - PointCollection points = pointCollectionConverter.ConvertFromString(parts[1]) as PointCollection; + if (pointCollectionConverter.ConvertFromString(parts[1]) is not PointCollection points || points.Count == 0) + { + return new Polygon(); + } - if (points == null || points.Count == 0) - return new Polygon(); + return new Polygon { Points = points }; + } - return new Polygon { Points = points }; + if (strValue.StartsWith(Polyline, true, culture)) + { + var parts = strValue.Split(Delimiter, 2); + if (parts.Length != 2) + { + return new Polyline(); } - if (strValue.StartsWith(Polyline, true, culture)) + PointCollectionConverter pointCollectionConverter = new PointCollectionConverter(); + + if (pointCollectionConverter.ConvertFromString(parts[1]) is not PointCollection points || points.Count == 0) { - var parts = strValue.Split(Delimiter, 2); - if (parts.Length != 2) - return new Polyline(); + return new Polyline(); + } - PointCollectionConverter pointCollectionConverter = new PointCollectionConverter(); - PointCollection points = pointCollectionConverter.ConvertFromString(parts[1]) as PointCollection; + return new Polyline { Points = points }; + } - if (points == null || points.Count == 0) - return new Polyline(); + if (strValue.StartsWith(Rectangle, true, culture)) + { + return new Rectangle(); + } - return new Polyline { Points = points }; - } + if (strValue.StartsWith(RoundRectangle, true, culture)) + { + var parts = strValue.Split(Delimiter, 2); - if (strValue.StartsWith(Rectangle, true, culture)) - { - return new Rectangle(); - } + CornerRadius cornerRadius = new CornerRadius(); - if (strValue.StartsWith(RoundRectangle, true, culture)) + if (parts.Length > 1) { - var parts = strValue.Split(Delimiter, 2); - - CornerRadius cornerRadius = new CornerRadius(); - - if (parts.Length > 1) + CornerRadiusTypeConverter cornerRadiusTypeConverter = new CornerRadiusTypeConverter(); + var convertedCornerRadius = cornerRadiusTypeConverter.ConvertFromString(parts[1]); + if (convertedCornerRadius is not null) { - CornerRadiusTypeConverter cornerRadiusTypeConverter = new CornerRadiusTypeConverter(); - cornerRadius = (CornerRadius)cornerRadiusTypeConverter.ConvertFromString(parts[1]); + cornerRadius = (CornerRadius)convertedCornerRadius; } - - return new RoundRectangle { CornerRadius = cornerRadius }; } - // Support for providing a double. This handles Border CSS support. - if (double.TryParse(strValue, out double radius)) - { - return new RoundRectangle { CornerRadius = new CornerRadius(radius) }; - } + return new RoundRectangle { CornerRadius = cornerRadius }; } - throw new InvalidOperationException($"Cannot convert \"{strValue}\" into {typeof(Shape)}"); + // Support for providing a double. This handles Border CSS support. + // Direct TypeConverter callers supply the culture; invariant XAML paths pass InvariantCulture. + if (double.TryParse(strValue, NumberStyles.Float | NumberStyles.AllowThousands, culture, out double radius)) + { + return new RoundRectangle { CornerRadius = new CornerRadius(radius) }; + } } + + throw new InvalidOperationException($"Cannot convert \"{strValue}\" into {typeof(Shape)}"); } -} \ No newline at end of file +} diff --git a/src/Controls/src/Core/Shell/ShellContent.cs b/src/Controls/src/Core/Shell/ShellContent.cs index f562cc27d444..42cd74d6a3a4 100644 --- a/src/Controls/src/Core/Shell/ShellContent.cs +++ b/src/Controls/src/Core/Shell/ShellContent.cs @@ -432,7 +432,7 @@ static void ApplyQueryAttributes(object content, ShellRouteParameters query, She { // Handle nullable types Type targetType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType; - + if (value == null) { prop.SetValue(content, null); @@ -465,16 +465,16 @@ static void ClearQueryIfAppliedToPage(ShellRouteParameters query, object content query.ResetToQueryParameters(); } } - +#nullable enable private sealed class ShellContentConverter : TypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(TemplatedPage); - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => false; - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { if (value is TemplatedPage templatedPage) { @@ -484,7 +484,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, System.Global throw new NotSupportedException(); } - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType) { throw new NotSupportedException(); } diff --git a/src/Controls/src/Core/Shell/ShellItem.cs b/src/Controls/src/Core/Shell/ShellItem.cs index 3705b461dcf2..becdfc28aab8 100644 --- a/src/Controls/src/Core/Shell/ShellItem.cs +++ b/src/Controls/src/Core/Shell/ShellItem.cs @@ -378,19 +378,19 @@ protected override void OnParentSet() if (this.IsVisibleItem && CurrentItem != null) ((IShellController)Parent)?.AppearanceChanged(CurrentItem, false); } - +#nullable enable private sealed class ShellItemConverter : TypeConverter { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(ShellSection) || sourceType == typeof(ShellContent) || sourceType == typeof(TemplatedPage) || sourceType == typeof(MenuItem); - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => false; - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) => value switch { ShellSection shellSection => (ShellItem)shellSection, @@ -400,10 +400,10 @@ public override object ConvertFrom(ITypeDescriptorContext context, System.Global _ => throw new NotSupportedException(), }; - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType) => throw new NotSupportedException(); } - +#nullable disable /// /// Provides a debug view for the class. /// diff --git a/src/Controls/src/Core/Shell/ShellNavigationState.cs b/src/Controls/src/Core/Shell/ShellNavigationState.cs index c737eb9961fa..b508f0aadb59 100644 --- a/src/Controls/src/Core/Shell/ShellNavigationState.cs +++ b/src/Controls/src/Core/Shell/ShellNavigationState.cs @@ -112,16 +112,16 @@ static Uri TrimDownImplicitAndDefaultPaths(Uri uri) toKeep.Insert(0, ""); return new Uri(string.Join(Routing.PathSeparator, toKeep), UriKind.Relative); } - +#nullable enable private sealed class ShellNavigationStateTypeConverter : TypeConverter { - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) => false; - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cultureInfo, object value, Type destinationType) => throw new NotSupportedException(); + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => false; + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? cultureInfo, object? value, Type destinationType) => throw new NotSupportedException(); - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(string) || sourceType == typeof(Uri); - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) => value switch { string str => (ShellNavigationState)str, diff --git a/src/Controls/src/Core/Shell/ShellSection.cs b/src/Controls/src/Core/Shell/ShellSection.cs index b4056912bf7a..9d8ab2da894c 100644 --- a/src/Controls/src/Core/Shell/ShellSection.cs +++ b/src/Controls/src/Core/Shell/ShellSection.cs @@ -1295,16 +1295,16 @@ void IStackNavigation.NavigationFinished(IReadOnlyList newStack) _handlerBasedNavigationCompletionSource = null; source?.SetResult(true); } -#nullable disable + private sealed class ShellSectionTypeConverter : TypeConverter { - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) => false; - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cultureInfo, object value, Type destinationType) => throw new NotSupportedException(); + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) => false; + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? cultureInfo, object? value, Type destinationType) => throw new NotSupportedException(); - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) => sourceType == typeof(ShellContent) || sourceType == typeof(TemplatedPage); - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) => value switch { ShellContent shellContent => (ShellSection)shellContent, @@ -1312,7 +1312,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, System.Global _ => throw new NotSupportedException(), }; } - +#nullable disable /// /// Provides a debug view for the class. /// diff --git a/src/Controls/src/Core/TextAlignment.cs b/src/Controls/src/Core/TextAlignment.cs index 0d9b90c604a3..a5c3185922ee 100644 --- a/src/Controls/src/Core/TextAlignment.cs +++ b/src/Controls/src/Core/TextAlignment.cs @@ -1,57 +1,72 @@ -#nullable disable using System; using System.ComponentModel; using System.Globalization; -namespace Microsoft.Maui.Controls +namespace Microsoft.Maui.Controls; + +public class TextAlignmentConverter : TypeConverter { - public class TextAlignmentConverter : TypeConverter - { - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - => sourceType == typeof(string); + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) + => sourceType == typeof(string); - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - => destinationType == typeof(string); + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) + => destinationType == typeof(string); - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + { + var strValue = value?.ToString(); + if (strValue is not null) { - var strValue = value?.ToString(); - if (strValue != null) + if (strValue.Equals("Start", StringComparison.OrdinalIgnoreCase) || + strValue.Equals("left", StringComparison.OrdinalIgnoreCase) || + strValue.Equals("top", StringComparison.OrdinalIgnoreCase)) + { + return TextAlignment.Start; + } + + if (strValue.Equals("Center", StringComparison.OrdinalIgnoreCase) || + strValue.Equals("middle", StringComparison.OrdinalIgnoreCase)) + { + return TextAlignment.Center; + } + + if (strValue.Equals("End", StringComparison.OrdinalIgnoreCase) || + strValue.Equals("right", StringComparison.OrdinalIgnoreCase) || + strValue.Equals("bottom", StringComparison.OrdinalIgnoreCase)) + { + return TextAlignment.End; + } + + if (Enum.TryParse(strValue, out TextAlignment direction)) { - if (strValue.Equals("Start", StringComparison.OrdinalIgnoreCase) || strValue.Equals("left", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.Start; - if (strValue.Equals("top", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.Start; - if (strValue.Equals("right", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.End; - if (strValue.Equals("bottom", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.End; - if (strValue.Equals("center", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.Center; - if (strValue.Equals("middle", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.Center; - if (strValue.Equals("End", StringComparison.OrdinalIgnoreCase) || strValue.Equals("right", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.End; - if (strValue.Equals("Center", StringComparison.OrdinalIgnoreCase) || strValue.Equals("center", StringComparison.OrdinalIgnoreCase)) - return TextAlignment.Center; - - if (Enum.TryParse(strValue, out TextAlignment direction)) - return direction; + return direction; } - throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", strValue, typeof(TextAlignment))); } + throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", strValue, typeof(TextAlignment))); + } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) + { + if (value is not TextAlignment ta) { - if (value is not TextAlignment ta) - throw new NotSupportedException(); - if (ta == TextAlignment.Start) - return nameof(TextAlignment.Start); - if (ta == TextAlignment.Center) - return nameof(TextAlignment.Center); - if (ta == TextAlignment.End) - return nameof(TextAlignment.End); throw new NotSupportedException(); } + + if (ta == TextAlignment.Start) + { + return nameof(TextAlignment.Start); + } + + if (ta == TextAlignment.Center) + { + return nameof(TextAlignment.Center); + } + + if (ta == TextAlignment.End) + { + return nameof(TextAlignment.End); + } + + throw new NotSupportedException(); } } diff --git a/src/Controls/src/SourceGen/KnownMarkups.cs b/src/Controls/src/SourceGen/KnownMarkups.cs index 6dffbdab3d37..f7ef1f13ddc4 100644 --- a/src/Controls/src/SourceGen/KnownMarkups.cs +++ b/src/Controls/src/SourceGen/KnownMarkups.cs @@ -396,14 +396,16 @@ private static bool ProvideValueForBindingExtension(ElementNode markupNode, Inde // Emit property-not-found diagnostic when the source type was known at compile time // but the binding path doesn't exist on that type. Specifically: // - x:DataType bindings: always emit (existing behavior). - // - AncestorType bindings with a resolved type: emit, because the type is known and the - // path is provably wrong — consistent with x:DataType behavior. Suppress only when the - // AncestorType itself failed to resolve (ancestorTypeSymbol == null), since no type - // inference was possible. + // - AncestorType bindings with a resolved type: emit only when the AncestorType is + // sealed. AncestorType matching is an `is`-style check, so the runtime ancestor may + // be a derived type that declares the missing property; for unsealed types, absence + // on the declared AncestorType doesn't prove the binding is broken. Also suppress + // when the AncestorType itself failed to resolve (ancestorTypeSymbol == null), since + // no type inference was possible. // - x:Reference bindings: always suppress — they were never compiled before. if (propertyNotFoundDiagnostic is not null && xRefSourceType is null - && (!isAncestorTypeSource || ancestorTypeSymbol is not null)) + && (!isAncestorTypeSource || (ancestorTypeSymbol is not null && ancestorTypeSymbol.IsSealed))) { context.ReportDiagnostic(propertyNotFoundDiagnostic); } diff --git a/src/Controls/src/SourceGen/NodeSGExtensions.cs b/src/Controls/src/SourceGen/NodeSGExtensions.cs index 609493f0d57f..4357a1c9e54a 100644 --- a/src/Controls/src/SourceGen/NodeSGExtensions.cs +++ b/src/Controls/src/SourceGen/NodeSGExtensions.cs @@ -74,8 +74,8 @@ static string ConvertEnum(string value, BaseNode node, ITypeSymbol toType, Inden { context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Shapes.PointCollectionConverter")!, (CreateLazyRegistryConverter("Microsoft.Maui.Controls.PointCollection"), context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.PointCollection")!) }, { context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.TypeTypeConverter")!, (CreateLazyConverter(), context.Compilation.GetTypeByMetadataName("System.Type")!) }, { context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Compatibility.ConstraintTypeConverter")!, (CreateLazyRegistryConverter("Microsoft.Maui.Controls.Compatibility.Constraint"), context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Compatibility.Constraint")!) }, - - // TODO: PathFigureCollectionConverter (used for PathGeometry and StrokeShape) is very complex, skipping for now, apart from that one all other shapes work though + // TODO: PathFigureCollectionConverter (used for PathGeometry and StrokeShape) is very complex, skipping for now, apart from that one all other shapes work though. + // Add StrokeShapeConverter's numeric RoundRectangle fallback before registering it here. //{ context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Shapes.PathGeometryConverter")!, (CreateRegistryConverter("Microsoft.Maui.Controls.Shapes.Geometry"), context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Shapes.Geometry")!) }, //{ context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Shapes.StrokeShapeTypeConverter")!, (CreateRegistryConverter("Microsoft.Maui.Controls.Shapes.Shape"), context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Shapes.Shape")!) }, }; @@ -181,7 +181,7 @@ public static bool IsLazyResource(this ElementNode node, INode parentNode, Sourc // If we can't resolve the type, err on the side of caution and don't treat as lazy if (!node.XmlType.TryResolveTypeSymbol(null, context.Compilation, context.XmlnsCache, context.TypeCache, out var typeSymbol) || typeSymbol == null) return false; - + // Value types should not be lazy (no benefit - value types are copied anyway) if (typeSymbol.IsValueType) return false; diff --git a/src/Controls/tests/Core.UnitTests/BindablePropertyConverterUnitTests.cs b/src/Controls/tests/Core.UnitTests/BindablePropertyConverterUnitTests.cs new file mode 100644 index 000000000000..cca05276b903 --- /dev/null +++ b/src/Controls/tests/Core.UnitTests/BindablePropertyConverterUnitTests.cs @@ -0,0 +1,20 @@ +using Xunit; + +namespace Microsoft.Maui.Controls.Core.UnitTests +{ + public class BindablePropertyConverterUnitTests : BaseTestFixture + { + [Theory] + [InlineData("")] + [InlineData("Label")] + [InlineData("Label.Text.More")] + [InlineData("prefix:Label.Text")] + [InlineData("NotAType.Text")] + public void InvalidValuesReturnNull(string value) + { + var converter = new BindablePropertyConverter(); + + Assert.Null(converter.ConvertFromInvariantString(value)); + } + } +} diff --git a/src/Controls/tests/Core.UnitTests/FontAttributeConverterUnitTests.cs b/src/Controls/tests/Core.UnitTests/FontAttributeConverterUnitTests.cs index 7f5c609616c3..cac922b9d0ac 100644 --- a/src/Controls/tests/Core.UnitTests/FontAttributeConverterUnitTests.cs +++ b/src/Controls/tests/Core.UnitTests/FontAttributeConverterUnitTests.cs @@ -1,3 +1,4 @@ +using System; using Xunit; namespace Microsoft.Maui.Controls.Core.UnitTests @@ -12,10 +13,37 @@ public class FontAttributeConverterUnitTests : BaseTestFixture [InlineData("oblique", FontAttributes.Italic)] [InlineData("oblique, bold", FontAttributes.Italic | FontAttributes.Bold)] [InlineData("bold italic", FontAttributes.Italic | FontAttributes.Bold)] + [InlineData(" ", FontAttributes.None)] public void TestFontAttributeConverter(string input, FontAttributes expected) { var conv = new FontAttributesConverter(); Assert.Equal(conv.ConvertFromInvariantString(input), expected); } + + [Theory] + [InlineData(FontAttributes.None)] + [InlineData(FontAttributes.Bold)] + [InlineData(FontAttributes.Italic)] + [InlineData(FontAttributes.Bold | FontAttributes.Italic)] + public void FontAttributesRoundTripThroughString(FontAttributes attributes) + { + var conv = new FontAttributesConverter(); + var converted = conv.ConvertToInvariantString(attributes); + + Assert.Equal(attributes, conv.ConvertFromInvariantString(converted)); + } + + [Theory] + [InlineData(",")] + [InlineData(",,")] + [InlineData("Bold,,Italic")] + [InlineData(",Bold")] + [InlineData("Bold,")] + public void MalformedCommaTokensThrow(string input) + { + var conv = new FontAttributesConverter(); + + Assert.Throws(() => conv.ConvertFromInvariantString(input)); + } } -} \ No newline at end of file +} diff --git a/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs b/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs index f8641829b85c..3b99b04431bf 100644 --- a/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs +++ b/src/Controls/tests/Core.UnitTests/StrokeShapeTests.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using Microsoft.Maui.Controls.Shapes; using Xunit; @@ -140,5 +141,25 @@ public void TestRoundRectangleSingleValue(string value) Assert.NotEqual(0, roundRectangle.CornerRadius.BottomLeft); Assert.NotEqual(0, roundRectangle.CornerRadius.BottomRight); } + + [Theory] + [InlineData("1e2", 100.0)] + [InlineData("2.5e1", 25.0)] + [InlineData("1E2", 100.0)] + public void TestRoundRectangleExponentNotation(string value, double expectedRadius) + { + var roundRectangle = Assert.IsType(_strokeShapeTypeConverter.ConvertFromInvariantString(value)); + + Assert.Equal(expectedRadius, roundRectangle.CornerRadius.TopLeft); + } + + [Fact] + public void TestRoundRectangleUsesProvidedCulture() + { + var roundRectangle = Assert.IsType( + _strokeShapeTypeConverter.ConvertFrom(null, CultureInfo.GetCultureInfo("fr-FR"), "1,5")); + + Assert.Equal(1.5, roundRectangle.CornerRadius.TopLeft); + } } -} \ No newline at end of file +} diff --git a/src/Controls/tests/SourceGen.UnitTests/BindingDiagnosticsTests.cs b/src/Controls/tests/SourceGen.UnitTests/BindingDiagnosticsTests.cs index cc6038f66480..d49e1d612930 100644 --- a/src/Controls/tests/SourceGen.UnitTests/BindingDiagnosticsTests.cs +++ b/src/Controls/tests/SourceGen.UnitTests/BindingDiagnosticsTests.cs @@ -378,7 +378,7 @@ public void BindingWithRelativeSourceAncestorTypeInvalidPath_ReportsPropertyNotF """ namespace Test; -public partial class TestPage : Microsoft.Maui.Controls.ContentPage { } +public sealed partial class TestPage : Microsoft.Maui.Controls.ContentPage { } public class ViewModel { @@ -390,8 +390,9 @@ public class ViewModel .AddSyntaxTrees(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(csharp)); var result = RunGenerator(compilation, new AdditionalXamlFile("Test.xaml", xaml), assertNoCompilationErrors: false); - // AncestorType=TestPage is resolvable at compile time, so the path is provably wrong on - // that type — MAUIG2045 must fire, consistent with x:DataType binding behavior. + // AncestorType=TestPage is sealed, so no derived runtime ancestor can exist — the path is + // provably wrong on that type, so MAUIG2045 must fire, consistent with x:DataType binding + // behavior. var diagnostic = result.Diagnostics.FirstOrDefault(d => d.Id == "MAUIG2045"); Assert.NotNull(diagnostic); Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); @@ -401,6 +402,67 @@ public class ViewModel Assert.Contains("TestPage", message, System.StringComparison.Ordinal); } + [Fact] + public void BindingWithRelativeSourceAncestorTypeMatchingIssue36818Repro_SuppressesPropertyNotFound() + { + // XAML root is `BasePage : ContentPage`, and `BasePage` declares `SelectedItem`. + // The binding declares AncestorType={x:Type ContentPage} (the framework base type, not the + // derived BasePage). At runtime the resolved ancestor is the BasePage instance, so the + // binding is valid — MAUIG2045 must NOT fire, since ContentPage is unsealed and BasePage (a + // real derived type present in this same compilation) legitimately supplies SelectedItem. + var xaml = +""" + + + + + + +"""; + + var csharp = +""" +using System.Windows.Input; + +namespace Test.Views; + +public partial class BasePage : Microsoft.Maui.Controls.ContentPage +{ + public static readonly Microsoft.Maui.Controls.BindableProperty SelectedItemProperty = + Microsoft.Maui.Controls.BindableProperty.Create(nameof(SelectedItem), typeof(object), typeof(BasePage)); + + public object SelectedItem + { + get => GetValue(SelectedItemProperty); + set => SetValue(SelectedItemProperty, value); + } + + public ICommand NavigateCommand { get; set; } +} + +namespace Test; + +public class ViewModel +{ + public string Name { get; set; } +} +"""; + + var compilation = CreateMauiCompilation() + .AddSyntaxTrees(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(csharp)); + var result = RunGenerator(compilation, new AdditionalXamlFile("ControlsPage.xaml", xaml), assertNoCompilationErrors: false); + + // ContentPage (the declared AncestorType) is unsealed and does not declare SelectedItem, but + // the real derived type BasePage does — MAUIG2045 must be suppressed. + Assert.DoesNotContain(result.Diagnostics, d => d.Id == "MAUIG2045"); + } + [Fact] public void BindingWithRelativeSourceUnresolvedAncestorTypeInvalidPath_SuppressesPropertyNotFound() { diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CollectionViewSelectionShouldClear.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CollectionViewSelectionShouldClear.png index 4c2c086ef02f..4f91786cc548 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CollectionViewSelectionShouldClear.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CollectionViewSelectionShouldClear.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/HeaderAndFooterShouldBeVisible.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/HeaderAndFooterShouldBeVisible.png index 99a559cbff0d..5826ef29364f 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/HeaderAndFooterShouldBeVisible.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/HeaderAndFooterShouldBeVisible.png differ diff --git a/src/Controls/tests/Xaml.UnitTests/BindablePropertyConverterTests.cs b/src/Controls/tests/Xaml.UnitTests/BindablePropertyConverterTests.cs new file mode 100644 index 000000000000..7a6695b522f0 --- /dev/null +++ b/src/Controls/tests/Xaml.UnitTests/BindablePropertyConverterTests.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Xml; +using Microsoft.Maui.Controls.Xaml; +using Xunit; + +namespace Microsoft.Maui.Controls.Xaml.UnitTests; + +public class BindablePropertyConverterTests : BaseTestFixture +{ + static readonly IXamlTypeResolver s_typeResolver = new Internals.XamlTypeResolver( + new XmlNamespaceManager(new NameTable()), + XamlParser.GetElementType, + typeof(BindablePropertyConverterTests).Assembly); + + [Fact] + public void TruncatedVisualStateParentChainsThrowXamlParseException() + { + AssertMissingTargetType(new Setter(), new VisualState()); + AssertMissingTargetType(new Setter(), new VisualState(), new VisualStateGroup()); + AssertMissingTargetType(new Setter(), new VisualState(), new VisualStateGroup(), new VisualStateGroupList()); + AssertMissingTargetType(new Setter(), new VisualState(), new VisualStateGroup(), new VisualStateGroupList(), new Setter()); + } + + [Fact] + public void InvalidVisualStateGroupUsesSpecificError() + { + var exception = ConvertWithParents(new Setter(), new VisualState(), new object()); + + Assert.Contains($"Expected {nameof(VisualStateGroup)}", exception.Message, StringComparison.Ordinal); + } + + [Fact] + public void InvalidVisualStateGroupListUsesSpecificError() + { + var exception = ConvertWithParents(new Setter(), new VisualState(), new VisualStateGroup(), new object()); + + Assert.Contains($"Expected {nameof(VisualStateGroupList)}", exception.Message, StringComparison.Ordinal); + } + + [Fact] + public void InvalidSetterUsesSpecificError() + { + var exception = ConvertWithParents(new Setter(), new VisualState(), new VisualStateGroup(), new VisualStateGroupList(), new object()); + + Assert.Contains($"Expected {nameof(Setter)}", exception.Message, StringComparison.Ordinal); + } + + static void AssertMissingTargetType(params object[] parents) + { + var exception = ConvertWithParents(parents); + + Assert.Contains("Unable to find a TargetType", exception.Message, StringComparison.Ordinal); + } + + static XamlParseException ConvertWithParents(params object[] parents) + { + var serviceProvider = new Internals.XamlServiceProvider + { + IXamlTypeResolver = s_typeResolver, + IProvideValueTarget = new ParentValuesProvider(parents), + }; + var converter = (IExtendedTypeConverter)new BindablePropertyConverter(); + + return Assert.Throws(() => converter.ConvertFromInvariantString("Text", serviceProvider)); + } + + sealed class ParentValuesProvider : IProvideParentValues + { + public ParentValuesProvider(object[] parents) + { + ParentObjects = parents; + TargetObject = parents[0]; + } + + public IEnumerable ParentObjects { get; } + + public object TargetObject { get; } + + public object TargetProperty => null; + } +} diff --git a/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml b/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml index 32f851f3b24e..36683305ef90 100644 --- a/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml +++ b/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml @@ -20,6 +20,7 @@ PolylineShape="Polyline 0 48, 0 144, 96 150, 100 0, 192 0, 192 96, 50 96, 48 192, 150 200 144 48" RectangleShape="Rectangle" RoundRectangleShape="RoundRectangle 1,2,3,4" + NumericRoundRectangleShape="1.5e2" PathShape="Path M16.484421,0.73799322C20.831404,0.7379931 24.353395,1.1259904 24.353395,1.6049905 24.353395,2.0839829 20.831404,2.4719803 16.484421,2.47198 12.138443,2.4719803 8.6154527,2.0839829 8.6154527,1.6049905 8.6154527,1.1259904 12.138443,0.7379931 16.484421,0.73799322z M1.9454784,0.061995983C2.7564723,5.2449602 12.246436,11.341911 12.246436,11.341911 13.248431,19.240842 9.6454477,17.915854 9.6454477,17.915854 7.9604563,18.897849 6.5314603,17.171859 6.5314603,17.171859 4.1084647,18.29585 3.279473,15.359877 3.2794733,15.359877 0.82348057,15.291876 1.2804796,11.362907 1.2804799,11.362907 -1.573514,10.239915 1.2344746,6.3909473 1.2344746,6.3909473 -1.3255138,4.9869594 1.9454782,0.061996057 1.9454784,0.061995983z M30.054371,0C30.054371,9.8700468E-08 33.325355,4.9249634 30.765367,6.3289513 30.765367,6.3289513 33.574364,10.177919 30.71837,11.30191 30.71837,11.30191 31.175369,15.22988 28.721384,15.297872 28.721384,15.297872 27.892376,18.232854 25.468389,17.110862 25.468389,17.110862 24.040392,18.835847 22.355402,17.853852 22.355402,17.853852 18.752417,19.178845 19.753414,11.279907 19.753414,11.279907 29.243385,5.1829566 30.054371,0z" List="Foo, Bar" ButtonType="Button" diff --git a/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml.cs b/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml.cs index 1e6ebb9ef6aa..3e294be221dc 100644 --- a/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml.cs +++ b/src/Controls/tests/Xaml.UnitTests/CompiledTypeConverter.xaml.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using Microsoft.Maui.Controls.Shapes; using Microsoft.Maui.Graphics; @@ -60,6 +61,9 @@ public Rect RectangleBP [System.ComponentModel.TypeConverter(typeof(StrokeShapeTypeConverter))] public IShape RoundRectangleShape { get; set; } + [System.ComponentModel.TypeConverter(typeof(StrokeShapeTypeConverter))] + public IShape NumericRoundRectangleShape { get; set; } + [System.ComponentModel.TypeConverter(typeof(StrokeShapeTypeConverter))] public IShape PathShape { get; set; } @@ -105,6 +109,7 @@ internal void CompiledTypeConverterAreInvoked(XamlInflator xamlInflator) Assert.Equal(10, ((Shapes.Polyline)p.PolylineShape).Points.Count); Assert.IsType(p.RectangleShape); Assert.Equal(new CornerRadius(1, 2, 3, 4), ((RoundRectangle)p.RoundRectangleShape).CornerRadius); + Assert.Equal(new CornerRadius(150), Assert.IsType(p.NumericRoundRectangleShape).CornerRadius); Assert.Equal(3, ((PathGeometry)((Path)p.PathShape).Data).Figures.Count); Assert.Equal(LayoutOptions.EndAndExpand, p.label.GetValue(View.HorizontalOptionsProperty)); var xConstraint = Microsoft.Maui.Controls.Compatibility.RelativeLayout.GetXConstraint(p.label); @@ -116,6 +121,24 @@ internal void CompiledTypeConverterAreInvoked(XamlInflator xamlInflator) Assert.Equal(Label.TextProperty, p.BindableProp); } + [Fact] + internal void CompiledStrokeShapeUsesInvariantCulture() + { + var originalCulture = System.Threading.Thread.CurrentThread.CurrentCulture; + try + { + System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-FR"); + + MockCompiler.Compile(typeof(CompiledTypeConverter), out _, out bool hasLoggedErrors); + + Assert.False(hasLoggedErrors); + } + finally + { + System.Threading.Thread.CurrentThread.CurrentCulture = originalCulture; + } + } + public static IEnumerable ConverterTestData => from inflator in new[] { XamlInflator.XamlC, XamlInflator.SourceGen } from converterType in new[] @@ -208,6 +231,9 @@ public Rect RectangleBP [System.ComponentModel.TypeConverter(typeof(StrokeShapeTypeConverter))] public IShape RoundRectangleShape { get; set; } + [System.ComponentModel.TypeConverter(typeof(StrokeShapeTypeConverter))] + public IShape NumericRoundRectangleShape { get; set; } + [System.ComponentModel.TypeConverter(typeof(StrokeShapeTypeConverter))] public IShape PathShape { get; set; }