2016-06-06 13:18:52 +03:00
TOP = ../..
2016-05-26 16:06:52 +03:00
i n c l u d e $( TOP ) / M a k e . c o n f i g
2017-03-06 19:26:06 +03:00
export MD_MTOUCH_SDK_ROOT = $( IOS_DESTDIR) /$( MONOTOUCH_PREFIX)
export XamarinMacFrameworkRoot = $( MAC_DESTDIR) /Library/Frameworks/Xamarin.Mac.framework/Versions/Current
2016-05-26 16:06:52 +03:00
#
# * Use [IOS|MAC]_TESTS for simple tests that just verify the code can compile / generate.
# To add such a test, just add the file, and add the name of the file (without extension) to [IOS|MAC]_TESTS.
#
# * Use [IOS|MAC]_CUSTOM_TESTS for more advanced tests that needs more validation.
# In this case you additionally need to add a target for the name of the test, with the
# your test logic.
#
IOS_CURRENT_DIR = $( IOS_DESTDIR) /Library/Frameworks/Xamarin.iOS.framework/Versions/Current
2017-03-06 19:26:06 +03:00
i f d e f I K V M
IOS_GENERATOR = $( IOS_CURRENT_DIR) /bin/bgen /unsafe --target-framework= Xamarin.iOS,v1.0
e l s e
2017-02-22 18:47:11 +03:00
IOS_GENERATOR = $( IOS_CURRENT_DIR) /bin/btouch-native /baselib:$( IOS_CURRENT_DIR) /lib/mono/Xamarin.iOS/Xamarin.iOS.dll /unsafe
2017-03-06 19:26:06 +03:00
e n d i f
2017-02-22 16:23:45 +03:00
IOS_TESTS = bug15283 bug15307 bug15799 bug16036 sof20696157 bug23041 bug27430 bug27428 bug34042 btouch-with-hyphen-in-name property-redefination-ios arrayfromhandlebug bug36457 bug39614 bug40282 bug17232 bug24078-ignore-methods-events strong-dict-support-templated-dicts bug43579 bindastests
2017-07-11 09:52:24 +03:00
IOS_CUSTOM_TESTS = forum54078 desk63279 desk79124 multiple-api-definitions1 multiple-api-definitions2 bug29493 classNameCollision bi1036 bug37527 bug27986 bug35176 bi1046 bindas1048error bindas1049error bindas1050modelerror bindas1050protocolerror virtualwrap bug42855 bug52570classinternal bug52570methodinternal bug52570allowstaticmembers bug42742 warnaserror nowarn noasyncinternalwrapper noasyncwarningcs0219 bug53076 bug53076withmodel bug57070 fieldenumtests
2016-05-26 16:06:52 +03:00
MAC_CURRENT_DIR = $( MAC_DESTDIR) /Library/Frameworks/Xamarin.Mac.framework/Versions/Current
2017-03-06 19:26:06 +03:00
i f d e f I K V M
MAC_GENERATOR = $( MAC_CURRENT_DIR) /bin/bgen
2017-03-22 18:22:31 +03:00
MAC_CLASSIC_GENERATOR = $( MAC_CURRENT_DIR) /bin/bgen --target-framework= XamMac,v1.0
MAC_FULL_GENERATOR = $( MAC_CURRENT_DIR) /bin/bgen --target-framework= Xamarin.Mac,Version= v4.5,Profile= Full
MAC_MOBILE_GENERATOR = $( MAC_CURRENT_DIR) /bin/bgen --target-framework= Xamarin.Mac,Version= v2.0,Profile= Mobile
2017-03-06 19:26:06 +03:00
e l s e
2016-05-26 16:06:52 +03:00
MAC_GENERATOR = $( MAC_CURRENT_DIR) /bin/bmac
2017-03-22 18:22:31 +03:00
MAC_CLASSIC_GENERATOR = $( MAC_GENERATOR)
MAC_FULL_GENERATOR = $( MAC_GENERATOR) --unified-full-profile
MAC_MOBILE_GENERATOR = $( MAC_GENERATOR) --unified-mobile-profile
2017-03-06 19:26:06 +03:00
e n d i f
2016-05-26 16:06:52 +03:00
MAC_TESTS = bmac_smoke bmac-with-hyphen-in-name property-redefination-mac NSApplicationPublicEnsureMethods protocol-duplicate-abstract
MAC_CUSTOM_TESTS = bug31788 protocol-duplicate-abstract-error protocol-duplicate-method-diff-length protocol-duplicate-method-diff-out protocol-duplicate-method-diff-type protocol-duplicate-method-diff-return
ALL_TESTS =
i f d e f I N C L U D E _ I O S
ALL_TESTS += $( IOS_TESTS) $( IOS_CUSTOM_TESTS)
e n d i f
i f d e f I N C L U D E _ M A C
ALL_TESTS += $( MAC_TESTS) $( MAC_CUSTOM_TESTS)
e n d i f
2017-07-11 09:52:24 +03:00
all-local :: $( ALL_TESTS ) run -unit -tests
build-unit-tests :
$( Q) $( SYSTEM_MONO) /Library/Frameworks//Mono.framework/Versions/Current/lib/mono/nuget/NuGet.exe restore $( TOP) /src/generator-ikvm.sln
$( SYSTEM_XBUILD) generator-tests.csproj $( XBUILD_VERBOSITY)
run-unit-tests : build -unit -tests
rm -f .failed-stamp
$( SYSTEM_MONO) --debug $( TOP) /packages/NUnit.ConsoleRunner.3.5.0/tools/nunit3-console.exe $( abspath $( TOP) /tests/generator/bin/Debug/generator-tests.dll) " --result= $( abspath $( CURDIR) /TestResult.xml) ;format=nunit2 " $( TEST_FIXTURE) --labels= All || touch $( CURDIR) /.failed-stamp
@# Create an html file and tell MonkeyWrench to upload it ( if we' re running there)
@[ [ -z " $$ BUILD_REPOSITORY " ] ] || \
( xsltproc $( TOP) /tests/HtmlTransform.xslt TestResult.xml > index.html && \
echo " @MonkeyWrench: AddFile: $$ PWD/index.html " )
@[ [ ! -e .failed-stamp ] ]
2016-05-26 16:06:52 +03:00
$(MAC_TESTS) :
2017-03-22 18:22:31 +03:00
$( if $( V) ,,@echo " $@ " ; ) $( MAC_CLASSIC_GENERATOR) -d= MONOMAC $@ .cs
$( if $( V) ,,@echo " $@ " ; ) $( MAC_FULL_GENERATOR) -d= MONOMAC -d= XAMCORE_2_0 $@ .cs
$( if $( V) ,,@echo " $@ " ; ) $( MAC_MOBILE_GENERATOR) -d= MONOMAC -d= XAMCORE_2_0 $@ .cs
2016-05-26 16:06:52 +03:00
$(IOS_TESTS) :
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $@ .cs
d e f i n e P r o t o c o l T e s t T e m p l a t e
$(1) :
2017-03-22 18:22:31 +03:00
$( if $( V) ,,@echo " $$ @ " ; ) $( MAC_CLASSIC_GENERATOR) -d= MONOMAC $( 1) .cs 2>& 1 | grep BI$( 2) > /dev/null
$( if $( V) ,,@echo " $$ @ " ; ) $( MAC_FULL_GENERATOR) -d= MONOMAC -d= XAMCORE_2_0 $( 1) .cs 2>& 1 | grep BI$( 2) > /dev/null
$( if $( V) ,,@echo " $$ @ " ; ) $( MAC_MOBILE_GENERATOR) -d= MONOMAC -d= XAMCORE_2_0 $( 1) .cs 2>& 1 | grep BI$( 2) > /dev/null
2016-05-26 16:06:52 +03:00
e n d e f
$( eval $ ( call ProtocolTestTemplate ,protocol -duplicate -abstract -error ,1037) )
$( eval $ ( call ProtocolTestTemplate ,protocol -duplicate -method -diff -length ,1039) )
$( eval $ ( call ProtocolTestTemplate ,protocol -duplicate -method -diff -out ,1040) )
$( eval $ ( call ProtocolTestTemplate ,protocol -duplicate -method -diff -type ,1041) )
$( eval $ ( call ProtocolTestTemplate ,protocol -duplicate -method -diff -return ,1038) )
2017-01-25 09:14:55 +03:00
d e f i n e i O S E r r o r C o d e T e s t T e m p l a t e
$(1) :
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $( 1) .cs 2>& 1 | grep BI$( 2) > /dev/null
e n d e f
$( eval $ ( call iOSErrorCodeTestTemplate ,bindas 1048error ,1048) )
$( eval $ ( call iOSErrorCodeTestTemplate ,bindas 1049error ,1049) )
$( eval $ ( call iOSErrorCodeTestTemplate ,bindas 1050modelerror ,1050) )
$( eval $ ( call iOSErrorCodeTestTemplate ,bindas 1050protocolerror ,1050) )
2017-03-10 18:52:32 +03:00
$( eval $ ( call iOSErrorCodeTestTemplate ,bug 42855,1060) )
2017-06-02 19:31:10 +03:00
$( eval $ ( call iOSErrorCodeTestTemplate ,bug 57070,1061) )
2017-03-14 22:03:13 +03:00
d e f i n e i O S N o E r r o r C o d e s T e s t T e m p l a t e
$(1) :
$( if $( V) ,,@echo " $@ " ; ) !( $( IOS_GENERATOR) $( 1) .cs 2>& 1 | grep BI$( 2) > /dev/null)
e n d e f
$( eval $ ( call iOSNoErrorCodesTestTemplate ,bug 52570classinternal ,1117) )
$( eval $ ( call iOSNoErrorCodesTestTemplate ,bug 52570methodinternal ,1117) )
$( eval $ ( call iOSNoErrorCodesTestTemplate ,bug 52570allowstaticmembers ,1117) )
2017-01-25 09:14:55 +03:00
2016-05-26 16:06:52 +03:00
classNameCollision :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $@ .cs -s:classNameCollision-enum.cs -tmpdir= $@ .tmpdir
bug31788 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
2017-03-22 18:22:31 +03:00
$( if $( V) ,,@echo " $@ " ; ) $( MAC_CLASSIC_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
2016-05-26 16:06:52 +03:00
@grep -q xamarin_IntPtr_objc_msgSend bug31788.tmpdir/Test/MarshalOnProperty.g.cs
@grep -q xamarin_IntPtr_objc_msgSend bug31788.tmpdir/Test/MarshalInProperty.g.cs
desk63279 :
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) desk63279A.cs desk63279B.cs
desk79124 :
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $@ .cs >/dev/null 2>& 1
@if ! monodis $@ .dll --typedef | grep WYPopoverBackgroundViewAppearance > /dev/null; then \
echo "error: Could not find WYPopoverBackgroundViewAppearance in generated code." ; \
fi
forum54078 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@! grep "Type does not conform to NSCoding" forum54078.tmpdir/Test/CustomController.g.cs
multiple-api-definitions1 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
multiple-api-definitions2 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir --api= $@ -a.cs --api= $@ -b.cs
bug29493 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@! grep -r "static readonly IntPtr class_ptr = Class.GetHandle (\"global::" bug29493.tmpdir/Bug29493
bug37527 :
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $@ -missing-property.cs | grep "BaseType.Delegates were set but no properties could be found. Do ensure that the WrapAttribute is used on the right properties." >/dev/null 2>& 1
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $@ -wrong-property.cs | grep "should be renamed to 'Delegate' for BaseType.Events and BaseType.Delegates to work." >/dev/null 2>& 1
bug27986 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@if ! grep -r Preserve bug27986.tmpdir/bug27986 > /dev/null; then \
echo "error: Could not find Preserve attribute in generated code." ; exit 1; \
fi
@if [ ` grep -r Preserve bug27986.tmpdir/bug27986 | wc -l` -ne 28 ] ; then \
echo "Error: Expected 28 Preserve attributes in generated code. If you modified code that generates PreserveAttributes please update the preserve count." ; exit 1; \
fi
bug35176 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@if ! grep -r Introduced bug35176.tmpdir/bug35176 > /dev/null; then \
echo "error: Could not find Introduced attribute in generated code." ; exit 1; \
fi
@if [ ` grep -r Introduced bug35176.tmpdir/bug35176 | wc -l` -ne 8 ] ; then \
echo "Error: Expected 4 Introduced attributes in generated code." ; exit 1; \
fi
2016-11-03 06:18:59 +03:00
bug46292 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs --process-enums
@if ! grep -r Obsolete bug46292.tmpdir/BindingTests > /dev/null; then \
echo "error: Could not find Obsolete attribute in generated code." ; exit 1; \
fi
@if [ ` grep -r Obsolete bug46292.tmpdir/BindingTests | wc -l` -ne 2 ] ; then \
echo "Error: Expected 2 Obsolete attributes in generated code." ; exit 1; \
fi
2016-09-26 09:05:41 +03:00
forcedtype :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@if ! grep -r GetINativeObject forcedtype.tmpdir > /dev/null; then \
echo "error: Could not find GetINativeObject usage in generated code." ; exit 1; \
fi
@if [ ` grep -r GetINativeObject forcedtype.tmpdir | wc -l` -ne 12 ] ; then \
echo "Error: Expected 12 GetINativeObject usages in generated code." ; exit 1; \
fi
2016-05-26 16:06:52 +03:00
bi1036 :
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $@ .cs | grep BI1036 >/dev/null 2>& 1
2016-11-03 04:46:04 +03:00
bi1046 :
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) $@ .cs --process-enums | grep BI1046 >/dev/null 2>& 1
2017-02-17 02:24:40 +03:00
virtualwrap :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs --process-enums
@if ! grep -r "public virtual" virtualwrap.tmpdir/WrapTest > /dev/null; then \
echo "error: Could not find public virtual keywords in generated code." ; exit 1; \
fi
@if [ ` grep -r "public virtual" virtualwrap.tmpdir/WrapTest | wc -l` -ne 4 ] ; then \
echo "Error: Expected 4 virtual keywords in generated code." ; exit 1; \
fi
2017-03-21 18:20:05 +03:00
bug42742 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@if ! grep -r Advice bug42742.tmpdir/bug42742 > /dev/null; then \
echo "error: Could not find Advice attribute in generated code." ; exit 1; \
fi
@if [ ` grep -r Advice bug42742.tmpdir/bug42742 | wc -l` -ne 24 ] ; then \
echo "Error: Expected 24 Advice attributes in generated code. If you modified code that generates PreserveAttributes please update the preserve count." ; exit 1; \
fi
2017-03-22 15:52:24 +03:00
warnaserror :
$( if $( V) ,,@echo " iOS $@ Enabled " ; ) $( IOS_GENERATOR) -d= XAMCORE_2_0 -warnaserror $@ .cs | grep "error BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " iOS $@ Disabled " ; ) !( $( IOS_GENERATOR) -d= XAMCORE_2_0 $@ .cs | grep "error BI1117" > /dev/null 2>& 1)
$( if $( V) ,,@echo " iOS $@ Disabled Warning Found " ; ) $( IOS_GENERATOR) -d= XAMCORE_2_0 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " iOS $@ Only 1116 " ; ) $( IOS_GENERATOR) -d= XAMCORE_2_0 -warnaserror:1116 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " iOS $@ Only 1117 " ; ) $( IOS_GENERATOR) -d= XAMCORE_2_0 -warnaserror:1117 $@ .cs | grep "error BI1117" > /dev/null 2>& 1
2017-03-22 18:22:31 +03:00
$( if $( V) ,,@echo " macOS $@ Enabled " ; ) $( MAC_CLASSIC_GENERATOR) -warnaserror $@ .cs | grep "error BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " macOS $@ Disabled " ; ) !( $( MAC_CLASSIC_GENERATOR) $@ .cs | grep "error BI1117" > /dev/null 2>& 1)
$( if $( V) ,,@echo " macOS $@ Disabled Warning Found " ; ) $( MAC_CLASSIC_GENERATOR) $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " macOS $@ Only 1116 " ; ) $( MAC_CLASSIC_GENERATOR) -warnaserror:1116 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " macOS $@ Only 1117 " ; ) $( MAC_CLASSIC_GENERATOR) -warnaserror:1117 $@ .cs | grep "error BI1117" > /dev/null 2>& 1
2017-03-22 15:52:24 +03:00
nowarn :
$( if $( V) ,,@echo " iOS $@ Enabled " ; ) !( $( IOS_GENERATOR) -d= XAMCORE_2_0 -nowarn $@ .cs | grep "warning BI1117" > /dev/null 2>& 1)
$( if $( V) ,,@echo " iOS $@ Disabled " ; ) $( IOS_GENERATOR) -d= XAMCORE_2_0 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " iOS $@ Disabled Warning Found " ; ) $( IOS_GENERATOR) -d= XAMCORE_2_0 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " iOS $@ Only 1116 " ; ) $( IOS_GENERATOR) -d= XAMCORE_2_0 -nowarn:1116 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " iOS $@ Only 1117 " ; ) !( $( IOS_GENERATOR) -d= XAMCORE_2_0 -nowarn:1117 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1)
2017-03-22 18:22:31 +03:00
$( if $( V) ,,@echo " macOS $@ Enabled " ; ) !( $( MAC_CLASSIC_GENERATOR) -nowarn $@ .cs | grep "warning BI1117" > /dev/null 2>& 1)
$( if $( V) ,,@echo " macOS $@ Disabled " ; ) $( MAC_CLASSIC_GENERATOR) $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " macOS $@ Disabled Warning Found " ; ) $( MAC_CLASSIC_GENERATOR) $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " macOS $@ Only 1116 " ; ) $( MAC_CLASSIC_GENERATOR) -nowarn:1116 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1
$( if $( V) ,,@echo " macOS $@ Only 1117 " ; ) !( $( MAC_CLASSIC_GENERATOR) -nowarn:1117 $@ .cs | grep "warning BI1117" > /dev/null 2>& 1)
2017-03-22 15:52:24 +03:00
[generator] Remove Async members from internal BaseWrapper derived types
Currently we generate FooAsync members inside internal BaseWrapper
derived types used by protocol support. This generated Async members
are useles so we remove them to avoid extra metadata.
Old generated code
```csharp
internal sealed class MyFooDelegateWrapper : BaseWrapper, IMyFooDelegate {
[Preserve (Conditional = true)]
public MyFooDelegateWrapper (IntPtr handle, bool owns)
: base (handle, owns)
{
}
[Export ("stringMethod:completion:")]
[CompilerGenerated]
public unsafe void StringMethod (int arg1, [BlockProxy (typeof (ObjCRuntime.Trampolines.NIDActionArity1V0))]global::System.Action<NSError> err)
{
if (err == null)
throw new ArgumentNullException ("err");
BlockLiteral *block_ptr_err;
BlockLiteral block_err;
block_err = new BlockLiteral ();
block_ptr_err = &block_err;
block_err.SetupBlock (Trampolines.SDActionArity1V0.Handler, err);
global::ApiDefinition.Messaging.void_objc_msgSend_int_IntPtr (this.Handle, Selector.GetHandle ("stringMethod:completion:"), arg1, (IntPtr) block_ptr_err);
block_ptr_err->CleanupBlock ();
}
[CompilerGenerated]
public unsafe Task StringMethodAsync (int arg1)
{
var tcs = new TaskCompletionSource<bool> ();
StringMethod(arg1, (obj_) => {
if (obj_ != null)
tcs.SetException (new NSErrorException(obj_));
else
tcs.SetResult (true);
});
return tcs.Task;
}
}
```
new generated code:
```csharp
internal sealed class MyFooDelegateWrapper : BaseWrapper, IMyFooDelegate {
[Preserve (Conditional = true)]
public MyFooDelegateWrapper (IntPtr handle, bool owns)
: base (handle, owns)
{
}
[Export ("stringMethod:completion:")]
[CompilerGenerated]
public unsafe void StringMethod (int arg1, [BlockProxy (typeof (ObjCRuntime.Trampolines.NIDActionArity1V0))]global::System.Action<NSError> err)
{
if (err == null)
throw new ArgumentNullException ("err");
BlockLiteral *block_ptr_err;
BlockLiteral block_err;
block_err = new BlockLiteral ();
block_ptr_err = &block_err;
block_err.SetupBlock (Trampolines.SDActionArity1V0.Handler, err);
global::ApiDefinition.Messaging.void_objc_msgSend_int_IntPtr (this.Handle, Selector.GetHandle ("stringMethod:completion:"), arg1, (IntPtr) block_ptr_err);
block_ptr_err->CleanupBlock ();
}
}
```
Added unit test.
build diff for this change:
https://gist.github.com/dalexsoto/eeaefc9d86e37b0c5ce5fe6d5d091383
2017-03-25 02:40:55 +03:00
noasyncinternalwrapper :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
2017-03-29 12:12:56 +03:00
@if [ ` grep -r RequiredMethodAsync $@ .tmpdir/NoAsyncInternalWrapperTests | wc -l` -ne 1 ] ; then \
echo "Error: Expected 1 RequiredMethodAsync members in generated code. If you modified code that generates RequiredMethodAsync (AsyncAttribute) please update the RequiredMethodAsync count." ; exit 1; \
[generator] Remove Async members from internal BaseWrapper derived types
Currently we generate FooAsync members inside internal BaseWrapper
derived types used by protocol support. This generated Async members
are useles so we remove them to avoid extra metadata.
Old generated code
```csharp
internal sealed class MyFooDelegateWrapper : BaseWrapper, IMyFooDelegate {
[Preserve (Conditional = true)]
public MyFooDelegateWrapper (IntPtr handle, bool owns)
: base (handle, owns)
{
}
[Export ("stringMethod:completion:")]
[CompilerGenerated]
public unsafe void StringMethod (int arg1, [BlockProxy (typeof (ObjCRuntime.Trampolines.NIDActionArity1V0))]global::System.Action<NSError> err)
{
if (err == null)
throw new ArgumentNullException ("err");
BlockLiteral *block_ptr_err;
BlockLiteral block_err;
block_err = new BlockLiteral ();
block_ptr_err = &block_err;
block_err.SetupBlock (Trampolines.SDActionArity1V0.Handler, err);
global::ApiDefinition.Messaging.void_objc_msgSend_int_IntPtr (this.Handle, Selector.GetHandle ("stringMethod:completion:"), arg1, (IntPtr) block_ptr_err);
block_ptr_err->CleanupBlock ();
}
[CompilerGenerated]
public unsafe Task StringMethodAsync (int arg1)
{
var tcs = new TaskCompletionSource<bool> ();
StringMethod(arg1, (obj_) => {
if (obj_ != null)
tcs.SetException (new NSErrorException(obj_));
else
tcs.SetResult (true);
});
return tcs.Task;
}
}
```
new generated code:
```csharp
internal sealed class MyFooDelegateWrapper : BaseWrapper, IMyFooDelegate {
[Preserve (Conditional = true)]
public MyFooDelegateWrapper (IntPtr handle, bool owns)
: base (handle, owns)
{
}
[Export ("stringMethod:completion:")]
[CompilerGenerated]
public unsafe void StringMethod (int arg1, [BlockProxy (typeof (ObjCRuntime.Trampolines.NIDActionArity1V0))]global::System.Action<NSError> err)
{
if (err == null)
throw new ArgumentNullException ("err");
BlockLiteral *block_ptr_err;
BlockLiteral block_err;
block_err = new BlockLiteral ();
block_ptr_err = &block_err;
block_err.SetupBlock (Trampolines.SDActionArity1V0.Handler, err);
global::ApiDefinition.Messaging.void_objc_msgSend_int_IntPtr (this.Handle, Selector.GetHandle ("stringMethod:completion:"), arg1, (IntPtr) block_ptr_err);
block_ptr_err->CleanupBlock ();
}
}
```
Added unit test.
build diff for this change:
https://gist.github.com/dalexsoto/eeaefc9d86e37b0c5ce5fe6d5d091383
2017-03-25 02:40:55 +03:00
fi
2017-03-25 06:08:40 +03:00
noasyncwarningcs0219 :
$( if $( V) ,,@echo " $@ " ; ) !( $( IOS_GENERATOR) $@ .cs 2>& 1 | grep "warning CS0219" > /dev/null 2>& 1)
[generator] Turn [Async] methods inside [Protocol] into extension methods
Partial fix for:
https://bugzilla.xamarin.com/show_bug.cgi?id=53076
We currently generate extension methods for optional members decorated
with [Async] inside a [Protocol] but we ignore the required methods
decorated with [Async]. This commit fixes this issue and we now
generate extension methods for required members.
Lets take the following API definition
```csharp
[Protocol]
interface MyFooProtocol {
[Abstract]
[Async]
[Export ("requiredMethod:completion:")]
void RequiredMethod (int arg1, Action<NSError> err);
[Async]
[Export ("optional:completion:")]
void OptionalMethod (int arg1, Action<NSError> err);
}
```
This generates:
```csharp
public static partial class MyFooProtocol_Extensions {
[CompilerGenerated]
public unsafe static void OptionalMethod (this IMyFooProtocol This, int arg1, [BlockProxy (typeof (ObjCRuntime.Trampolines.NIDActionArity1V0))]global::System.Action<NSError> err)
{
if (err == null)
throw new ArgumentNullException ("err");
BlockLiteral *block_ptr_err;
BlockLiteral block_err;
block_err = new BlockLiteral ();
block_ptr_err = &block_err;
block_err.SetupBlock (Trampolines.SDActionArity1V0.Handler, err);
global::ApiDefinition.Messaging.void_objc_msgSend_int_IntPtr (This.Handle, Selector.GetHandle ("optional:completion:"), arg1, (IntPtr) block_ptr_err);
block_ptr_err->CleanupBlock ();
}
[CompilerGenerated]
public unsafe static Task OptionalMethodAsync (this IMyFooProtocol This, int arg1)
{
var tcs = new TaskCompletionSource<bool> ();
This.OptionalMethod(arg1, (obj_) => {
if (obj_ != null)
tcs.SetException (new NSErrorException(obj_));
else
tcs.SetResult (true);
});
return tcs.Task;
}
[CompilerGenerated]
public unsafe static Task RequiredMethodAsync (this IMyFooProtocol This, int arg1)
{
var tcs = new TaskCompletionSource<bool> ();
This.RequiredMethod(arg1, (obj_) => {
if (obj_ != null)
tcs.SetException (new NSErrorException(obj_));
else
tcs.SetResult (true);
});
return tcs.Task;
}
}
```
Adds unit test
Build diff:
https://gist.github.com/dalexsoto/75290d1ffa1fdfb529cc30b9e66de5f2
2017-03-25 07:57:05 +03:00
bug53076 :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@if [ ` grep -r "Async (this IMyFooProtocol" $@ .tmpdir/Bug53076Test | wc -l` -ne 10 ] ; then \
echo "Error: Expected 10 'Async (this IMyFooProtocol' matches in generated code. If you modified code that generates extension FooRequiredMethodAsync (AsyncAttribute) please update the 'Async (this IMyFooProtocol' count." ; exit 1; \
fi
2017-03-25 09:35:36 +03:00
bug53076withmodel :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs
@if [ ` grep -r "Async (this IMyFooProtocol" $@ .tmpdir/Bug53076WithModelTest | wc -l` -ne 10 ] ; then \
echo "Error: Expected 10 'Async (this IMyFooProtocol' matches in generated code. If you modified code that generates extension FooRequiredMethodAsync (AsyncAttribute) please update the 'Async (this IMyFooProtocol' count." ; exit 1; \
fi
2017-06-20 21:46:00 +03:00
fieldenumtests :
@rm -Rf $@ .tmpdir
@mkdir -p $@ .tmpdir
$( if $( V) ,,@echo " $@ " ; ) $( IOS_GENERATOR) --sourceonly:$@ .source -tmpdir= $@ .tmpdir $@ .cs --process-enums
2016-05-26 16:06:52 +03:00
clean-local ::
rm -f *.dll *.source
rm -Rf *.tmpdir