mono / Embeddinator-4000

Tools to turn .NET libraries into native libraries that can be consumed on Android, iOS, Mac, Linux and other platforms.
MIT License
758 stars 95 forks source link

[objc] Special case System.String when generating from mscorlib.dll #259

Open VincentDondain opened 7 years ago

VincentDondain commented 7 years ago

When running e4k on mscorlib.dll System.String is generated as NSString *

** Class NSString *
 *  Corresponding .NET Qualified Name: `System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089`
 */
@interface NSString * : NSObject <System_IComparable, System_ICloneable, System_IConvertible, System_Collections_IEnumerable> {
    @public MonoEmbedObject* _object;
}

- (nullable instancetype)initWithC:(unsigned short *)aUshort count:(int *)count;

/** This type is not meant to be created using only default values
 *  Both the `-init` and `+new` selectors cannot be used to create instances of this type.
 */
- (nullable instancetype)init NS_UNAVAILABLE;
+ (nullable instancetype)new NS_UNAVAILABLE;

Because of this the generation of property_type, field_type, return_type and parameter type is wrong and we get some NSString * * or NSString **.

E.g.

- (NSString **)applyPolicyAssemblyName:(NSString * *)assemblyName;
@property (nonatomic, readonly) NSString * * category;

I believe we should special case System.String.

chamons commented 7 years ago

I believe this patch handles this -https://gist.github.com/cace5af3585db61daf82664c41f360fd

But there is no way to regression test this until we decide/get all of mscorlib building.

chamons commented 7 years ago

@spouliot - Is that worth spending time on?

spouliot commented 7 years ago

@chamons not urgent. We should generate correct code first. It's also a moving target as we started (not ended) exposing other types (either directly or by conversion)