From 656d22a61947acff9324521ab830d89fa0080208 Mon Sep 17 00:00:00 2001 From: Mitchell Currie Date: Wed, 18 Mar 2020 16:49:13 +1100 Subject: [PATCH] Address two related issues: That the custom base class is not sanitised (leading '.' from default/implicit module creeps in) The filename has the same symptom except '.' gets replaced with '_', but in the case of the useless leading prefix, it ends up being '__' for machine file. --- mogenerator.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mogenerator.m b/mogenerator.m index 752844e7..e2b786fe 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -211,6 +211,15 @@ - (NSString*)customSuperentity { return forcedBaseClass; } } + +- (NSString*)sanitizedCustomSuperentity { + NSString *customSuperentity = [self customSuperentity]; + if ([customSuperentity hasPrefix:@"."]) { + return [customSuperentity stringByReplacingOccurrencesOfString:@"." withString:@""]; + } + return customSuperentity; +} + - (NSString*)forcedCustomBaseClass { NSString* userInfoCustomBaseClass = [[self userInfo] objectForKey:kCustomBaseClass]; return userInfoCustomBaseClass ? userInfoCustomBaseClass : gCustomBaseClassForced; @@ -1220,6 +1229,10 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { generatedHumanM = [generatedHumanM stringByReplacingOccurrencesOfRegex:searchPattern withString:replacementString]; NSString *entityClassName = [entity managedObjectClassName]; + if ([entityClassName.firstLetter compare:@"."] == NSOrderedSame) { + // If default module specified, "MyClass" -> ".MyClass" -> "_MyClass"/"__MyClass" + entityClassName = [entityClassName substringFromIndex:1]; + } entityClassName = [entityClassName stringByReplacingOccurrencesOfString:@"." withString:@"_"]; BOOL machineDirtied = NO;