Skip to content

Commit

Permalink
fix: correctly set nested type namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Clazex committed Mar 8, 2023
1 parent db64df8 commit c6f5b99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HKReflect.Fody/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal static void ParallelForEach<T>(this IEnumerable<T> self, Action<T> acti


internal static bool IsInNamespace(this TypeReference self, string ns) =>
self.Namespace == ns || self.Namespace.StartsWith(ns + '.');
self.DeclaringType?.IsInNamespace(ns) ?? (self.Namespace == ns || self.Namespace.StartsWith(ns + '.'));


internal static GenericInstanceMethod MakeGenericMethod(this MethodReference self, params TypeReference[] arguments) {
Expand Down
4 changes: 3 additions & 1 deletion ReflectGen/InstanceClassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Dictionary<TypeDefinition, string> typesToAddInheritance
}

Lazy<TypeDefinition> resTypeDef = new(() => new(
string.IsNullOrEmpty(typeDef.Namespace) ? baseNs : $"{baseNs}.{typeDef.Namespace}",
typeDef.IsNested
? string.Empty
: string.IsNullOrEmpty(typeDef.Namespace) ? baseNs : $"{baseNs}.{typeDef.Namespace}",
typeDef.Name,
(typeDef.Attributes & (~TypeAttributes.NestedFamORAssem))
| (typeDef.IsNested ? TypeAttributes.NestedPublic : TypeAttributes.Public)
Expand Down
4 changes: 3 additions & 1 deletion ReflectGen/StaticClassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ internal sealed partial class Program {
Dictionary<TypeDefinition, string> typesToAddInheritance
) {
Lazy<TypeDefinition> resTypeDef = new(() => new(
string.IsNullOrEmpty(typeDef.Namespace) ? baseNs + ".Static" : $"{baseNs}.Static.{typeDef.Namespace}",
typeDef.IsNested
? string.Empty
: string.IsNullOrEmpty(typeDef.Namespace) ? baseNs + ".Static" : $"{baseNs}.Static.{typeDef.Namespace}",
typeDef.Name + "R",
(typeDef.Attributes & (~TypeAttributes.NestedFamORAssem))
| (typeDef.IsNested ? TypeAttributes.NestedPublic : TypeAttributes.Public)
Expand Down

0 comments on commit c6f5b99

Please sign in to comment.