Skip to content

Commit

Permalink
Address two related issues:
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mitchins committed Mar 18, 2020
1 parent 797dcd5 commit 656d22a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 656d22a

Please sign in to comment.