diff --git a/tools/ArduinoCsCompiler/IlWriter.cs b/tools/ArduinoCsCompiler/IlWriter.cs index 888841ea9b..e9c2e9aba6 100644 --- a/tools/ArduinoCsCompiler/IlWriter.cs +++ b/tools/ArduinoCsCompiler/IlWriter.cs @@ -22,6 +22,7 @@ namespace ArduinoCsCompiler { public class IlWriter { + public const string GENERATED_NAMESPACE = "NanoInput"; private readonly ExecutionSet _executionSet; private readonly IlCapabilities _ilCapabilities; @@ -81,7 +82,7 @@ public void Write(string sourceFile, string outFile) using TextWriter tw = new StreamWriter("C:\\projects\\iot4\\tools\\ArduinoCsCompiler\\samples\\BlinkingLedNano\\generated.cs"); SyntaxTree tree = new SyntaxTree(); - var node = new NamespaceDeclaration("Decompiled"); + var node = new NamespaceDeclaration(GENERATED_NAMESPACE); tree.AddChild(node, SyntaxTree.MemberRole); foreach (var cls in _executionSet.Classes) @@ -89,6 +90,8 @@ public void Write(string sourceFile, string outFile) var typeSystemAstBuilder = new TypeSystemAstBuilder(); var wrapped = new ClassWrapper(cls, _executionSet); EntityDeclaration decl = typeSystemAstBuilder.ConvertEntity(wrapped); + + node.AddChild(new Comment($"{cls.Name}", CommentType.Documentation), Roles.Comment); node.AddChild(decl, SyntaxTree.MemberRole); foreach (var member in cls.Members) { diff --git a/tools/ArduinoCsCompiler/NanoGenerator/ClassWrapper.cs b/tools/ArduinoCsCompiler/NanoGenerator/ClassWrapper.cs index f87b44418b..31f1952c84 100644 --- a/tools/ArduinoCsCompiler/NanoGenerator/ClassWrapper.cs +++ b/tools/ArduinoCsCompiler/NanoGenerator/ClassWrapper.cs @@ -38,7 +38,7 @@ public ClassWrapper(ClassDeclaration cls, ExecutionSet executionSet) public SymbolKind SymbolKind => SymbolKind.TypeDefinition; - public string FullName => _cls.Name; + public string FullName => $"Class_{_cls.NewToken:X8}"; public IEnumerable GetAttributes() { @@ -57,7 +57,7 @@ public bool HasAttribute(KnownAttribute attribute) public EntityHandle MetadataToken => throw new NotImplementedException(); - public string Name => _cls.SimpleName; + public string Name => $"Class_{_cls.NewToken:X8}"; public ITypeDefinition? DeclaringTypeDefinition => null; @@ -235,7 +235,7 @@ public IEnumerable DirectBaseTypes public string ReflectionName => _cls.TheType.Name; - public string Namespace => _cls.TheType.Namespace ?? string.Empty; + public string Namespace => IlWriter.GENERATED_NAMESPACE; public ICompilation Compilation => throw new NotImplementedException(); public bool Equals(IType? other) diff --git a/tools/ArduinoCsCompiler/NanoGenerator/FieldWrapper.cs b/tools/ArduinoCsCompiler/NanoGenerator/FieldWrapper.cs index 87c47e1328..6ad731b97b 100644 --- a/tools/ArduinoCsCompiler/NanoGenerator/FieldWrapper.cs +++ b/tools/ArduinoCsCompiler/NanoGenerator/FieldWrapper.cs @@ -50,7 +50,14 @@ public bool HasAttribute(KnownAttribute attribute) return _memberField.Field.GetValue(null); // Expect a constant here } - public string Name => _memberField.FieldName; + public string Name + { + get + { + // memberfied.FieldName + return $"Field_{_memberField.Token:X8}"; + } + } public bool IsReadOnly => _memberField.Field.IsInitOnly; public bool ReturnTypeIsRefReadOnly { get; } public bool IsVolatile { get; }