diff --git a/Make.config b/Make.config
index 9cda89d2fa36..37f686f7ca98 100644
--- a/Make.config
+++ b/Make.config
@@ -289,12 +289,12 @@ MAX_TVOS_SIMULATOR_VERSION=$(TVOS_SDK_VERSION)
MAX_WATCH_SIMULATOR_VERSION=$(WATCH_SDK_VERSION)
# Minimum OS versions for running XI/XM apps.
-MIN_IOS_SDK_VERSION=11.0
+MIN_IOS_SDK_VERSION=12.2
MIN_MACOS_SDK_VERSION=12.0
MIN_WATCHOS_SDK_VERSION=4.0
MIN_WATCHOS64_32_SDK_VERSION=5.1
MIN_WATCH_OS_VERSION=4.0
-MIN_TVOS_SDK_VERSION=11.0
+MIN_TVOS_SDK_VERSION=12.2
MIN_MACCATALYST_SDK_VERSION=15.0
# Minimum OS versions for .NET 9 support
@@ -314,11 +314,9 @@ EXTRA_SIMULATORS=com.apple.pkg.iPhoneSimulatorSDK15_0 com.apple.pkg.AppleTVSimul
INCLUDE_IOS=1
INCLUDE_MAC=1
-INCLUDE_WATCH=1
INCLUDE_TVOS=1
INCLUDE_MACCATALYST=1
INCLUDE_DEVICE=1
-INCLUDE_DOTNET_WATCHOS=
INCLUDE_XAMARIN_LEGACY=
INCLUDE_HOTRESTART=1
@@ -408,7 +406,10 @@ SIMULATOR_SDK=$(XCODE_DEVELOPER_ROOT)/Platforms/iPhoneSimulator.platform/Develop
# Ref: https://github.com/xamarin/xamarin-macios/issues/16223
OBJC_CFLAGS=-ObjC++ -std=c++14 -fno-exceptions -fno-objc-msgsend-selector-stubs
-COMMON_SIMULATOR_CFLAGS=-mios-simulator-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(SIMULATOR_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES)
+COMMON_SIMULATOR_CFLAGS=-mios-simulator-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(SIMULATOR_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES) \
+ -L$(SIMULATOR_SDK)/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator \
+ -Wno-unused-command-line-argument
SIMULATOR86_CFLAGS=$(COMMON_SIMULATOR_CFLAGS) -arch i386
SIMULATOR64_CFLAGS=$(COMMON_SIMULATOR_CFLAGS) -arch x86_64
SIMULATOR_ARM64_CFLAGS=$(COMMON_SIMULATOR_CFLAGS) -arch arm64
@@ -420,14 +421,20 @@ SIMULATOR_ARM64_OBJC_CFLAGS=$(COMMON_SIMULATOR_OBJC_CFLAGS) $(SIMULATOR_ARM64_CF
MACCATALYST_COMMON_CFLAGS=-target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi -arch x86_64 -g $(IOS_COMMON_DEFINES) \
-isysroot $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk \
-isystem $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/usr/include \
- -iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks
+ -iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks \
+ -L$(SIMULATOR_SDK)/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator \
+ -Wno-unused-command-line-argument
MACCATALYST_OBJC_CFLAGS=$(MACCATALYST_COMMON_CFLAGS) -fobjc-abi-version=2 -fobjc-legacy-dispatch $(OBJC_CFLAGS)
MACCATALYST_CFLAGS=$(MACCATALYST_COMMON_CFLAGS)
MACCATALYST_COMMON_CFLAGS=$(CFLAGS) -g $(IOS_COMMON_DEFINES) \
-isysroot $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk \
-isystem $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/usr/include \
- -iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks
+ -iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks \
+ -L$(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx \
+ -Wno-unused-command-line-argument
MACCATALYST_COMMON_OBJC_CFLAGS=$(MACCATALYST_COMMON_CFLAGS) -fobjc-abi-version=2 -fobjc-legacy-dispatch $(OBJC_CFLAGS)
MACCATALYST_X86_64_OBJC_CFLAGS=$(MACCATALYST_COMMON_OBJC_CFLAGS) -target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi -arch x86_64
MACCATALYST_X86_64_CFLAGS=$(MACCATALYST_COMMON_CFLAGS) -target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi -arch x86_64
@@ -448,9 +455,13 @@ MACCATALYST_CSC=$(SYSTEM_CSC) -features:strict -nostdlib -noconfig -r:$(MONOTOUC
DEVICE_OBJC_CFLAGS=$(OBJC_CFLAGS)
DEVICE_SDK=$(XCODE_DEVELOPER_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(IOS_SDK_VERSION).sdk
-DEVICE7_CFLAGS= -arch armv7 -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
-DEVICE7S_CFLAGS=-arch armv7s -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
-DEVICE64_CFLAGS=-arch arm64 -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
+DEVICE_SWIFT_CFLAGS=\
+ -L$(DEVICE_SDK)/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos \
+ -Wno-unused-command-line-argument
+DEVICE7_CFLAGS= -arch armv7 -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES) $(DEVICE_SWIFT_CFLAGS)
+DEVICE7S_CFLAGS=-arch armv7s -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES) $(DEVICE_SWIFT_CFLAGS)
+DEVICE64_CFLAGS=-arch arm64 -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES) $(DEVICE_SWIFT_CFLAGS)
DEVICE7_OBJC_CFLAGS =$(DEVICE7_CFLAGS) $(DEVICE_OBJC_CFLAGS)
DEVICE7S_OBJC_CFLAGS=$(DEVICE7S_CFLAGS) $(DEVICE_OBJC_CFLAGS)
DEVICE64_OBJC_CFLAGS=$(DEVICE64_CFLAGS) $(DEVICE_OBJC_CFLAGS)
@@ -488,13 +499,22 @@ XAMARIN_TVSIMULATOR_SDK = $(MONOTOUCH_PREFIX)/SDKs/Xamarin.AppleTVSimulator.s
XAMARIN_TVOS_SDK = $(MONOTOUCH_PREFIX)/SDKs/Xamarin.AppleTVOS.sdk
SIMULATORTV_SDK = $(XCODE_DEVELOPER_ROOT)/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator$(TVOS_SDK_VERSION).sdk
-SIMULATORTV_CFLAGS = -arch x86_64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES)
-SIMULATORTV_ARM64_CFLAGS = -arch arm64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES)
+SIMULATORTV_CFLAGS = -arch x86_64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES) \
+ -L$(SIMULATORTV_SDK)/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/appletvsimulator \
+ -Wno-unused-command-line-argument
+SIMULATORTV_ARM64_CFLAGS = -arch arm64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES) \
+ -L$(SIMULATORTV_SDK)/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/appletvsimulator \
+ -Wno-unused-command-line-argument
SIMULATORTV_OBJC_CFLAGS = $(SIMULATORTV_CFLAGS) $(COMMON_SIMULATOR_OBJC_CFLAGS)
SIMULATORTV_ARM64_OBJC_CFLAGS = $(SIMULATORTV_ARM64_CFLAGS) $(COMMON_SIMULATOR_OBJC_CFLAGS)
DEVICETV_SDK = $(XCODE_DEVELOPER_ROOT)/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS$(TVOS_SDK_VERSION).sdk
-DEVICETV_CFLAGS = -arch arm64 -mtvos-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(DEVICETV_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
+DEVICETV_CFLAGS = -arch arm64 -mtvos-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(DEVICETV_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)\
+ -L$(DEVICETV_SDK)/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/appletvos \
+ -Wno-unused-command-line-argument
DEVICETV_OBJC_CFLAGS = $(DEVICETV_CFLAGS) $(DEVICE_OBJC_CFLAGS)
# macOS
@@ -502,7 +522,10 @@ DEVICETV_OBJC_CFLAGS = $(DEVICETV_CFLAGS) $(DEVICE_OBJC_CFLAGS)
XAMARIN_MACOS_SDK = $(MAC_FRAMEWORK_CURRENT_DIR)/SDKs/Xamarin.macOS.sdk
MAC_OBJC_CFLAGS= -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -DMONOMAC -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\" $(CFLAGS) $(OBJC_CFLAGS)
-MAC_CFLAGS = -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -DMONOMAC -g -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\" $(CFLAGS)
+MAC_CFLAGS = -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -DMONOMAC -g -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\" $(CFLAGS) \
+ -L$(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/usr/lib/swift \
+ -L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx \
+ -Wno-unused-command-line-argument
MAC_LDFLAGS = -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -framework AppKit
# Swift compiler flags
@@ -529,7 +552,7 @@ WATCHOS_DEVICE_COMMON_SWIFTFLAGS=$(COMMON_SWIFTFLAGS) -sdk $(DEVICEWATCH_SDK)
WATCHOS_DEVICE_ARM64_32_SWIFTFLAGS=$(WATCHOS_DEVICE_COMMON_SWIFTFLAGS) -target arm64_32-apple-watchos$(MIN_WATCHOS_SDK_VERSION)
WATCHOS_DEVICE_ARMV7K_SWIFTFLAGS=$(WATCHOS_DEVICE_COMMON_SWIFTFLAGS) -target armv7k-apple-watchos$(MIN_WATCHOS_SDK_VERSION)
-MACCATALYST_COMMON_SWIFTFLAGS=$(COMMON_SWIFTFLAGS) -sdk $(XCODE_MAC_SDKROOT)
+MACCATALYST_COMMON_SWIFTFLAGS=$(COMMON_SWIFTFLAGS) -sdk $(XCODE_MAC_SDKROOT) -Fsystem $(XCODE_MAC_SDKROOT)/System/iOSSupport/System/Library/Frameworks
MACCATALYST_ARM64_SWIFTFLAGS=$(MACCATALYST_COMMON_SWIFTFLAGS) -target arm64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi
MACCATALYST_X64_SWIFTFLAGS=$(MACCATALYST_COMMON_SWIFTFLAGS) -target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi
@@ -785,18 +808,6 @@ DOTNET_TVOS_RUNTIME_IDENTIFIERS_64+=$(DOTNET_TVOS_RUNTIME_IDENTIFIERS)
endif # ENABLE_DOTNET
endif
-ifdef INCLUDE_DOTNET_WATCHOS
-DOTNET_PLATFORMS+=watchOS
-ifdef INCLUDE_DEVICE
-DOTNET_WATCHOS_RUNTIME_IDENTIFIERS=watchos-arm watchos-x86
-DOTNET_WATCHOS_RUNTIME_IDENTIFIERS_32=watchos-arm watchos-x86
-else
-DOTNET_WATCHOS_RUNTIME_IDENTIFIERS=watchos-x86 watchos-x64
-DOTNET_WATCHOS_RUNTIME_IDENTIFIERS_32=watchos-x86
-DOTNET_WATCHOS_RUNTIME_IDENTIFIERS_64=watchos-x64
-endif
-endif
-
ifdef INCLUDE_MACCATALYST
ifdef ENABLE_DOTNET
DOTNET_PLATFORMS+=MacCatalyst
diff --git a/configure b/configure
index 4fa03300a985..83f2ec39fb81 100755
--- a/configure
+++ b/configure
@@ -66,7 +66,6 @@ while test "x$1" != x; do
echo "INCLUDE_MAC=" >> $CONFIGURED_FILE
echo "INCLUDE_IOS=" >> $CONFIGURED_FILE
echo "INCLUDE_TVOS=" >> $CONFIGURED_FILE
- echo "INCLUDE_WATCH=" >> $CONFIGURED_FILE
echo "INCLUDE_MACCATALYST=" >> $CONFIGURED_FILE
echo "Disabled all platforms"
shift
@@ -105,16 +104,6 @@ while test "x$1" != x; do
echo "tvOS Build enabled"
shift
;;
- --disable-watchos)
- echo "INCLUDE_WATCH=" >> $CONFIGURED_FILE
- echo "watchOS Build disabled"
- shift
- ;;
- --enable-watchos)
- echo "INCLUDE_WATCH=1" >> $CONFIGURED_FILE
- echo "watchOS Build enabled"
- shift
- ;;
--disable-maccatalyst)
echo "INCLUDE_MACCATALYST=" >> $CONFIGURED_FILE
echo "Mac Catalyst Build disabled"
diff --git a/docs/build-apps/build-properties.md b/docs/build-apps/build-properties.md
index 5a478bbcbe6d..52101278797d 100644
--- a/docs/build-apps/build-properties.md
+++ b/docs/build-apps/build-properties.md
@@ -30,3 +30,15 @@ Example:
```
This property was introduced in .NET 9.
+
+## MetalLibPath
+
+The full path to the `metallib` tool (the Metal Linker).
+
+The default behavior is to use `xcrun metallib`.
+
+## MetalPath
+
+The full path to the Metal compiler.
+
+The default behavior is to use `xcrun metal`.
diff --git a/docs/preview-apis.md b/docs/preview-apis.md
index e056d55a8bac..7e6ad5448848 100644
--- a/docs/preview-apis.md
+++ b/docs/preview-apis.md
@@ -96,4 +96,17 @@ We've tentatively set .NET 11 as the release when we'll stop marking FSKit as pr
The diagnostic id for FSKit is APL0002.
+## StoreKit.AppStore.RequestReview (APL0004)
+
+The
+[AppStore.RequestReview](https://developer.apple.com/documentation/storekit/appstore/3954432-requestreview/)
+method is Swift API we've bound manually, and as such it's marked as experimental until .NET 10.
+
[1]: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.experimentalattribute?view=net-8.0
+
+## Rgen (APL0003)
+
+Rgen is the new Roslyn codegenerator based binding tool. The tool is underdevelopment and its API is open to change until
+a stable release is announced.
+
+The diagnostic id for Rgen is APL0003.
diff --git a/dotnet/generate-vs-workload.csharp b/dotnet/generate-vs-workload.csharp
index f5e53c5274bf..810254d11c29 100755
--- a/dotnet/generate-vs-workload.csharp
+++ b/dotnet/generate-vs-workload.csharp
@@ -57,6 +57,7 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
var manifestBuildVersion = iOSPlatform.Any () ? iOSPlatform.First ().Item2 : platforms.First ().Item2;
writer.WriteLine ($" {manifestBuildVersion}");
writer.WriteLine ($" true");
+ writer.WriteLine ($" true");
writer.WriteLine ($" ");
writer.WriteLine ($" ");
writer.WriteLine ($" ");
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index d4a2a1a92b6d..d70b434e4bf9 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -95,9 +95,9 @@
https://github.com/dotnet/templating
-
+
https://github.com/dotnet/xharness
- 973ef6c89b67f2f746f62c413e3aeeb01a9034a3
+ 8c6d5afd99c713777165f4378462085a5679c223
diff --git a/eng/Versions.props b/eng/Versions.props
index 760ddee27d26..a9c51618bc68 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -12,7 +12,7 @@
9.0.0-rc.2.24462.10
7.0.100-alpha.1.21601.1
0.11.5-alpha.24467.1
- 10.0.0-prerelease.24509.1
+ 10.0.0-prerelease.24511.1
$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100Version)
$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100Version)
diff --git a/mk/rules.mk b/mk/rules.mk
index 2d8fd7c512d3..32f808353331 100644
--- a/mk/rules.mk
+++ b/mk/rules.mk
@@ -52,6 +52,9 @@ define NativeCompilationTemplate
.libs/iphonesimulator/%$(1).x86_64.dylib: %.swift | .libs/iphonesimulator
$$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@
+.libs/iphonesimulator/%$(1).x86_64.o: %.swift | .libs/iphonesimulator
+ $$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/iphonesimulator/%$(1).x86_64.dylib: | .libs/iphonesimulator
$$(call Q_2,LD, [iphonesimulator]) $(SIMULATOR_CC) $(SIMULATOR64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_IOSSIMULATOR_SDK)/lib -fapplication-extension
@@ -72,6 +75,9 @@ define NativeCompilationTemplate
.libs/iphonesimulator/%$(1).arm64.dylib: %.swift | .libs/iphonesimulator
$$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@
+.libs/iphonesimulator/%$(1).arm64.o: %.swift | .libs/iphonesimulator
+ $$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/iphonesimulator/%$(1).arm64.dylib: | .libs/iphonesimulator
$$(call Q_2,LD, [iphonesimulator]) $(SIMULATOR_CC) $(SIMULATOR_ARM64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_IOSSIMULATOR_SDK)/lib -fapplication-extension
@@ -117,6 +123,9 @@ define NativeCompilationTemplate
.libs/iphoneos/%$(1).arm64.dylib: %.swift | .libs/iphoneos
$$(call Q_2,SWIFT, [iphoneos]) $(SWIFTC) $(IOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@
+.libs/iphoneos/%$(1).arm64.o: %.swift | .libs/iphoneos
+ $$(call Q_2,SWIFT, [iphoneos]) $(SWIFTC) $(IOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/iphoneos/%$(1).arm64.dylib: | .libs/iphoneos
$$(call Q_2,LD, [iphoneos]) $(DEVICE_CC) $(DEVICE64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_IPHONEOS_SDK)/lib -fapplication-extension
@@ -137,6 +146,9 @@ define NativeCompilationTemplate
.libs/maccatalyst/%$(1).x86_64.dylib: %.swift | .libs/maccatalyst
$$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_X64_SWIFTFLAGS) $$< -o $$@
+.libs/maccatalyst/%$(1).x86_64.o: %.swift | .libs/maccatalyst
+ $$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_X64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/maccatalyst/%$(1).x86_64.dylib: | .libs/maccatalyst
$$(call Q_2,LD, [maccatalyst]) $(XCODE_CC) $(MACCATALYST_X86_64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_MACCATALYST_SDK)/lib -fapplication-extension
@@ -155,6 +167,9 @@ define NativeCompilationTemplate
.libs/maccatalyst/%$(1).arm64.dylib: %.swift | .libs/maccatalyst
$$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_ARM64_SWIFTFLAGS) $$< -o $$@
+.libs/maccatalyst/%$(1).arm64.o: %.swift | .libs/maccatalyst
+ $$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/maccatalyst/%$(1).arm64.dylib: | .libs/maccatalyst
$$(call Q_2,LD, [maccatalyst]) $(XCODE_CC) $(MACCATALYST_ARM64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_MACCATALYST_SDK)/lib -fapplication-extension
@@ -247,6 +262,9 @@ define NativeCompilationTemplate
.libs/tvsimulator/%$(1).x86_64.dylib: %.swift | .libs/tvsimulator
$$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@
+.libs/tvsimulator/%$(1).x86_64.o: %.swift | .libs/tvsimulator
+ $$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/tvsimulator/%$(1).x86_64.dylib: | .libs/tvsimulator
$$(call Q_2,LD, [tvsimulator]) $(SIMULATOR_CC) $(SIMULATORTV_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib -fapplication-extension
@@ -267,6 +285,9 @@ define NativeCompilationTemplate
.libs/tvsimulator/%$(1).arm64.dylib: %.swift | .libs/tvsimulator
$$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@
+.libs/tvsimulator/%$(1).arm64.o: %.swift | .libs/tvsimulator
+ $$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/tvsimulator/%$(1).arm64.dylib: | .libs/tvsimulator
$$(call Q_2,LD, [tvsimulator]) $(SIMULATOR_CC) $(SIMULATORTV_ARM64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib -fapplication-extension
@@ -287,6 +308,9 @@ define NativeCompilationTemplate
.libs/tvos/%$(1).arm64.dylib: %.swift | .libs/tvos
$$(call Q_2,SWIFT, [tvos]) $(SWIFTC) $(TVOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@
+.libs/tvos/%$(1).arm64.o: %.swift | .libs/tvos
+ $$(call Q_2,SWIFT, [tvos]) $(SWIFTC) $(TVOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/tvos/%$(1).arm64.dylib: | .libs/tvos
$$(call Q_2,LD, [tvos]) $(DEVICE_CC) $(DEVICETV_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_TVOS_SDK)/lib -fapplication-extension
@@ -307,6 +331,15 @@ define NativeCompilationTemplate
.libs/mac/%$(1).x86_64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@
+.libs/mac/%$(1).x86_64.o: %.swift | .libs/mac
+ $$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
+.libs/macos/%$(1).x86_64.dylib: %.swift | .libs/mac
+ $$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@
+
+.libs/macos/%$(1).x86_64.o: %.swift | .libs/mac
+ $$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/macos/%$(1).x86_64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@
@@ -328,9 +361,15 @@ define NativeCompilationTemplate
.libs/mac/%$(1).arm64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@
+.libs/mac/%$(1).arm64.o: %.swift | .libs/mac
+ $$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/macos/%$(1).arm64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@
+.libs/macos/%$(1).arm64.o: %.swift | .libs/mac
+ $$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object
+
.libs/mac/%$(1).arm64.dylib: | .libs/mac
$$(call Q_2,LD, [mac]) $(MAC_CC) $(MAC_CFLAGS) $$(EXTRA_FLAGS) -arch arm64 -dynamiclib -o $$@ $$^ -L$(MAC_DESTDIR)$(XAMARIN_MACOS_SDK)/lib -fapplication-extension
diff --git a/msbuild/Makefile b/msbuild/Makefile
index f614321fc427..9cc8d6cc1731 100644
--- a/msbuild/Makefile
+++ b/msbuild/Makefile
@@ -9,19 +9,16 @@ endif
ifdef INCLUDE_TVOS
BUILD_IOS=1
endif
-ifdef INCLUDE_WATCH
-BUILD_IOS=1
-endif
ifdef INCLUDE_MACCATALYST
BUILD_IOS=1
endif
#
-# To add a new MSBuild assembly, add the base name to the corresponding [IOS|MAC|WATCH]_[BINDING]_TASK_ASSEMBLIES variable.
+# To add a new MSBuild assembly, add the base name to the corresponding [IOS|MAC]_[BINDING]_TASK_ASSEMBLIES variable.
#
# New .targets and .props files are picked up automatically if they're in a directory with already
# existing .targets or .props files. If .targets or .props are added in a new directory, add that
-# directory using a wildcard function to the corresponding [IOS|MAC|WATCH]_TARGETS variable.
+# directory using a wildcard function to the corresponding [IOS|MAC]_TARGETS variable.
#
##
@@ -144,44 +141,6 @@ MSBUILD_DIRECTORIES += $(MACCATALYST_DIRECTORIES)
MSBUILD_SYMLINKS += symlinks-maccatalyst
endif
-##
-## XW definitions
-##
-
-WATCH_TARGETS = \
- $(wildcard Xamarin.Shared/Xamarin.WatchOS.*.props) \
- $(wildcard Xamarin.Shared/Xamarin.WatchOS.*.targets) \
- Xamarin.MacDev.Tasks/NoCode.cs \
- $(wildcard Xamarin.Shared/Xamarin.ImplicitFacade.targets) \
-
-WATCH_DIRECTORIES = \
- $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/RedistList \
- $(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks/Xamarin.WatchOS/v1.0/RedistList \
- $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS \
-
-# XW symlinks the entire $(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS directory to
-# /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/WatchOS instead of
-# each separate file (like XI does).
-
-WATCH_SYMLINKS = \
- $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/RedistList/FrameworkList.xml \
- $(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks/Xamarin.WatchOS/v1.0/RedistList/FrameworkList.xml \
- $(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/WatchOS \
-
-WATCH_PRODUCTS = \
- $(WATCH_SYMLINKS) \
- $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS/FrameworkList.xml \
- $(foreach target,$(WATCH_TARGETS) ,$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS/$(notdir $(target))) \
-
-all-watch: $(WATCH_PRODUCTS)
-symlinks-watch: $(WATCH_SYMLINKS)
-
-ifdef INCLUDE_WATCH
-MSBUILD_PRODUCTS += all-watch
-MSBUILD_DIRECTORIES += $(WATCH_DIRECTORIES)
-MSBUILD_SYMLINKS += symlinks-watch
-endif
-
##
## Xamarin.TVOS definitions
##
@@ -333,25 +292,6 @@ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.MacCatalyst/RedistList/Framew
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/MacCatalyst/%: Xamarin.Shared/% | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/MacCatalyst
$(Q) install -m 644 $< $@
-##
-## XW
-##
-
-$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks/Xamarin.WatchOS/v1.0/RedistList/FrameworkList.xml: | $(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks/Xamarin.WatchOS/v1.0/RedistList
- $(Q) ln -fs $(IOS_TARGETDIR)/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/msbuild/WatchOS/$(notdir $@) $@
-
-$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/WatchOS: | $(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild/Xamarin
- $(Q) ln -Fhs $(IOS_TARGETDIR)/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/msbuild/WatchOS $@
-
-$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS/FrameworkList.xml: Xamarin.Shared/Xamarin.WatchOS-FrameworkList.xml.in Makefile | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS
- $(Q) sed 's@%TargetFrameworkDirectory%@$(IOS_TARGETDIR)/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.WatchOS@' $< > $@
-
-$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS/RedistList/FrameworkList.xml: $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS/FrameworkList.xml | $(WATCH_DIRECTORIES)
- $(Q) ln -fs $(IOS_TARGETDIR)/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/msbuild/WatchOS/$(notdir $@) $@
-
-$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS/%: Xamarin.Shared/% | $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/msbuild/WatchOS
- $(Q) install -m 644 $< $@
-
##
## Xamarin.TVOS
##
@@ -415,11 +355,10 @@ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/msbuild/%: Xamarin.Localization.M
## net5 targets ##
##
-# tvOS and watchOS ships most of the iOS targets as well (for now, we don't need all of these, so this is optimizable)
+# tvOS ships most of the iOS targets as well (for now, we don't need all of these, so this is optimizable)
DOTNET_SHARED_FILES = $(IOS_TARGETS) $(IOS_BINDING_TARGETS) $(foreach dll,$(IOS_TASK_ASSEMBLIES),$(dll).dll $(dll).pdb)
DOTNET_IOS_FILES = $(DOTNET_SHARED_FILES) FrameworkList.xml
DOTNET_TVOS_FILES = $(TVOS_TARGETS) FrameworkList.xml
-DOTNET_WATCHOS_FILES = $(WATCH_TARGETS) FrameworkList.xml
DOTNET_MACOS_FILES = $(MAC_TARGETS) $(MAC_BINDING_TARGETS) $(foreach dll,$(MAC_TASK_ASSEMBLIES),$(dll).dll $(dll).pdb) FrameworkList.xml
DOTNET_MACCATALYST_FILES = $(MACCATALYST_TARGETS) FrameworkList.xml
diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/Metal.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/Metal.cs
index dffb0dd4724a..bf3f7b927e8d 100644
--- a/msbuild/Xamarin.MacDev.Tasks/Tasks/Metal.cs
+++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/Metal.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
+using System.Threading;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
@@ -11,77 +12,53 @@
using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;
-// Disable until we get around to enable + fix any issues.
-#nullable disable
-
namespace Xamarin.MacDev.Tasks {
- public class Metal : XamarinToolTask {
+ public class Metal : XamarinTask {
+ CancellationTokenSource? cancellationTokenSource;
+
#region Inputs
[Required]
- public string IntermediateOutputPath { get; set; }
+ public string IntermediateOutputPath { get; set; } = string.Empty;
+
+ public string MetalPath { get; set; } = string.Empty;
[Required]
- public string MinimumOSVersion { get; set; }
+ public string MinimumOSVersion { get; set; } = string.Empty;
[Required]
- public string ProjectDir { get; set; }
+ public string ProjectDir { get; set; } = string.Empty;
[Required]
- public string ResourcePrefix { get; set; }
+ public string ResourcePrefix { get; set; } = string.Empty;
[Required]
- public string SdkDevPath { get; set; }
+ public string SdkDevPath { get; set; } = string.Empty;
[Required]
- public string SdkVersion { get; set; }
+ public string SdkVersion { get; set; } = string.Empty;
[Required]
public bool SdkIsSimulator { get; set; }
[Required]
- public string SdkRoot { get; set; }
+ public string SdkRoot { get; set; } = string.Empty;
[Required]
- public ITaskItem SourceFile { get; set; }
+ public ITaskItem? SourceFile { get; set; }
#endregion
[Output]
- public ITaskItem OutputFile { get; set; }
-
- string DevicePlatformBinDir {
- get {
- switch (Platform) {
- case ApplePlatform.iOS:
- case ApplePlatform.TVOS:
- case ApplePlatform.WatchOS:
- return AppleSdkSettings.XcodeVersion.Major >= 11
- ? Path.Combine (SdkDevPath, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin")
- : Path.Combine (SdkDevPath, "Platforms", "iPhoneOS.platform", "usr", "bin");
- case ApplePlatform.MacOSX:
- case ApplePlatform.MacCatalyst:
- return AppleSdkSettings.XcodeVersion.Major >= 10
- ? Path.Combine (SdkDevPath, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin")
- : Path.Combine (SdkDevPath, "Platforms", "MacOSX.platform", "usr", "bin");
- default:
- throw new InvalidOperationException (string.Format (MSBStrings.InvalidPlatform, Platform));
- }
- }
- }
+ public ITaskItem? OutputFile { get; set; }
- protected override string ToolName {
- get { return "metal"; }
- }
-
- protected override string GenerateFullPathToTool ()
+ static string GetExecutable (List arguments, string toolName, string toolPathOverride)
{
- if (!string.IsNullOrEmpty (ToolPath))
- return Path.Combine (ToolPath, ToolExe);
-
- var path = Path.Combine (DevicePlatformBinDir, ToolExe);
-
- return File.Exists (path) ? path : ToolExe;
+ if (string.IsNullOrEmpty (toolPathOverride)) {
+ arguments.Insert (0, toolName);
+ return "xcrun";
+ }
+ return toolPathOverride;
}
public override bool Execute ()
@@ -89,37 +66,36 @@ public override bool Execute ()
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
- if (AppleSdkSettings.XcodeVersion.Major >= 11)
- EnvironmentVariables = EnvironmentVariables.CopyAndAdd ($"SDKROOT={SdkRoot}");
- return base.Execute ();
- }
+ var env = new Dictionary {
+ { "SDKROOT", SdkRoot },
+ };
- protected override string GenerateCommandLineCommands ()
- {
var prefixes = BundleResource.SplitResourcePrefixes (ResourcePrefix);
- var intermediate = Path.Combine (IntermediateOutputPath, ToolName);
- var logicalName = BundleResource.GetLogicalName (ProjectDir, prefixes, SourceFile, !string.IsNullOrEmpty (SessionId));
+ var intermediate = Path.Combine (IntermediateOutputPath, MetalPath);
+ var logicalName = BundleResource.GetLogicalName (ProjectDir, prefixes, SourceFile!, !string.IsNullOrEmpty (SessionId));
var path = Path.Combine (intermediate, logicalName);
- var args = new CommandLineArgumentBuilder ();
+ var args = new List ();
var dir = Path.GetDirectoryName (path);
- if (!Directory.Exists (dir))
- Directory.CreateDirectory (dir);
+ Directory.CreateDirectory (dir);
OutputFile = new TaskItem (Path.ChangeExtension (path, ".air"));
OutputFile.SetMetadata ("LogicalName", Path.ChangeExtension (logicalName, ".air"));
- args.Add ("-arch", "air64");
+ var executable = GetExecutable (args, "metal", MetalPath);
+
+ args.Add ("-arch");
+ args.Add ("air64");
args.Add ("-emit-llvm");
args.Add ("-c");
args.Add ("-gline-tables-only");
args.Add ("-ffast-math");
args.Add ("-serialize-diagnostics");
- args.AddQuoted (Path.ChangeExtension (path, ".dia"));
+ args.Add (Path.ChangeExtension (path, ".dia"));
args.Add ("-o");
- args.AddQuoted (Path.ChangeExtension (path, ".air"));
+ args.Add (Path.ChangeExtension (path, ".air"));
if (Platform == ApplePlatform.MacCatalyst) {
args.Add ($"-target");
@@ -127,23 +103,21 @@ protected override string GenerateCommandLineCommands ()
} else {
args.Add (PlatformFrameworkHelper.GetMinimumVersionArgument (TargetFrameworkMoniker, SdkIsSimulator, MinimumOSVersion));
}
- args.AddQuoted (SourceFile.ItemSpec);
+ args.Add (SourceFile!.ItemSpec);
- return args.ToString ();
- }
+ cancellationTokenSource = new CancellationTokenSource ();
+ ExecuteAsync (Log, executable, args, environment: env, cancellationToken: cancellationTokenSource.Token).Wait ();
- protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance)
- {
- // TODO: do proper parsing of error messages and such
- Log.LogMessage (messageImportance, "{0}", singleLine);
+ return !Log.HasLoggedErrors;
}
- public override void Cancel ()
+ public void Cancel ()
{
- if (ShouldExecuteRemotely ())
+ if (ShouldExecuteRemotely ()) {
BuildConnection.CancelAsync (BuildEngine4).Wait ();
-
- base.Cancel ();
+ } else {
+ cancellationTokenSource?.Cancel ();
+ }
}
}
}
diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/MetalLib.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/MetalLib.cs
index a98654fb4dd4..2c689669a2f1 100644
--- a/msbuild/Xamarin.MacDev.Tasks/Tasks/MetalLib.cs
+++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/MetalLib.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Threading;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
@@ -10,78 +11,35 @@
using Xamarin.Messaging.Build.Client;
using Xamarin.Utils;
-// Disable until we get around to enable + fix any issues.
-#nullable disable
-
namespace Xamarin.MacDev.Tasks {
- public class MetalLib : XamarinToolTask, ITaskCallback {
+ public class MetalLib : XamarinTask, ITaskCallback {
+ CancellationTokenSource? cancellationTokenSource;
+
#region Inputs
[Required]
- public ITaskItem [] Items { get; set; }
+ public ITaskItem [] Items { get; set; } = Array.Empty ();
+
+ public string MetalLibPath { get; set; } = string.Empty;
[Required]
- public string OutputLibrary { get; set; }
+ public string OutputLibrary { get; set; } = string.Empty;
[Required]
- public string SdkDevPath { get; set; }
+ public string SdkDevPath { get; set; } = string.Empty;
[Required]
- public string SdkRoot { get; set; }
+ public string SdkRoot { get; set; } = string.Empty;
#endregion
- string DevicePlatformBinDir {
- get {
- switch (Platform) {
- case ApplePlatform.iOS:
- case ApplePlatform.TVOS:
- case ApplePlatform.WatchOS:
- return AppleSdkSettings.XcodeVersion.Major >= 11
- ? Path.Combine (SdkDevPath, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin")
- : Path.Combine (SdkDevPath, "Platforms", "iPhoneOS.platform", "usr", "bin");
- case ApplePlatform.MacOSX:
- case ApplePlatform.MacCatalyst:
- return AppleSdkSettings.XcodeVersion.Major >= 10
- ? Path.Combine (SdkDevPath, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin")
- : Path.Combine (SdkDevPath, "Platforms", "MacOSX.platform", "usr", "bin");
- default:
- throw new InvalidOperationException (string.Format (MSBStrings.InvalidPlatform, Platform));
- }
- }
- }
-
- protected override string ToolName {
- get { return "metallib"; }
- }
-
- protected override string GenerateFullPathToTool ()
+ static string GetExecutable (List arguments, string toolName, string toolPathOverride)
{
- if (!string.IsNullOrEmpty (ToolPath))
- return Path.Combine (ToolPath, ToolExe);
-
- var path = Path.Combine (DevicePlatformBinDir, ToolExe);
-
- return File.Exists (path) ? path : ToolExe;
- }
-
- protected override string GenerateCommandLineCommands ()
- {
- var args = new CommandLineArgumentBuilder ();
-
- args.Add ("-o");
- args.AddQuoted (OutputLibrary);
-
- foreach (var item in Items)
- args.AddQuoted (item.ItemSpec);
-
- return args.ToString ();
- }
-
- protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance)
- {
- // TODO: do proper parsing of error messages and such
- Log.LogMessage (messageImportance, "{0}", singleLine);
+ if (string.IsNullOrEmpty (toolPathOverride)) {
+ arguments.Insert (0, toolName);
+ return "xcrun";
+ }
+ return toolPathOverride;
}
public override bool Execute ()
@@ -90,14 +48,24 @@ public override bool Execute ()
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
var dir = Path.GetDirectoryName (OutputLibrary);
+ Directory.CreateDirectory (dir);
- if (!Directory.Exists (dir))
- Directory.CreateDirectory (dir);
+ var env = new Dictionary {
+ { "SDKROOT", SdkRoot },
+ };
- if (AppleSdkSettings.XcodeVersion.Major >= 11)
- EnvironmentVariables = EnvironmentVariables.CopyAndAdd ($"SDKROOT={SdkRoot}");
+ var args = new List ();
+ args.Add ("-o");
+ args.Add (OutputLibrary);
+ foreach (var item in Items)
+ args.Add (item.ItemSpec);
+
+ var executable = GetExecutable (args, "metallib", MetalLibPath);
+
+ cancellationTokenSource = new CancellationTokenSource ();
+ ExecuteAsync (Log, executable, args, environment: env, cancellationToken: cancellationTokenSource.Token).Wait ();
- return base.Execute ();
+ return !Log.HasLoggedErrors;
}
public bool ShouldCopyToBuildServer (ITaskItem item) => false;
@@ -106,12 +74,13 @@ public override bool Execute ()
public IEnumerable GetAdditionalItemsToBeCopied () => Enumerable.Empty ();
- public override void Cancel ()
+ public void Cancel ()
{
- base.Cancel ();
-
- if (ShouldExecuteRemotely ())
+ if (ShouldExecuteRemotely ()) {
BuildConnection.CancelAsync (BuildEngine4).Wait ();
+ } else {
+ cancellationTokenSource?.Cancel ();
+ }
}
}
}
diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs
index e17775c17c75..ab5fc5e04ed0 100644
--- a/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs
+++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Threading;
using Microsoft.Build.Framework;
using Microsoft.Build.Tasks;
@@ -120,7 +121,7 @@ protected System.Threading.Tasks.Task ExecuteAsync (string fileName,
return ExecuteAsync (Log, fileName, arguments, sdkDevPath, environment, mergeOutput, showErrorIfFailure, workingDirectory);
}
- internal protected static async System.Threading.Tasks.Task ExecuteAsync (TaskLoggingHelper log, string fileName, IList arguments, string? sdkDevPath = null, Dictionary? environment = null, bool mergeOutput = true, bool showErrorIfFailure = true, string? workingDirectory = null)
+ internal protected static async System.Threading.Tasks.Task ExecuteAsync (TaskLoggingHelper log, string fileName, IList arguments, string? sdkDevPath = null, Dictionary? environment = null, bool mergeOutput = true, bool showErrorIfFailure = true, string? workingDirectory = null, CancellationToken? cancellationToken = null)
{
// Create a new dictionary if we're given one, to make sure we don't change the caller's dictionary.
var launchEnvironment = environment is null ? new Dictionary () : new Dictionary (environment);
@@ -128,7 +129,7 @@ internal protected static async System.Threading.Tasks.Task ExecuteAs
launchEnvironment ["DEVELOPER_DIR"] = sdkDevPath;
log.LogMessage (MessageImportance.Normal, MSBStrings.M0001, fileName, StringUtils.FormatArguments (arguments));
- var rv = await Execution.RunAsync (fileName, arguments, environment: launchEnvironment, mergeOutput: mergeOutput, workingDirectory: workingDirectory);
+ var rv = await Execution.RunAsync (fileName, arguments, environment: launchEnvironment, mergeOutput: mergeOutput, workingDirectory: workingDirectory, cancellationToken: cancellationToken);
log.LogMessage (rv.ExitCode == 0 ? MessageImportance.Low : MessageImportance.High, MSBStrings.M0002, fileName, rv.ExitCode);
// Show the output
diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets
index bc155c936ad5..e92e02dae188 100644
--- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets
+++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets
@@ -1398,6 +1398,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' and '%(Metal.Identity)' != ''"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
+ MetalPath="$(MetalPath)"
MinimumOSVersion="$(_MinimumOSVersion)"
ProjectDir="$(MSBuildProjectDirectory)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
@@ -1417,6 +1418,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
Items="@(_SmeltedMetal)"
+ MetalLibPath="$(MetalLibPath)"
SdkDevPath="$(_SdkDevPath)"
SdkRoot="$(_SdkRoot)"
OutputLibrary="$(_AppResourcesPath)default.metallib">
diff --git a/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets b/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets
index 3e7f4b9de394..4ed1bd93a17b 100644
--- a/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets
+++ b/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets
@@ -403,6 +403,10 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved.
+
+
+ <_ILLinkExitCode Condition="'$(_ILLinkExitCode)' == '' And '$(MSBuildLastTaskResult)' != 'true'">-1
+
diff --git a/runtime/Makefile b/runtime/Makefile
index 2d95fa5973a5..72ca9932f4d9 100644
--- a/runtime/Makefile
+++ b/runtime/Makefile
@@ -22,7 +22,7 @@ SHIPPED_HEADERS += \
xamarin/monovm-bridge.h \
xamarin/coreclr-bridge.h \
-SHARED_SOURCES += mono-runtime.m bindings.m bindings-generated.m shared.m runtime.m trampolines.m trampolines-invoke.m xamarin-support.m nsstring-localization.m trampolines-varargs.m monovm-bridge.m coreclr-bridge.m nativeaot-bridge.m
+SHARED_SOURCES += mono-runtime.m bindings.m bindings-generated.m shared.m runtime.m trampolines.m trampolines-invoke.m xamarin-support.m nsstring-localization.m trampolines-varargs.m monovm-bridge.m coreclr-bridge.m nativeaot-bridge.m swift-functions.swift
SHARED_I386_SOURCES += trampolines-i386.m trampolines-i386-asm.s trampolines-i386-objc_msgSend.s trampolines-i386-objc_msgSendSuper.s trampolines-i386-objc_msgSend_stret.s trampolines-i386-objc_msgSendSuper_stret.s
SHARED_X86_64_SOURCES += trampolines-x86_64.m trampolines-x86_64-asm.s trampolines-x86_64-objc_msgSend.s trampolines-x86_64-objc_msgSendSuper.s trampolines-x86_64-objc_msgSend_stret.s trampolines-x86_64-objc_msgSendSuper_stret.s
SHARED_ARM64_SOURCES += trampolines-arm64.m trampolines-arm64-asm.s trampolines-arm64-objc_msgSend.s trampolines-arm64-objc_msgSendSuper.s
@@ -69,14 +69,14 @@ bindings-generated.m: $(BINDINGS_GENERATOR)
# our makefiles don't support building the same source file multiple times with different defines,
# so just symlink extension-main.m to another file and compile that instead.
-app-main.m watchextension-main.m tvextension-main.m: extension-main.m
+app-main.m tvextension-main.m: extension-main.m
$(Q_LN) ln -fs $< $@
product.h: product.in.h Makefile $(GIT_DIRECTORY)/index
$(Q) sed -e 's/@PRODUCT_HASH@/$(CURRENT_HASH_LONG)/' $< > $@.tmp
$(Q) mv $@.tmp $@
#
-# MonoTouch defines (used for all MonoTouch platforms: iOS, WatchOS and TVOS)
+# MonoTouch defines (used for all MonoTouch platforms: iOS and TVOS)
#
MONOTOUCH_SOURCES = \
@@ -99,7 +99,7 @@ MONOTOUCH_FRAMEWORKS = \
Xamarin \
Xamarin-debug \
-MONOTOUCH_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_SOURCES) $(MONOTOUCH_SOURCES)))
+MONOTOUCH_SOURCE_STEMS = $(patsubst %.swift,%,$(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_SOURCES) $(MONOTOUCH_SOURCES))))
MONOTOUCH_I386_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_I386_SOURCES)))
MONOTOUCH_X86_64_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_X86_64_SOURCES)))
MONOTOUCH_ARM64_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_ARM64_SOURCES)))
@@ -166,17 +166,6 @@ endif
$(eval $(call FrameworkTemplate,iphonesimulator,IOSSIMULATOR,$(IOS_SIMULATOR_ARCHITECTURES)))
endif
-ifdef INCLUDE_WATCH
-ifdef INCLUDE_DEVICE
-ifdef WATCHOS_SUPPORTS_32BIT_DEVICE_ARCHITECTURES
-$(eval $(call FrameworkTemplate,watchos,WATCHOS,armv7k arm64_32))
-else
-$(eval $(call FrameworkTemplate,watchos,WATCHOS,arm64_32))
-endif
-endif
-$(eval $(call FrameworkTemplate,watchsimulator,WATCHSIMULATOR,x86))
-endif
-
ifdef INCLUDE_TVOS
ifdef INCLUDE_DEVICE
$(eval $(call FrameworkTemplate,tvos,TVOS,arm64))
@@ -241,17 +230,6 @@ ifdef INCLUDE_MACCATALYST
$(eval $(call PlatformTemplate,maccatalyst,MACCATALYST,x86_64))
endif
-ifdef INCLUDE_WATCH
-ifdef INCLUDE_DEVICE
-ifdef WATCHOS_SUPPORTS_32BIT_DEVICE_ARCHITECTURES
-$(eval $(call PlatformTemplate,watchos,WATCHOS,armv7k arm64_32))
-else
-$(eval $(call PlatformTemplate,watchos,WATCHOS,arm64_32))
-endif
-endif
-$(eval $(call PlatformTemplate,watchsimulator,WATCHSIMULATOR,x86 x86_64))
-endif
-
ifdef INCLUDE_TVOS
ifdef INCLUDE_DEVICE
$(eval $(call PlatformTemplate,tvos,TVOS,arm64))
@@ -269,7 +247,6 @@ endif
define LibTemplate
$$(foreach arch,$$($(2)_ARCHITECTURES),.libs/$(1)/extension-main.$$(arch).o): EXTRA_DEFINES=-DEXTENSION
-$$(foreach arch,$$($(2)_ARCHITECTURES),.libs/$(1)/watchextension-main.$$(arch).o): EXTRA_DEFINES=-DWATCH_EXTENSION
$$(foreach arch,$$($(2)_ARCHITECTURES),.libs/$(1)/tvextension-main.$$(arch).o): EXTRA_DEFINES=-DTV_EXTENSION
.libs/$(1)/libextension.%.a: .libs/$(1)/extension-main.%.o
@@ -322,8 +299,6 @@ endef
$(eval $(call LibTemplate,iphoneos,IPHONEOS))
$(eval $(call LibTemplate,iphonesimulator,IOSSIMULATOR))
$(eval $(call LibTemplate,maccatalyst,MACCATALYST))
-$(eval $(call LibTemplate,watchos,WATCHOS))
-$(eval $(call LibTemplate,watchsimulator,WATCHSIMULATOR))
$(eval $(call LibTemplate,tvos,TVOS))
$(eval $(call LibTemplate,tvsimulator,TVSIMULATOR))
@@ -406,10 +381,6 @@ $(eval $(call LibXamarinTemplate,iphonesimulator,IOSSIMULATOR))
$(eval $(call LibXamarinTemplate,iphonesimulator,IOSSIMULATOR,_DEBUG,-debug))
$(eval $(call LibXamarinTemplate,maccatalyst,MACCATALYST))
$(eval $(call LibXamarinTemplate,maccatalyst,MACCATALYST,_DEBUG,-debug))
-$(eval $(call LibXamarinTemplate,watchos,WATCHOS))
-$(eval $(call LibXamarinTemplate,watchos,WATCHOS,_DEBUG,-debug))
-$(eval $(call LibXamarinTemplate,watchsimulator,WATCHSIMULATOR))
-$(eval $(call LibXamarinTemplate,watchsimulator,WATCHSIMULATOR,_DEBUG,-debug))
$(eval $(call LibXamarinTemplate,tvos,TVOS))
$(eval $(call LibXamarinTemplate,tvos,TVOS,_DEBUG,-debug))
$(eval $(call LibXamarinTemplate,tvsimulator,TVSIMULATOR))
diff --git a/runtime/swift-functions.swift b/runtime/swift-functions.swift
new file mode 100644
index 000000000000..1f826a771560
--- /dev/null
+++ b/runtime/swift-functions.swift
@@ -0,0 +1,29 @@
+#if os(macOS)
+import AppKit
+#endif
+import Foundation
+import StoreKit
+#if !os(macOS)
+import UIKit
+#endif
+
+@objc(XamarinSwiftFunctions)
+public class XamarinSwiftFunctions : NSObject {
+#if os(macOS)
+ @MainActor
+ @objc(requestReview:)
+ @available(macOS 13, *)
+ public static func StoreKit_RequestReview(scene: NSViewController)
+ {
+ AppStore.requestReview(in: scene)
+ }
+#elseif !os(tvOS)
+ @MainActor
+ @objc(requestReview:)
+ @available(iOS 16, macCatalyst 16, *)
+ public static func StoreKit_RequestReview(scene: UIWindowScene)
+ {
+ AppStore.requestReview(in: scene)
+ }
+#endif
+}
diff --git a/src/AVFoundation/AVCaptureReactionType.rgen.cs b/src/AVFoundation/AVCaptureReactionType.rgen.cs
new file mode 100644
index 000000000000..de1bc4ee63f7
--- /dev/null
+++ b/src/AVFoundation/AVCaptureReactionType.rgen.cs
@@ -0,0 +1,44 @@
+#pragma warning disable APL0003
+using System;
+using System.Runtime.Versioning;
+
+using Foundation;
+using ObjCRuntime;
+using ObjCBindings;
+
+#nullable enable
+
+namespace AVFoundation {
+
+ [BindingTypeAttribute]
+ [SupportedOSPlatform ("ios17.0")]
+ [SupportedOSPlatform ("tvos17.0")]
+ [SupportedOSPlatform ("maccatalyst17.0")]
+ [SupportedOSPlatform ("macos14.0")]
+ public enum AVCaptureReactionType {
+ [Field ("AVCaptureReactionTypeThumbsUp")]
+ ThumbsUp,
+
+ [Field ("AVCaptureReactionTypeThumbsDown")]
+ ThumbsDown,
+
+ [Field ("AVCaptureReactionTypeBalloons")]
+ Balloons,
+
+ [Field ("AVCaptureReactionTypeHeart")]
+ Heart,
+
+ [Field ("AVCaptureReactionTypeFireworks")]
+ Fireworks,
+
+ [Field ("AVCaptureReactionTypeRain")]
+ Rain,
+
+ [Field ("AVCaptureReactionTypeConfetti")]
+ Confetti,
+
+ [Field ("AVCaptureReactionTypeLasers")]
+ Lasers,
+ }
+}
+#pragma warning restore APL0003
diff --git a/src/Makefile b/src/Makefile
index ea2a4162dcb4..bb088101958c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -103,6 +103,7 @@ DOTNET_WARNINGS_TO_FIX = -nowarn:$(CSC_WARNINGS_TO_FIX)
DOTNET_CORE_WARNINGS_TO_FIX = -nowarn:$(CSC_WARNINGS_TO_FIX),$(BGEN_WARNINGS_TO_FIX)
include ./Makefile.generator
+include ./Makefile.rgenerator
include ./generator-diff.mk
SHARED_RESX = $(TOP)/tools/mtouch/Errors.resx
@@ -355,7 +356,7 @@ $($(2)_DOTNET_BUILD_DIR)/core-$(3).dll: $($(2)_DOTNET_CORE_SOURCES) frameworks.s
$($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources: $(DOTNET_GENERATOR) $($(2)_DOTNET_APIS) $($(2)_DOTNET_BUILD_DIR)/core-$(3).dll $(DOTNET_BINDING_ATTRIBUTES) $($(2)_DOTNET_BUILD_DIR)/$(3).rsp | $($(2)_DOTNET_BUILD_DIR)/generated-sources
$$(Q_DOTNET_GEN) $$< @$($(2)_DOTNET_BUILD_DIR)/$(3).rsp
-$($(2)_DOTNET_BUILD_DIR)/$(3).rsp: Makefile Makefile.generator frameworks.sources $(DOTNET_COMPILER) | $($(2)_DOTNET_BUILD_DIR)
+$($(2)_DOTNET_BUILD_DIR)/$(3).rsp: Makefile Makefile.generator Makefile.rgenerator frameworks.sources $(ROSLYN_GENERATOR) $(DOTNET_COMPILER) | $($(2)_DOTNET_BUILD_DIR)
$(Q) echo \
$($(2)_GENERATOR_FLAGS) \
$(DOTNET_GENERATOR_FLAGS) \
@@ -450,10 +451,11 @@ $(2)_DOTNET_PLATFORM_ASSEMBLY_DIR_DEPENDENCIES = \
$($(2)_DOTNET_BUILD_DIR)/$(4) \
$($(2)_DOTNET_BUILD_DIR)/ref \
-$($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%dll $($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%pdb $$($(2)_$(4)_REF_TARGET) $$($(2)_$(4)_DOC_TARGET): $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DEPENDENCIES) | $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DIR_DEPENDENCIES)
+$($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%dll $($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%pdb $$($(2)_$(4)_REF_TARGET) $$($(2)_$(4)_DOC_TARGET): $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DEPENDENCIES) $$(ROSLYN_GENERATOR) | $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DIR_DEPENDENCIES)
$$(call Q_PROF_CSC,dotnet/$(4)-bit) \
$(DOTNET_CSC) \
$(DOTNET_FLAGS) \
+ /analyzer:$(ROSLYN_GENERATOR) \
-unsafe \
-optimize \
$$(ARGS_$(1)) \
diff --git a/src/Makefile.rgenerator b/src/Makefile.rgenerator
new file mode 100644
index 000000000000..e3bd9f2b997a
--- /dev/null
+++ b/src/Makefile.rgenerator
@@ -0,0 +1,8 @@
+# Roslyn code generator
+ROSLYN_GENERATOR=$(DOTNET_BUILD_DIR)/common/rgen/Microsoft.Macios.Generator.dll
+ROSLYN_GENERATOR_FILES := $(wildcard rgen/Microsoft.Macios.Generator/*.cs)
+
+$(ROSLYN_GENERATOR): Makefile.rgenerator $(ROSLYN_GENERATOR_FILES)
+ $(Q_DOTNET_BUILD) $(DOTNET) publish rgen/Microsoft.Macios.Generator/Microsoft.Macios.Generator.csproj $(DOTNET_BUILD_VERBOSITY) /p:Configuration=Debug /p:IntermediateOutputPath=$(abspath $(DOTNET_BUILD_DIR)/IDE/obj/common/rgen)/ /p:OutputPath=$(abspath $(DOTNET_BUILD_DIR)/IDE/bin/common/rgen/)/
+ @mkdir -p $(dir $@)
+ $(Q) $(CP) -r $(DOTNET_BUILD_DIR)/IDE/bin/common/rgen/publish/* $(dir $@)
diff --git a/src/ObjCBindings/BindingTypeAttribute.cs b/src/ObjCBindings/BindingTypeAttribute.cs
new file mode 100644
index 000000000000..6f936d77c69a
--- /dev/null
+++ b/src/ObjCBindings/BindingTypeAttribute.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Reflection;
+using System.Diagnostics.CodeAnalysis;
+
+namespace ObjCBindings {
+
+ ///
+ /// Attribute that indicates that a class or enum is a binding type. This attribute is used by the binding generator
+ /// to generate all the necessary code for the binding. The attribute can be used in a class or enum and it is required.
+ ///
+ /// If the attribute is used in a class, the class must be partial otherwise the generator will fail.
+ ///
+ [Experimental ("APL0003")]
+ [AttributeUsage (AttributeTargets.Class | System.AttributeTargets.Enum, AllowMultiple = false)]
+ public class BindingTypeAttribute : Attribute {
+
+ ///
+ /// Indicates the name of the binding type. This is the name that will be used by the registrar to make the
+ /// class available in the ObjC runtime. The default value is string.Empty, in that case the generator
+ /// will use the name of the C# class.
+ ///
+ public string Name { get; set; } = string.Empty;
+ }
+
+}
diff --git a/src/StoreKit/SwiftAPI.cs b/src/StoreKit/SwiftAPI.cs
new file mode 100644
index 000000000000..3ea8d380acfb
--- /dev/null
+++ b/src/StoreKit/SwiftAPI.cs
@@ -0,0 +1,37 @@
+#if __IOS__ || __MACCATALYST__ || __MACOS__
+
+using System.Diagnostics.CodeAnalysis;
+
+#if HAS_APPKIT
+using AppKit;
+#endif
+
+#if HAS_UIKIT
+using UIKit;
+#endif
+
+namespace StoreKit {
+
+ /// A class to interact with the App Store.
+#if !NET10_0_OR_GREATER
+ [Experimental ("APL0004")]
+#endif
+ public static class AppStore {
+ /// Ask StoreKit to request an App Store review or rating from the user.
+ /// The scene or view controller to display the interface in.
+ [SupportedOSPlatform ("ios16.0")]
+ [SupportedOSPlatform ("maccatalyst16.0")]
+ [SupportedOSPlatform ("macos13.0")]
+ [UnsupportedOSPlatform ("tvos")]
+#if __MACOS__
+ public static void RequestReview (NSViewController @in)
+#else
+ public static void RequestReview (UIWindowScene @in)
+#endif
+ {
+ XamarinSwiftFunctions.RequestReview (@in);
+ }
+ }
+}
+
+#endif // __IOS__ || __MACCATALYST__ || __MACOS__
diff --git a/src/bgen/Generator.cs b/src/bgen/Generator.cs
index 47cbefb4c0a6..0692efe5c98e 100644
--- a/src/bgen/Generator.cs
+++ b/src/bgen/Generator.cs
@@ -50,6 +50,7 @@
using System.Text;
using System.ComponentModel;
using System.Reflection;
+using ObjCBindings;
using ObjCRuntime;
using Foundation;
using Xamarin.Utils;
@@ -5630,6 +5631,13 @@ string GetAssemblyName ()
public void Generate (Type type)
{
+
+ // check if the type has been marked as a type that will be generated by the new code generator, if that
+ // is the case, bgen will ignore it allowing the rgen code generator add the type to the final assembly
+ bool is_rgen_type = AttributeManager.HasAttribute (type);
+ if (is_rgen_type)
+ return;
+
if (ZeroCopyStrings) {
ErrorHelper.Warning (1027);
ZeroCopyStrings = false;
diff --git a/src/bgen/bgen.csproj b/src/bgen/bgen.csproj
index 1444c86b365a..693c569025ba 100644
--- a/src/bgen/bgen.csproj
+++ b/src/bgen/bgen.csproj
@@ -9,6 +9,7 @@
$(DefineConstants);XAMMACIOS_DEBUGGER
Nullable
enable
+ APL0003
@@ -26,6 +27,9 @@
+
+ BindingTypeAttribute.cs
+
generator-errors.md
diff --git a/src/frameworks.sources b/src/frameworks.sources
index e129ca7cd91b..ec3f51ec8d61 100644
--- a/src/frameworks.sources
+++ b/src/frameworks.sources
@@ -296,6 +296,7 @@ AVFOUNDATION_SOURCES = \
AVFoundation/Events.cs \
AVFoundation/AVPlayerLooper.cs \
AVFoundation/AudioRendererWasFlushedAutomaticallyEventArgs.cs \
+ AVFoundation/AVCaptureReactionType.rgen.cs \
# AVKit
@@ -1760,6 +1761,7 @@ STOREKIT_SOURCES = \
StoreKit/SKCloudServiceSetupOptions.cs \
StoreKit/SKPayment.cs \
StoreKit/SKPaymentTransactionObserver.cs \
+ StoreKit/SwiftAPI.cs \
# SystemConfiguration
@@ -2012,6 +2014,7 @@ SHARED_CORE_SOURCES = \
DotNetGlobals.cs \
MinimumVersions.cs \
MonoPInvokeCallbackAttribute.cs \
+ ObjCBindings/BindingTypeAttribute.cs \
ObjCRuntime/ArgumentSemantic.cs \
ObjCRuntime/BindAsAttribute.cs \
ObjCRuntime/Blocks.cs \
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer.Sample/Examples.cs b/src/rgen/Microsoft.Macios.Bindings.Analyzer.Sample/Examples.cs
new file mode 100644
index 000000000000..fe4905a77980
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer.Sample/Examples.cs
@@ -0,0 +1,12 @@
+namespace Microsoft.Macios.Bindings.Analyzer.Sample;
+
+// If you don't see warnings, build the Analyzers Project.
+
+[BindingType]
+public class Examples {
+}
+
+[BindingType]
+public class Foo {
+
+}
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer.Sample/Microsoft.Macios.Bindings.Analyzer.Sample.csproj b/src/rgen/Microsoft.Macios.Bindings.Analyzer.Sample/Microsoft.Macios.Bindings.Analyzer.Sample.csproj
new file mode 100644
index 000000000000..bc9520bfbacf
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer.Sample/Microsoft.Macios.Bindings.Analyzer.Sample.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)
+ enable
+
+
+
+
+
+
+
+
+
+ external\Attributes.cs
+
+
+
+
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/AnalyzerReleases.Shipped.md b/src/rgen/Microsoft.Macios.Bindings.Analyzer/AnalyzerReleases.Shipped.md
new file mode 100644
index 000000000000..5a165075fbca
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/AnalyzerReleases.Shipped.md
@@ -0,0 +1,7 @@
+## Release 1.0
+
+### New Rules
+
+| Rule ID | Category | Severity | Notes |
+|---------|----------|----------|------------------------------------------------------|
+| RBI0001 | Usage | Error | Binding types should be declared as partial classes. |
\ No newline at end of file
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/AnalyzerReleases.Unshipped.md b/src/rgen/Microsoft.Macios.Bindings.Analyzer/AnalyzerReleases.Unshipped.md
new file mode 100644
index 000000000000..44f7c8f4ef7c
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/AnalyzerReleases.Unshipped.md
@@ -0,0 +1,4 @@
+### New Rules
+
+| Rule ID | Category | Severity | Notes |
+|---------|----------|----------|-------|
\ No newline at end of file
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/BindingTypeCodeFixProvider.cs b/src/rgen/Microsoft.Macios.Bindings.Analyzer/BindingTypeCodeFixProvider.cs
new file mode 100644
index 000000000000..17b8a2983607
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/BindingTypeCodeFixProvider.cs
@@ -0,0 +1,59 @@
+using System.Collections.Immutable;
+using System.Composition;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CodeActions;
+using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+
+using SyntaxFactory = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
+using SyntaxKind = Microsoft.CodeAnalysis.CSharp.SyntaxKind;
+
+namespace Microsoft.Macios.Bindings.Analyzer;
+
+///
+/// Code fix provider that adds the 'partial' modifier to the class decorated with BindingTypeAttribute.
+///
+[ExportCodeFixProvider (LanguageNames.CSharp, Name = nameof (BindingTypeCodeFixProvider)), Shared]
+public class BindingTypeCodeFixProvider : CodeFixProvider {
+ // Specify the diagnostic IDs of analyzers that are expected to be linked.
+ public sealed override ImmutableArray FixableDiagnosticIds { get; } =
+ ImmutableArray.Create (BindingTypeSemanticAnalyzer.DiagnosticId);
+
+ // If you don't need the 'fix all' behaviour, return null.
+ public override FixAllProvider? GetFixAllProvider () => null;
+
+ public sealed override async Task RegisterCodeFixesAsync (CodeFixContext context)
+ {
+ var diagnostic = context.Diagnostics.Single ();
+ var diagnosticSpan = diagnostic.Location.SourceSpan;
+ var root = await context.Document.GetSyntaxRootAsync (context.CancellationToken).ConfigureAwait (false);
+ var diagnosticNode = root?.FindNode (diagnosticSpan);
+
+ // To get the required metadata, we should match the Node to the specific type: 'ClassDeclarationSyntax'.
+ if (diagnosticNode is not ClassDeclarationSyntax declaration)
+ return;
+
+ // Register a code action that will invoke the fix.
+ context.RegisterCodeFix (
+ CodeAction.Create (
+ title: Resources.RBI0001CodeFixTitle,
+ createChangedDocument: c => MakePartialClassAsync (context.Document, declaration, c),
+ equivalenceKey: nameof (Resources.RBI0001CodeFixTitle)),
+ diagnostic);
+ }
+
+ async Task MakePartialClassAsync (Document document,
+ ClassDeclarationSyntax classDeclarationSyntax, CancellationToken cancellationToken)
+ {
+ var partialClass = classDeclarationSyntax.AddModifiers (SyntaxFactory.Token (SyntaxKind.PartialKeyword));
+ var oldRoot = await document.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false);
+ if (oldRoot is null)
+ return document;
+
+ var newRoot = oldRoot.ReplaceNode (classDeclarationSyntax, partialClass);
+ return document.WithSyntaxRoot (newRoot);
+ }
+}
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/BindingTypeSemanticAnalyzer.cs b/src/rgen/Microsoft.Macios.Bindings.Analyzer/BindingTypeSemanticAnalyzer.cs
new file mode 100644
index 000000000000..fd5df71a0e8b
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/BindingTypeSemanticAnalyzer.cs
@@ -0,0 +1,72 @@
+using System.Collections.Immutable;
+using System.Linq;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Diagnostics;
+
+namespace Microsoft.Macios.Bindings.Analyzer;
+
+///
+/// Analyzer that ensures that the types that have been declared as binding types are partial and follow the correct
+/// pattern.
+///
+[DiagnosticAnalyzer (LanguageNames.CSharp)]
+public class BindingTypeSemanticAnalyzer : DiagnosticAnalyzer {
+ internal const string DiagnosticId = "RBI0001";
+ static readonly LocalizableString Title = new LocalizableResourceString (nameof (Resources.RBI0001Title),
+ Resources.ResourceManager, typeof (Resources));
+ static readonly LocalizableString MessageFormat =
+ new LocalizableResourceString (nameof (Resources.RBI0001MessageFormat), Resources.ResourceManager,
+ typeof (Resources));
+ static readonly LocalizableString Description =
+ new LocalizableResourceString (nameof (Resources.RBI0001Description), Resources.ResourceManager,
+ typeof (Resources));
+ const string Category = "Usage";
+
+ static readonly DiagnosticDescriptor RBI0001 = new (DiagnosticId, Title, MessageFormat, Category,
+ DiagnosticSeverity.Error, isEnabledByDefault: true, description: Description);
+
+ public override ImmutableArray SupportedDiagnostics { get; } =
+ ImmutableArray.Create (RBI0001);
+
+ public override void Initialize (AnalysisContext context)
+ {
+ context.ConfigureGeneratedCodeAnalysis (GeneratedCodeAnalysisFlags.None);
+ context.EnableConcurrentExecution ();
+ context.RegisterSyntaxNodeAction (AnalysisContext, SyntaxKind.ClassDeclaration);
+ }
+
+ void AnalysisContext (SyntaxNodeAnalysisContext context)
+ {
+ // only care about classes
+ if (context.Node is not ClassDeclarationSyntax classDeclarationNode)
+ return;
+
+ var classSymbol = context.SemanticModel.GetDeclaredSymbol (classDeclarationNode);
+ if (classSymbol is null)
+ return;
+
+ var boundAttributes = classSymbol.GetAttributes ();
+ if (boundAttributes.Length == 0) {
+ return;
+ }
+
+ // the c# syntax is a a list of lists of attributes. That is why we need to iterate through the list of lists
+ foreach (var attributeData in boundAttributes) {
+ // based on the type use the correct parser to retrieve the data
+ var attributeType = attributeData.AttributeClass?.ToDisplayString ();
+ switch (attributeType) {
+ case "ObjCBindings.BindingTypeAttribute":
+ // validate that the class is partial, else we need to report an error
+ if (!classDeclarationNode.Modifiers.Any (x => x.IsKind (SyntaxKind.PartialKeyword))) {
+ var diagnostic = Diagnostic.Create (RBI0001,
+ classDeclarationNode.Identifier.GetLocation (), // point to where the 'class' keyword is used
+ classSymbol.ToDisplayString ());
+ context.ReportDiagnostic (diagnostic);
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/Microsoft.Macios.Bindings.Analyzer.csproj b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Microsoft.Macios.Bindings.Analyzer.csproj
new file mode 100644
index 000000000000..6f9e0902e438
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Microsoft.Macios.Bindings.Analyzer.csproj
@@ -0,0 +1,46 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)
+ false
+ enable
+ latest
+
+ true
+ true
+
+ Microsoft.Macios.Bindings.Analyzer
+ Microsoft.Macios.Bindings.Analyzer
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+ <_Parameter1>Microsoft.Macios.Bindings.Analyzer.Tests
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/Properties/launchSettings.json b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Properties/launchSettings.json
new file mode 100644
index 000000000000..874ffd77b7e5
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Properties/launchSettings.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "profiles": {
+ "DebugRoslynAnalyzers": {
+ "commandName": "DebugRoslynComponent",
+ "targetProject": "../Microsoft.Macios.Bindings.Analyzer.Sample/Microsoft.Macios.Bindings.Analyzer.Sample.csproj"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/Readme.md b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Readme.md
new file mode 100644
index 000000000000..d3a566c3c1cd
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Readme.md
@@ -0,0 +1,26 @@
+# Roslyn Analyzers Sample
+
+Roslyn analyzer to be installed along side the Roslyn Conde generator that will help developers work on Microsoft.Macios bindings.
+
+## Content
+### Microsoft.Macios.Bindings.Analyzer
+
+A .NET Standard project with implementations of sample analyzers and code fix providers.
+**You must build this project to see the results (warnings) in the IDE.**
+
+### Microsoft.Macios.Bindings.Analyzer.Sample
+A project that references the sample analyzers. Note the parameters of `ProjectReference` in [Microsoft.Macios.Bindings.Analyzer.Sample.csproj](../Microsoft.Macios.Bindings.Analyzer.Sample/Microsoft.Macios.Bindings.Analyzer.Sample.csproj), they make sure that the project is referenced as a set of analyzers.
+
+### Microsoft.Macios.Bindings.Analyzer.Tests
+Unit tests for the sample analyzers and code fix provider. The easiest way to develop language-related features is to start with unit tests.
+
+## How To?
+### How to debug?
+- Use the [launchSettings.json](Properties/launchSettings.json) profile.
+- Debug tests (in VSCode).
+
+### How can I determine which syntax nodes I should expect?
+Consider installing the Roslyn syntax tree viewer plugin [Rossynt](https://plugins.jetbrains.com/plugin/16902-rossynt/).
+
+### Learn more about wiring analyzers
+The complete set of information is available at [roslyn github repo wiki](https://github.com/dotnet/roslyn/blob/main/docs/wiki/README.md).
\ No newline at end of file
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.Designer.cs b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.Designer.cs
new file mode 100644
index 000000000000..bfe0d3152b0f
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.Designer.cs
@@ -0,0 +1,96 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Microsoft.Macios.Bindings.Analyzer {
+ using System;
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static System.Resources.ResourceManager resourceMan;
+
+ private static System.Globalization.CultureInfo resourceCulture;
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.Equals(null, resourceMan)) {
+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Microsoft.Macios.Bindings.Analyzer.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ internal static string AB0001Description {
+ get {
+ return ResourceManager.GetString("AB0001Description", resourceCulture);
+ }
+ }
+
+ internal static string AB0001MessageFormat {
+ get {
+ return ResourceManager.GetString("AB0001MessageFormat", resourceCulture);
+ }
+ }
+
+ internal static string AB0001Title {
+ get {
+ return ResourceManager.GetString("AB0001Title", resourceCulture);
+ }
+ }
+
+ internal static string RBI0001CodeFixTitle {
+ get {
+ return ResourceManager.GetString("RBI0001CodeFixTitle", resourceCulture);
+ }
+ }
+
+ internal static string RBI0001Description {
+ get {
+ return ResourceManager.GetString("RBI0001Description", resourceCulture);
+ }
+ }
+
+ internal static string RBI0001MessageFormat {
+ get {
+ return ResourceManager.GetString("RBI0001MessageFormat", resourceCulture);
+ }
+ }
+
+ internal static string RBI0001Title {
+ get {
+ return ResourceManager.GetString("RBI0001Title", resourceCulture);
+ }
+ }
+
+ internal static string AB0002Description {
+ get {
+ return ResourceManager.GetString("AB0002Description", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.resx b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.resx
new file mode 100644
index 000000000000..2f228a310c3f
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.resx
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Make Binding Type class partial
+ The title of the code fix.
+
+
+ In order for the code to be generated all binding types have to be declared as partial classes.
+ An optional longer localizable description of the diagnostic.
+
+
+ The binding type '{0}' must declared as a partial class
+ The format-able message the diagnostic displays.
+
+
+ Binding type declaration must be partial
+ The title of the diagnostic.
+
+
diff --git a/src/rgen/Microsoft.Macios.Generator.Sample/Microsoft.Macios.Generator.Sample.csproj b/src/rgen/Microsoft.Macios.Generator.Sample/Microsoft.Macios.Generator.Sample.csproj
new file mode 100644
index 000000000000..f21144e77c4c
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Generator.Sample/Microsoft.Macios.Generator.Sample.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)
+ enable
+ Microsoft.Macios.Generator.Sample
+
+
+
+
+
+
+
+
+ external\Attributes.cs
+
+
+
+
diff --git a/src/rgen/Microsoft.Macios.Generator.Sample/SampleBinding.cs b/src/rgen/Microsoft.Macios.Generator.Sample/SampleBinding.cs
new file mode 100644
index 000000000000..28d28329ae21
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Generator.Sample/SampleBinding.cs
@@ -0,0 +1,9 @@
+namespace Microsoft.Macios.Generator.Sample;
+
+// This code will not compile until you build the project with the Source Generators
+
+[BindingType]
+public partial class SampleBinding {
+ public int Id { get; } = 42;
+ public string? Name { get; } = "Sample";
+}
diff --git a/src/rgen/Microsoft.Macios.Generator/BindingSourceGeneratorGenerator.cs b/src/rgen/Microsoft.Macios.Generator/BindingSourceGeneratorGenerator.cs
new file mode 100644
index 000000000000..fcc630f160ce
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Generator/BindingSourceGeneratorGenerator.cs
@@ -0,0 +1,24 @@
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace Microsoft.Macios.Generator;
+
+///
+/// A sample source generator that creates a custom report based on class properties. The target class should be annotated with the 'Generators.ReportAttribute' attribute.
+/// When using the source code as a baseline, an incremental source generator is preferable because it reduces the performance overhead.
+///
+[Generator]
+public class BindingSourceGeneratorGenerator : IIncrementalGenerator {
+
+ public void Initialize (IncrementalGeneratorInitializationContext context)
+ {
+ // Add the binding generator attributes to the compilation. This are only available when the
+ // generator is used, similar to how bgen works.
+ foreach ((string fileName, string content) in ExtraSources.Sources) {
+ context.RegisterPostInitializationOutput (ctx => ctx.AddSource (
+ fileName, SourceText.From (content, Encoding.UTF8)));
+ }
+ }
+
+}
diff --git a/src/rgen/Microsoft.Macios.Generator/ExtraSources.cs b/src/rgen/Microsoft.Macios.Generator/ExtraSources.cs
new file mode 100644
index 000000000000..916949db8768
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Generator/ExtraSources.cs
@@ -0,0 +1,5 @@
+namespace Microsoft.Macios.Generator;
+
+public static class ExtraSources {
+ public static readonly (string FileName, string Content) [] Sources = new (string, string) [0];
+}
diff --git a/src/rgen/Microsoft.Macios.Generator/Microsoft.Macios.Generator.csproj b/src/rgen/Microsoft.Macios.Generator/Microsoft.Macios.Generator.csproj
new file mode 100644
index 000000000000..f9c73ed0396a
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Generator/Microsoft.Macios.Generator.csproj
@@ -0,0 +1,26 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)
+ false
+ enable
+ latest
+
+ true
+ true
+
+ Microsoft.Macios.Generator
+ Microsoft.Macios.Generator
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
diff --git a/src/rgen/Microsoft.Macios.Generator/Properties/launchSettings.json b/src/rgen/Microsoft.Macios.Generator/Properties/launchSettings.json
new file mode 100644
index 000000000000..5687e6130138
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Generator/Properties/launchSettings.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "profiles": {
+ "DebugRoslynSourceGenerator": {
+ "commandName": "DebugRoslynComponent",
+ "targetProject": "../Microsoft.Macios.Generator.Sample/Microsoft.Macios.Generator.Sample.csproj"
+ }
+ }
+}
diff --git a/src/rgen/Microsoft.Macios.Generator/Readme.md b/src/rgen/Microsoft.Macios.Generator/Readme.md
new file mode 100644
index 000000000000..8151de594361
--- /dev/null
+++ b/src/rgen/Microsoft.Macios.Generator/Readme.md
@@ -0,0 +1,21 @@
+# Roslyn binding code generator
+
+This directory contains the code generator for binding code. The generator is the implementation of [RFC: Migrate bgen to use roslyn instead of the reflection API](https://github.com/xamarin/xamarin-macios/issues/21308)
+
+## Content
+
+### Microsoft.Macios.Generator
+A .NET Standard project with implementations of sample source generators.
+
+**You must build this project to see the result (generated code) in the IDE.**
+
+### Microsoft.Macios.Generator.Sample
+A project that references source generators. Note the parameters of `ProjectReference` in [Microsoft.Macios.Generator.Sample.csproj](../Microsoft.Macios.Generator.Sample/Microsoft.Macios.Generator.Sample.csproj), they make sure that the project is referenced as a set of source generators.
+
+### Microsoft.Macios.Generator.Tests
+Unit tests for source generators. The easiest way to develop language-related features is to start with unit tests.
+
+## How To?
+### How to debug?
+- Use the [launchSettings.json](Properties/launchSettings.json) profile.
+- Debug tests.
\ No newline at end of file
diff --git a/src/rgen/rgen.sln b/src/rgen/rgen.sln
new file mode 100644
index 000000000000..684992039540
--- /dev/null
+++ b/src/rgen/rgen.sln
@@ -0,0 +1,46 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Macios.Generator", "Microsoft.Macios.Generator\Microsoft.Macios.Generator.csproj", "{8E9CF45D-E836-447E-9290-03A9CACE2704}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Macios.Generator.Sample", "Microsoft.Macios.Generator.Sample\Microsoft.Macios.Generator.Sample.csproj", "{AD0A1FDC-350F-47E2-AA9D-A6F32793C130}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Macios.Bindings.Analyzer", "Microsoft.Macios.Bindings.Analyzer\Microsoft.Macios.Bindings.Analyzer.csproj", "{27A7CBB0-A30D-4A08-A475-6D2DFD94C634}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Macios.Bindings.Analyzer.Sample", "Microsoft.Macios.Bindings.Analyzer.Sample\Microsoft.Macios.Bindings.Analyzer.Sample.csproj", "{65649B5A-9C23-4AA8-A687-82319EF4FA7E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Macios.Generator.Tests", "..\..\tests\rgen\Microsoft.Macios.Generator.Tests\Microsoft.Macios.Generator.Tests.csproj", "{CD222ACD-A54F-49D9-81CA-6D795CC31195}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Macios.Bindings.Analyzer.Tests", "..\..\tests\rgen\Microsoft.Macios.Bindings.Analyzer.Tests\Microsoft.Macios.Bindings.Analyzer.Tests.csproj", "{1AC4A248-CC98-4392-8690-4E2CAF6E194B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8E9CF45D-E836-447E-9290-03A9CACE2704}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E9CF45D-E836-447E-9290-03A9CACE2704}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E9CF45D-E836-447E-9290-03A9CACE2704}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E9CF45D-E836-447E-9290-03A9CACE2704}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AD0A1FDC-350F-47E2-AA9D-A6F32793C130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AD0A1FDC-350F-47E2-AA9D-A6F32793C130}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AD0A1FDC-350F-47E2-AA9D-A6F32793C130}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AD0A1FDC-350F-47E2-AA9D-A6F32793C130}.Release|Any CPU.Build.0 = Release|Any CPU
+ {27A7CBB0-A30D-4A08-A475-6D2DFD94C634}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {27A7CBB0-A30D-4A08-A475-6D2DFD94C634}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {27A7CBB0-A30D-4A08-A475-6D2DFD94C634}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {27A7CBB0-A30D-4A08-A475-6D2DFD94C634}.Release|Any CPU.Build.0 = Release|Any CPU
+ {65649B5A-9C23-4AA8-A687-82319EF4FA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {65649B5A-9C23-4AA8-A687-82319EF4FA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {65649B5A-9C23-4AA8-A687-82319EF4FA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {65649B5A-9C23-4AA8-A687-82319EF4FA7E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CD222ACD-A54F-49D9-81CA-6D795CC31195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CD222ACD-A54F-49D9-81CA-6D795CC31195}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CD222ACD-A54F-49D9-81CA-6D795CC31195}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CD222ACD-A54F-49D9-81CA-6D795CC31195}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1AC4A248-CC98-4392-8690-4E2CAF6E194B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1AC4A248-CC98-4392-8690-4E2CAF6E194B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1AC4A248-CC98-4392-8690-4E2CAF6E194B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1AC4A248-CC98-4392-8690-4E2CAF6E194B}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/src/storekit.cs b/src/storekit.cs
index cb1bfa1cb909..bd0308d34a44 100644
--- a/src/storekit.cs
+++ b/src/storekit.cs
@@ -9,6 +9,9 @@
// Copyright 2012 Xamarin Inc.
// Copyright 2020 Microsoft Corp.
//
+
+using System.ComponentModel;
+
using ObjCRuntime;
using Foundation;
using CoreFoundation;
@@ -34,6 +37,21 @@
namespace StoreKit {
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Internal]
+ [BaseType (typeof (NSObject))]
+ [DisableDefaultCtor]
+ interface XamarinSwiftFunctions {
+ [Export ("requestReview:")]
+ [Static]
+ [iOS (16, 0), MacCatalyst (16, 0), Mac (13, 0), NoTV]
+#if MONOMAC
+ void RequestReview (NSViewController viewController);
+#else
+ void RequestReview (UIWindowScene windowScene);
+#endif
+ }
+
[ErrorDomain ("SKANErrorDomain")]
[NoWatch, NoTV, NoMac, iOS (15, 4), MacCatalyst (17, 0)]
[Native]
@@ -1112,6 +1130,9 @@ interface SKStoreReviewController {
[Export ("requestReview")]
void RequestReview ();
+ [Deprecated (PlatformName.iOS, 18, 0, message: "Use the 'AppStore.RequestReview (UIWindowScene)' API instead.")]
+ [Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use the 'AppStore.RequestReview (UIWindowScene)' API instead.")]
+ [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use the 'AppStore.RequestReview (NSViewController)' API instead.")]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[NoWatch, NoTV, iOS (14, 0), NoMac]
[Static]
diff --git a/tests/Makefile b/tests/Makefile
index f13e4860ebe9..6b57f8b34d4f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -189,11 +189,9 @@ logdev:
build-test-libraries:
@$(MAKE) -C $(TOP)/tests/test-libraries
-.stamp-xharness-configure: $(XHARNESS_EXECUTABLE)
- $(Q_GEN) $(DOTNET) $< $(XHARNESS_VERBOSITY) --configure --autoconf --rootdir $(CURDIR)
- $(Q) touch $@
+xharness: $(XHARNESS_EXECUTABLE)
-all-local:: .stamp-xharness-configure
+all-local:: xharness
$(TOP)/tools/common/SdkVersions.cs: $(TOP)/tools/common/SdkVersions.in.cs
@$(MAKE) -C $(TOP)/tools/mtouch ../common/SdkVersions.cs
@@ -240,14 +238,6 @@ else
@echo Not enabled
endif
-ifdef INCLUDE_DOTNET
-dotnet-test-package.7z:
- ./package-dotnet-tests.sh
-else
-dotnet-test-package.7z:
- @echo Not enabled
-endif
-
#XI
ifdef INCLUDE_IOS
wrench-mtouch:
@@ -356,13 +346,5 @@ package-test-libraries.zip:
$(Q) $(MAKE) all -C test-libraries/custom-type-assembly build-assembly
$(Q_GEN) rm -f "$@" "$@.tmp"
$(Q_GEN) cd $(TOP) && zip -9r --symlinks $(abspath $@).tmp ./tests/test-libraries
- $(Q_GEN) cd $(TOP) && find tests -regex '.*/generated-projects/.*[c|f]sproj' -exec zip -9r --symlinks $(abspath $@).tmp {} +
- $(Q_GEN) cd $(TOP) && find tests -regex '.*/generated-projects/.*sln' -exec zip -9r --symlinks $(abspath $@).tmp {} +
$(Q_GEN) cd $(TOP) && find tests -regex 'tests/test-libraries/custom-type-assembly/.libs/.*dll' -exec zip -9r --symlinks $(abspath $@).tmp {} +
- $(Q_GEN) cd $(TOP) && git ls-files -o -- 'tests/*/Info-*plist' | zip -9r --symlinks $(abspath $@).tmp -@
-ifdef INCLUDE_XAMARIN_LEGACY
-ifdef INCLUDE_IOS
- $(Q_GEN) cd $(TOP) && zip -9r --symlinks $(abspath $@).tmp ./tools/mtouch/simlauncher*-sgen*
-endif
-endif
$(Q) mv "$@".tmp "$@"
diff --git a/tests/bgen/bgen-tests.csproj b/tests/bgen/bgen-tests.csproj
index 6ee37f30a0a8..cef7c5856f16 100644
--- a/tests/bgen/bgen-tests.csproj
+++ b/tests/bgen/bgen-tests.csproj
@@ -48,6 +48,9 @@
Configuration.cs
+
+ ConfigurationNUnit.cs
+
ExecutionHelper.cs
diff --git a/tests/cecil-tests/AttributeTest.cs b/tests/cecil-tests/AttributeTest.cs
index 38c197e05cd6..220bdf8a6768 100644
--- a/tests/cecil-tests/AttributeTest.cs
+++ b/tests/cecil-tests/AttributeTest.cs
@@ -181,6 +181,9 @@ public void FindSupportedOnElementsThatDoNotExistInThatAssembly ()
// Walk every class/struct/enum/property/method/enum value/pinvoke/event
foreach (var module in assembly.Modules) {
foreach (var type in module.Types) {
+ if (!type.IsPubliclyVisible ())
+ continue;
+
switch (type.Namespace) {
case "AppKit":
case "UIKit":
@@ -289,10 +292,6 @@ static HashSet IgnoreElementsThatDoNotExistInThatAssembly {
// These methods have different optional/required semantics between platforms.
"PassKit.PKPaymentAuthorizationControllerDelegate_Extensions.GetPresentationWindow (PassKit.IPKPaymentAuthorizationControllerDelegate, PassKit.PKPaymentAuthorizationController)",
- "Metal.MTLTextureWrapper.FirstMipmapInTail",
- "Metal.MTLTextureWrapper.IsSparse",
- "Metal.MTLTextureWrapper.TailSizeInBytes",
-
// HKSeriesBuilder doesn't implement the ISNCopying protocol on all platforms (and shouldn't on any according to the headers, so removed for XAMCORE_5_0).
"HealthKit.HKSeriesBuilder.EncodeTo (Foundation.NSCoder)",
@@ -325,6 +324,10 @@ static HashSet IgnoreElementsThatDoNotExistInThatAssembly {
"Foundation.NSAttributedString.ReadableTypeIdentifiers",
"Foundation.NSAttributedString.WritableTypeIdentifiers",
"Foundation.NSAttributedString.WritableTypeIdentifiersForItemProvider",
+
+ // Same method, but different arguments due to platform differences. We should treat this as the same method, so ignore this failure.
+ "StoreKit.AppStore.RequestReview (XKit.XWindowScene)", // iOS, MacCatalyst
+ "StoreKit.AppStore.RequestReview (XKit.XViewController)", // macOS
};
}
}
diff --git a/tests/cecil-tests/Documentation.KnownFailures.txt b/tests/cecil-tests/Documentation.KnownFailures.txt
index 41a7ee58be76..8fcf9b1d7d30 100644
--- a/tests/cecil-tests/Documentation.KnownFailures.txt
+++ b/tests/cecil-tests/Documentation.KnownFailures.txt
@@ -5311,6 +5311,14 @@ F:AVFoundation.AVCapturePrimaryConstituentDeviceSwitchingBehavior.Auto
F:AVFoundation.AVCapturePrimaryConstituentDeviceSwitchingBehavior.Locked
F:AVFoundation.AVCapturePrimaryConstituentDeviceSwitchingBehavior.Restricted
F:AVFoundation.AVCapturePrimaryConstituentDeviceSwitchingBehavior.Unsupported
+F:AVFoundation.AVCaptureReactionType.Balloons
+F:AVFoundation.AVCaptureReactionType.Confetti
+F:AVFoundation.AVCaptureReactionType.Fireworks
+F:AVFoundation.AVCaptureReactionType.Heart
+F:AVFoundation.AVCaptureReactionType.Lasers
+F:AVFoundation.AVCaptureReactionType.Rain
+F:AVFoundation.AVCaptureReactionType.ThumbsDown
+F:AVFoundation.AVCaptureReactionType.ThumbsUp
F:AVFoundation.AVCaptureSessionInterruptionReason.AudioDeviceInUseByAnotherClient
F:AVFoundation.AVCaptureSessionInterruptionReason.VideoDeviceInUseByAnotherClient
F:AVFoundation.AVCaptureSessionInterruptionReason.VideoDeviceNotAvailableDueToSystemPressure
@@ -44900,6 +44908,7 @@ M:NotificationCenter.NSExtensionContext_NCWidgetAdditions.GetWidgetMaximumSize(F
M:NotificationCenter.NSExtensionContext_NCWidgetAdditions.SetWidgetLargestAvailableDisplayMode(Foundation.NSExtensionContext,NotificationCenter.NCWidgetDisplayMode)
M:NotificationCenter.NSWidgetSearchForTermEventArgs.#ctor(System.String,System.UIntPtr)
M:NotificationCenter.NSWidgetSearchResultSelectedEventArgs.#ctor(Foundation.NSObject)
+M:ObjCBindings.BindingTypeAttribute.#ctor
M:ObjCRuntime.AdoptsAttribute.#ctor(System.String)
M:ObjCRuntime.AssemblyRegistrationEventArgs.#ctor
M:ObjCRuntime.BaseWrapper.#ctor(ObjCRuntime.NativeHandle,System.Boolean)
@@ -81590,6 +81599,7 @@ T:AVFoundation.AVCapturePhotoQualityPrioritization
T:AVFoundation.AVCapturePhotoSettingsThumbnailFormat
T:AVFoundation.AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions
T:AVFoundation.AVCapturePrimaryConstituentDeviceSwitchingBehavior
+T:AVFoundation.AVCaptureReactionType
T:AVFoundation.AVCaptureSessionInterruptionReason
T:AVFoundation.AVCaptureSessionRuntimeErrorEventArgs
T:AVFoundation.AVCaptureSystemPressureFactors
diff --git a/tests/cecil-tests/Helper.cs b/tests/cecil-tests/Helper.cs
index e5d32d0ed35a..67b01aaaecf4 100644
--- a/tests/cecil-tests/Helper.cs
+++ b/tests/cecil-tests/Helper.cs
@@ -449,11 +449,6 @@ static IEnumerable PlatformAssemblies {
yield return Path.Combine (Configuration.MonoTouchRootDirectory, "lib", "64bits", "iOS", "Xamarin.iOS.dll");
}
- if (Configuration.include_watchos) {
- // XamarinWatchOSDll is stripped of its IL
- yield return Path.Combine (Configuration.MonoTouchRootDirectory, "lib", "32bits", "watchOS", "Xamarin.WatchOS.dll");
- }
-
if (Configuration.include_tvos) {
// XamarinTVOSDll is stripped of it's IL
yield return Path.Combine (Configuration.MonoTouchRootDirectory, "lib", "64bits", "tvOS", "Xamarin.TVOS.dll");
diff --git a/tests/cecil-tests/cecil-tests.csproj b/tests/cecil-tests/cecil-tests.csproj
index 50d9f62c8f53..eac1c64fe7d1 100644
--- a/tests/cecil-tests/cecil-tests.csproj
+++ b/tests/cecil-tests/cecil-tests.csproj
@@ -19,6 +19,9 @@
Configuration.cs
+
+ ConfigurationNUnit.cs
+
Profile.cs
diff --git a/tests/common/Configuration.cs b/tests/common/Configuration.cs
index 5fdbd955485d..741c1c2fd21d 100644
--- a/tests/common/Configuration.cs
+++ b/tests/common/Configuration.cs
@@ -7,8 +7,6 @@
using System.Text;
using System.Threading;
-using NUnit.Framework;
-
using Xamarin.Utils;
#nullable disable // until we get around to fixing this file
@@ -42,8 +40,6 @@ static partial class Configuration {
public static bool include_ios;
public static bool include_mac;
public static bool include_tvos;
- public static bool include_watchos;
- public static bool include_dotnet_watchos;
public static bool include_maccatalyst;
public static bool include_device;
public static bool include_dotnet;
@@ -299,8 +295,6 @@ static Configuration ()
include_ios = !string.IsNullOrEmpty (GetVariable ("INCLUDE_IOS", ""));
include_mac = !string.IsNullOrEmpty (GetVariable ("INCLUDE_MAC", ""));
include_tvos = !string.IsNullOrEmpty (GetVariable ("INCLUDE_TVOS", ""));
- include_watchos = !string.IsNullOrEmpty (GetVariable ("INCLUDE_WATCH", ""));
- include_dotnet_watchos = !string.IsNullOrEmpty (GetVariable ("INCLUDE_DOTNET_WATCH", ""));
include_maccatalyst = !string.IsNullOrEmpty (GetVariable ("INCLUDE_MACCATALYST", ""));
include_device = !string.IsNullOrEmpty (GetVariable ("INCLUDE_DEVICE", ""));
include_dotnet = !string.IsNullOrEmpty (GetVariable ("ENABLE_DOTNET", ""));
@@ -333,7 +327,6 @@ static Configuration ()
Console.WriteLine (" INCLUDE_IOS={0}", include_ios);
Console.WriteLine (" INCLUDE_MAC={0}", include_mac);
Console.WriteLine (" INCLUDE_TVOS={0}", include_tvos);
- Console.WriteLine (" INCLUDE_WATCHOS={0}", include_watchos);
Console.WriteLine (" INCLUDE_MACCATALYST={0}", include_maccatalyst);
Console.WriteLine (" ENABLE_DOTNET={0}", include_dotnet);
}
@@ -384,12 +377,6 @@ public static bool TryGetRootPath (out string rootPath)
}
}
- static string TestAssemblyDirectory {
- get {
- return TestContext.CurrentContext.WorkDirectory;
- }
- }
-
public static string SourceRoot {
get {
if (mt_src_root is null)
@@ -682,25 +669,6 @@ public static string MlaunchPath {
}
#if !XAMMAC_TESTS
- public static void AssertRuntimeIdentifierAvailable (ApplePlatform platform, string runtimeIdentifier)
- {
- if (string.IsNullOrEmpty (runtimeIdentifier))
- return;
-
- if (GetRuntimeIdentifiers (platform).Contains (runtimeIdentifier))
- return;
-
- Assert.Ignore ($"The runtime identifier {runtimeIdentifier} is not available on {platform}");
- }
-
- public static void AssertRuntimeIdentifiersAvailable (ApplePlatform platform, string runtimeIdentifiers)
- {
- if (string.IsNullOrEmpty (runtimeIdentifiers))
- return;
-
- foreach (var rid in runtimeIdentifiers.Split (new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries))
- AssertRuntimeIdentifierAvailable (platform, rid);
- }
public static string GetBaseLibrary (Profile profile)
{
@@ -913,12 +881,6 @@ public static string GetCompiler (Profile profile, IList args)
return "/Library/Frameworks/Mono.framework/Commands/csc";
}
- public static void AssertiOS32BitAvailable ()
- {
- if (iOSSupports32BitArchitectures)
- return;
- Assert.Ignore ($"32-bit iOS support is not available in the current build.");
- }
#endif // !XAMMAC_TESTS
public static IEnumerable GetIncludedPlatforms (bool dotnet)
@@ -934,8 +896,6 @@ public static IEnumerable GetIncludedPlatforms (bool dotnet)
yield return ApplePlatform.MacOSX;
if (include_maccatalyst)
yield return ApplePlatform.MacCatalyst;
- if (include_watchos && !dotnet)
- yield return ApplePlatform.WatchOS;
}
public static IEnumerable GetAllPlatforms (bool dotnet)
@@ -959,27 +919,6 @@ public static string XIBuildPath {
get { return Path.GetFullPath (Path.Combine (RootPath, "tools", "xibuild", "xibuild")); }
}
- public static void AssertDeviceAvailable ()
- {
- if (include_device)
- return;
- Assert.Ignore ("This build does not include device support.");
- }
-
- public static void AssertDotNetAvailable ()
- {
- if (include_dotnet)
- return;
- Assert.Ignore (".NET tests not enabled");
- }
-
- public static void AssertLegacyXamarinAvailable ()
- {
- if (include_legacy_xamarin)
- return;
- Assert.Ignore ("Legacy xamarin build not enabled");
- }
-
public static string CloneTestDirectory (string directory)
{
// Copy the test projects to a temporary directory so that we can run the tests from there without affecting the working directory.
@@ -1072,102 +1011,6 @@ public static void SetBuildVariables (ApplePlatform platform, ref Dictionary notIncluded)
- {
- var allPlatforms = GetAllPlatforms (dotnet);
- var includedPlatforms = GetIncludedPlatforms (dotnet);
- notIncluded = allPlatforms.Where (v => !includedPlatforms.Contains (v)).ToArray ();
- return notIncluded.Any ();
- }
-
- public static void IgnoreIfAnyIgnoredPlatforms (bool dotnet = true)
- {
- if (AnyIgnoredPlatforms (dotnet, out var notIncluded))
- Assert.Ignore ($"This test requires all platforms to be included, but the following platforms aren't included: {string.Join (", ", notIncluded.Select (v => v.AsString ()))}");
- }
-
- public static void IgnoreIfNotOnMacOS ()
- {
- IgnoreIfNotOn (System.Runtime.InteropServices.OSPlatform.OSX);
- }
-
- public static void IgnoreIfNotOnWindows ()
- {
- IgnoreIfNotOn (System.Runtime.InteropServices.OSPlatform.Windows);
- }
-
- public static void IgnoreIfNotOn (System.Runtime.InteropServices.OSPlatform platform)
- {
- if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform (platform))
- return;
- Assert.Ignore ($"This test is only applicable on {platform}");
- }
-
- public static void IgnoreIfNotXamarinEnabled ()
- {
- if (EnableXamarin)
- return;
- Assert.Ignore ($"This test is only applicable if Xamarin-specific bits are enabled.");
- }
-
public static string GetTestLibraryDirectory (ApplePlatform platform, bool? simulator = null)
{
string dir;
@@ -1278,3 +1121,4 @@ public static IEnumerable GetUndefinedNativeSymbols (string file, string
}
}
}
+
diff --git a/tests/common/ConfigurationNUnit.cs b/tests/common/ConfigurationNUnit.cs
new file mode 100644
index 000000000000..885d91cf844b
--- /dev/null
+++ b/tests/common/ConfigurationNUnit.cs
@@ -0,0 +1,163 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+
+using NUnit.Framework;
+
+using Xamarin.Utils;
+
+#nullable disable // until we get around to fixing this file
+
+namespace Xamarin.Tests {
+ static partial class Configuration {
+
+ static string TestAssemblyDirectory {
+ get {
+ return TestContext.CurrentContext.WorkDirectory;
+ }
+ }
+
+#if !XAMMAC_TESTS
+ public static void AssertRuntimeIdentifierAvailable (ApplePlatform platform, string runtimeIdentifier)
+ {
+ if (string.IsNullOrEmpty (runtimeIdentifier))
+ return;
+
+ if (GetRuntimeIdentifiers (platform).Contains (runtimeIdentifier))
+ return;
+
+ Assert.Ignore ($"The runtime identifier {runtimeIdentifier} is not available on {platform}");
+ }
+
+ public static void AssertRuntimeIdentifiersAvailable (ApplePlatform platform, string runtimeIdentifiers)
+ {
+ if (string.IsNullOrEmpty (runtimeIdentifiers))
+ return;
+
+ foreach (var rid in runtimeIdentifiers.Split (new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries))
+ AssertRuntimeIdentifierAvailable (platform, rid);
+ }
+
+ public static void AssertiOS32BitAvailable ()
+ {
+ if (iOSSupports32BitArchitectures)
+ return;
+ Assert.Ignore ($"32-bit iOS support is not available in the current build.");
+ }
+#endif // !XAMMAC_TESTS
+
+ public static void AssertDeviceAvailable ()
+ {
+ if (include_device)
+ return;
+ Assert.Ignore ("This build does not include device support.");
+ }
+
+ public static void AssertDotNetAvailable ()
+ {
+ if (include_dotnet)
+ return;
+ Assert.Ignore (".NET tests not enabled");
+ }
+
+ public static void AssertLegacyXamarinAvailable ()
+ {
+ if (include_legacy_xamarin)
+ return;
+ Assert.Ignore ("Legacy xamarin build not enabled");
+ }
+
+ // Calls Assert.Ignore if the given platform isn't included in the current build.
+ public static void IgnoreIfIgnoredPlatform (ApplePlatform platform)
+ {
+ switch (platform) {
+ case ApplePlatform.iOS:
+ if (!include_ios)
+ Assert.Ignore ("iOS is not included in this build");
+ break;
+ case ApplePlatform.TVOS:
+ if (!include_tvos)
+ Assert.Ignore ("tvOS is not included in this build");
+ break;
+ case ApplePlatform.MacOSX:
+ if (!include_mac)
+ Assert.Ignore ("macOS is not included in this build");
+ break;
+ case ApplePlatform.MacCatalyst:
+ if (!include_maccatalyst)
+ Assert.Ignore ("Mac Catalyst is not included in this build");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ($"Unknown platform: {platform}");
+ }
+ }
+
+ // Calls Assert.Ignore if the given platform isn't included in the current build.
+ public static void IgnoreIfIgnoredPlatform (string platform)
+ {
+ switch (platform.ToLower ()) {
+ case "ios":
+ case "tvos":
+ case "watchos":
+ case "macosx":
+ case "maccatalyst":
+ IgnoreIfIgnoredPlatform ((ApplePlatform) Enum.Parse (typeof (ApplePlatform), platform, true));
+ break;
+ case "macos":
+ IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ($"Unknown platform: {platform}");
+ }
+ }
+
+ public static bool AnyIgnoredPlatforms (bool dotnet = true)
+ {
+ return AnyIgnoredPlatforms (dotnet, out var _);
+ }
+
+ public static bool AnyIgnoredPlatforms (bool dotnet, out IEnumerable notIncluded)
+ {
+ var allPlatforms = GetAllPlatforms (dotnet);
+ var includedPlatforms = GetIncludedPlatforms (dotnet);
+ notIncluded = allPlatforms.Where (v => !includedPlatforms.Contains (v)).ToArray ();
+ return notIncluded.Any ();
+ }
+
+ public static void IgnoreIfAnyIgnoredPlatforms (bool dotnet = true)
+ {
+ if (AnyIgnoredPlatforms (dotnet, out var notIncluded))
+ Assert.Ignore ($"This test requires all platforms to be included, but the following platforms aren't included: {string.Join (", ", notIncluded.Select (v => v.AsString ()))}");
+ }
+
+ public static void IgnoreIfNotOnMacOS ()
+ {
+ IgnoreIfNotOn (System.Runtime.InteropServices.OSPlatform.OSX);
+ }
+
+ public static void IgnoreIfNotOnWindows ()
+ {
+ IgnoreIfNotOn (System.Runtime.InteropServices.OSPlatform.Windows);
+ }
+
+ public static void IgnoreIfNotOn (System.Runtime.InteropServices.OSPlatform platform)
+ {
+ if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform (platform))
+ return;
+ Assert.Ignore ($"This test is only applicable on {platform}");
+ }
+
+ public static void IgnoreIfNotXamarinEnabled ()
+ {
+ if (EnableXamarin)
+ return;
+ Assert.Ignore ($"This test is only applicable if Xamarin-specific bits are enabled.");
+ }
+
+ }
+}
diff --git a/tests/common/ConfigurationXUnit.cs b/tests/common/ConfigurationXUnit.cs
new file mode 100644
index 000000000000..d1555af04e69
--- /dev/null
+++ b/tests/common/ConfigurationXUnit.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Xamarin.Utils;
+using Xunit.Sdk;
+
+namespace Xamarin.Tests {
+
+ [AttributeUsage (AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
+ public sealed class PlatformInlineDataAttribute : DataAttribute {
+ readonly object [] dataValues;
+ public PlatformInlineDataAttribute (ApplePlatform platform, params object [] parameters)
+ {
+ // data values are the join of the platform and all other values passed to the attr
+ dataValues = parameters.Prepend (platform).ToArray ();
+ // based on the passed platform and the configuration, decide if we skip the test
+ switch (platform) {
+ case ApplePlatform.iOS:
+ if (!Configuration.include_ios)
+ Skip = "iOS is not included in this build";
+ break;
+ case ApplePlatform.TVOS:
+ if (!Configuration.include_tvos)
+ Skip = "tvOS is not included in this build";
+ break;
+ case ApplePlatform.MacOSX:
+ if (!Configuration.include_mac)
+ Skip = "macOS is not included in this build";
+ break;
+ case ApplePlatform.MacCatalyst:
+ if (!Configuration.include_maccatalyst)
+ Skip = "Mac Catalyst is not included in this build";
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ($"Unknown platform: {platform}");
+ }
+ }
+
+ public object [] DataValues {
+ get { return dataValues; }
+ }
+
+ public override IEnumerable