anchor.diff:          .join('\n');
     }
   
  -  String generateSerializerDeclaration() {
  -    var camelCaseName = _toCamelCase(name);
  -    return 'Serializer<$genericName> '
  -        '_\$${camelCaseName}Serializer = '
  -        'new _\$${name}Serializer();';
  -  }
  +  String generateSerializerDeclaration() =>
  +      'Serializer<$genericName> ${serializerInstanceName} = new ${serializerImplName}();';
  +
  +  /// Returns the class name for the generated implementation. If the manually
  +  /// maintained class is private then we ignore the underscore here, to avoid
  +  /// returning a class name starting `_$_`.
  +  @memoized
  +  String get implName =>
  +      name.startsWith('_') ? '_\$${name.substring(1)}' : '_\$$name';
   
     String generateSerializer() {
       if (isBuiltValue) {
         return '''
  -class _\$${name}Serializer implements StructuredSerializer<$genericName> {
  -  @override
  -  final Iterable<Type> types = const [$name, _\$$name];
  +class ${serializerImplName} implements StructuredSerializer<$genericName> {
  +  @override
  +  final Iterable<Type> types = const [$name, $implName];
     @override
     final String wireName = '${escapeString(wireName)}';
   
  
positive.code:       if (wireNameMapping.isEmpty) {
          // No wire names. Just use the enum names directly.
          return '''
  class _\$${name}Serializer implements PrimitiveSerializer<$genericName> {
    @override
    final Iterable<Type> types = const <Type>[$name];
    @override
  
negative.code:   CompilationUnitElement get compilationUnit =>
        element.library.definingCompilationUnit;
  
    /// Returns the serializer class name for the generated implementation. If the manually
    /// maintained class is private then we ignore the underscore here, to avoid
    /// returning a class name starting `_$_`.
    @memoized
    String get serializerImplName {
      final unhidden = name.startsWith('_') ? name.substring(1) : name;
      return '_\$${unhidden}Serializer';
    }
  
    /// Returns the serializer instance name for the generated implementation,
    /// referenced by the user as a `static serializer` attribute.
    ///
    /// If the manually maintained class is private then we ignore the underscore here, to avoid
    /// returning a class name starting `_$_`.
    @memoized
    String get serializerInstanceName {
      final unhidden = name.startsWith('_') ? name.substring(1) : name;
      final camelCaseName =
          unhidden.substring(0, 1).toLowerCase() + unhidden.substring(1);
      return '_\$${camelCaseName}Serializer';
    }
  
    Iterable<String> computeErrors() {
      var result = <String>[];
  
      if (!serializerSettings.custom) {
        final expectedSerializerDeclaration =
            'static Serializer<$genericName> get serializer => ${serializerInstanceName};';
        // We used to recommend raw types; recommend the full type now, but still
        // allow raw types.
        final expectedSerializerDeclarationRaw =
            'static Serializer<$name> get serializer => ${serializerInstanceName};';
        if (serializerDeclaration != expectedSerializerDeclaration &&
            serializerDeclaration != expectedSerializerDeclarationRaw) {
          result.add('Declare $name.serializer as: '
  