From fc80642e375035e49f666d9f248549d3d2cb0b4f Mon Sep 17 00:00:00 2001 From: Ste Prescott Date: Sat, 11 Jun 2022 01:36:22 +0100 Subject: [PATCH 1/2] Add C# generator Co-authored-by: Jonny Booker : <1131478+JonnyBooker@users.noreply.github.com> --- .../xcschemes/LexiconGenerators.xcscheme | 107 ++++++++ Package.swift | 235 ++++++++++-------- Sources/CSharpStandAlone/Generator.swift | 121 +++++++++ Sources/LexiconGenerators/List.swift | 25 +- .../ CSharpStandAlone\342\204\242.swift" | 20 ++ Tests/CSharpStandAloneTests/Resources/test.cs | 124 +++++++++ .../Resources/test.taskpaper | 17 ++ Tests/CSharpStandAloneTests/util.swift | 26 ++ 8 files changed, 557 insertions(+), 118 deletions(-) create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/LexiconGenerators.xcscheme create mode 100644 Sources/CSharpStandAlone/Generator.swift create mode 100644 "Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" create mode 100644 Tests/CSharpStandAloneTests/Resources/test.cs create mode 100644 Tests/CSharpStandAloneTests/Resources/test.taskpaper create mode 100644 Tests/CSharpStandAloneTests/util.swift diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/LexiconGenerators.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/LexiconGenerators.xcscheme new file mode 100644 index 0000000..133d839 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/LexiconGenerators.xcscheme @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Package.swift b/Package.swift index 20b23d1..baa68c5 100644 --- a/Package.swift +++ b/Package.swift @@ -3,111 +3,132 @@ import PackageDescription let package = Package( - name: "Lexicon", - platforms: [ - .macOS(.v11), - .iOS(.v14) - ], - products: [ - .library(name: "Lexicon", targets: ["Lexicon"]), - .library(name: "SwiftLexicon", targets: ["SwiftLexicon"]), - .library(name: "SwiftStandAlone", targets: ["SwiftStandAlone"]), - .library(name: "KotlinStandAlone", targets: ["KotlinStandAlone"]), - .library(name: "LexiconGenerators", targets: ["LexiconGenerators"]), - ], - dependencies: [ - .package(url: "https://github.com/screensailor/Hope", .branch("trunk")), - .package(url: "https://github.com/apple/swift-collections", from: "1.0.0"), - ], - targets: [ - - // MARK: Lexicon - - .target( - name: "Lexicon", - dependencies: [ - .product(name: "Collections", package: "swift-collections") - ], - swiftSettings: [.define("EDITOR")] // TODO: meke this opt in - ), - .testTarget( - name: "LexiconTests", - dependencies: [ - "Hope", - "Lexicon" - ], - resources: [ - .copy("Resources") - ] - ), - - // MARK: LexiconGenerators - - .target( - name: "LexiconGenerators", - dependencies: [ - "Lexicon", - "SwiftLexicon", - "SwiftStandAlone", - "KotlinStandAlone" - ] - ), - - // MARK: SwiftLexicon - - .target( - name: "SwiftLexicon", - dependencies: [ - "Lexicon", - ] - ), - .testTarget( - name: "SwiftLexiconTests", - dependencies: [ - "Hope", - "SwiftLexicon" - ], - resources: [ - .copy("Resources"), - ] - ), - - // MARK: SwiftStandAlone - - .target( - name: "SwiftStandAlone", - dependencies: [ - "Lexicon", - ] - ), - .testTarget( - name: "SwiftStandAloneTests", - dependencies: [ - "Hope", - "SwiftStandAlone" - ], - resources: [ - .copy("Resources"), - ] - ), - - // MARK: KotlinStandAlones - - .target( - name: "KotlinStandAlone", - dependencies: [ - "Lexicon", - ] - ), - .testTarget( - name: "KotlinStandAloneTests", - dependencies: [ - "Hope", - "KotlinStandAlone" - ], - resources: [ - .copy("Resources"), - ] - ), - ] + name: "Lexicon", + platforms: [ + .macOS(.v11), + .iOS(.v14) + ], + products: [ + .library(name: "Lexicon", targets: ["Lexicon"]), + .library(name: "SwiftLexicon", targets: ["SwiftLexicon"]), + .library(name: "SwiftStandAlone", targets: ["SwiftStandAlone"]), + .library(name: "KotlinStandAlone", targets: ["KotlinStandAlone"]), + .library(name: "CSharpStandAlone", targets: ["CSharpStandAlone"]), + .library(name: "LexiconGenerators", targets: ["LexiconGenerators"]), + ], + dependencies: [ + .package(url: "https://github.com/screensailor/Hope", .branch("trunk")), + .package(url: "https://github.com/apple/swift-collections", from: "1.0.0"), + ], + targets: [ + + // MARK: Lexicon + + .target( + name: "Lexicon", + dependencies: [ + .product(name: "Collections", package: "swift-collections") + ], + swiftSettings: [.define("EDITOR")] // TODO: meke this opt in + ), + .testTarget( + name: "LexiconTests", + dependencies: [ + "Hope", + "Lexicon" + ], + resources: [ + .copy("Resources") + ] + ), + + // MARK: LexiconGenerators + + .target( + name: "LexiconGenerators", + dependencies: [ + "Lexicon", + "SwiftLexicon", + "SwiftStandAlone", + "KotlinStandAlone", + "CSharpStandAlone" + ] + ), + + // MARK: SwiftLexicon + + .target( + name: "SwiftLexicon", + dependencies: [ + "Lexicon", + ] + ), + .testTarget( + name: "SwiftLexiconTests", + dependencies: [ + "Hope", + "SwiftLexicon" + ], + resources: [ + .copy("Resources"), + ] + ), + + // MARK: SwiftStandAlone + + .target( + name: "SwiftStandAlone", + dependencies: [ + "Lexicon", + ] + ), + .testTarget( + name: "SwiftStandAloneTests", + dependencies: [ + "Hope", + "SwiftStandAlone" + ], + resources: [ + .copy("Resources"), + ] + ), + + // MARK: KotlinStandAlones + + .target( + name: "KotlinStandAlone", + dependencies: [ + "Lexicon", + ] + ), + .testTarget( + name: "KotlinStandAloneTests", + dependencies: [ + "Hope", + "KotlinStandAlone" + ], + resources: [ + .copy("Resources"), + ] + ), + + // MARK: CSharpStandAlone + + .target( + name: "CSharpStandAlone", + dependencies: [ + "Lexicon", + ] + ), + .testTarget( + name: "CSharpStandAloneTests", + dependencies: [ + "Hope", + "CSharpStandAlone" + ], + resources: [ + .copy("Resources"), + ] + ), + ] ) diff --git a/Sources/CSharpStandAlone/Generator.swift b/Sources/CSharpStandAlone/Generator.swift new file mode 100644 index 0000000..b05b23d --- /dev/null +++ b/Sources/CSharpStandAlone/Generator.swift @@ -0,0 +1,121 @@ +import Lexicon +import UniformTypeIdentifiers + +public enum Generator: CodeGenerator { + + // TODO: prefixes? + + public static let utType = UTType(filenameExtension: "cs", conformingTo: .sourceCode)! + + public static func generate(_ json: Lexicon.Graph.JSON) throws -> Data { + return Data(json.cSharp().utf8) + } +} + +private extension Lexicon.Graph.JSON { + + func cSharp() -> String { + return """ +public interface I_TypeLocalised +{ + string Localised { get; set; } +} + +public interface I_SourceCodeIdentifiable +{ + string Identifier { get; } +} + +public interface I_LexiconType : I_TypeLocalised, I_SourceCodeIdentifiable { } + +public class L_LexiconType : I_LexiconType +{ + public string Identifier { get; private set; } + + public string Localised { get; set; } + + public L_LexiconType(string identifer, string localised = "") + { + Identifier = identifer; + Localised = localised; + } + + public override string ToString() + { + return Identifier; + } +} + +// MARK: generated types + +I_\(name) \(name) = new L_\(name)(nameof(\(name))); + +\(classes.flatMap{ $0.cSharp(prefix: ("L", "I")) }.joined(separator: "\n")) + +""" + } +} + +private extension Lexicon.Graph.Node.Class.JSON { + + // TODO: make this more readable + + func cSharp(prefix: (class: String, protocol: String)) -> [String] { + + guard mixin == nil else { + return [] + } + + var lines: [String] = [] + let T = id.idToClassSuffix + let (L, I) = prefix + + let supertype = supertype? + .replacingOccurrences(of: "_", with: "__") + .replacingOccurrences(of: ".", with: "_") + .replacingOccurrences(of: "__&__", with: ", I_") + + if let protonym = protonym { + lines += """ +public sealed class \(L)_\(T) : \(L)_LexiconType, \(I)_\(T), \(I)_\(protonym.idToClassSuffix) +{ + public \(L)_\(T)(string identifer, string localised = "") : base(identifer, localised) { } +} +""" + } else { + lines += """ +public sealed class \(L)_\(T) : \(L)_LexiconType, \(I)_\(T)\(supertype.map{ ", \(I)_\($0)" } ?? "") +{ + public \(L)_\(T)(string identifer, string localised = "") : base(identifer, localised) { } +} +""" + } + + let line = "public interface \(I)_\(T) : \(I)\(supertype.map{ "_\($0)" } ?? "_LexiconType")" + + lines += line + " {" + + for child in children ?? [] { + let id = "\(id).\(child)" + lines += "\t\(I)_\(id.idToClassSuffix) \(child) => new \(L)_\(id.idToClassSuffix)($\"{Identifier}.{nameof(\(child))}\");" + } + + for (synonym, protonym) in (synonyms?.sortedByLocalizedStandard(by: \.key) ?? []) { + let id = "\(id).\(synonym)" + lines += "\t\(I)_\(id.idToClassSuffix) \(synonym) => new \(L)_\(id.idToClassSuffix)($\"{Identifier}.{nameof(\(protonym))}\");" + } + + lines += "}" + + return lines + } +} + +private extension String { + + var idToClassSuffix: String { + replacingOccurrences(of: "_", with: "__") + .replacingOccurrences(of: ".", with: "_") + .replacingOccurrences(of: "_&_", with: "_") + } +} diff --git a/Sources/LexiconGenerators/List.swift b/Sources/LexiconGenerators/List.swift index d8eb719..15d768d 100644 --- a/Sources/LexiconGenerators/List.swift +++ b/Sources/LexiconGenerators/List.swift @@ -7,17 +7,20 @@ import Collections import SwiftLexicon import SwiftStandAlone import KotlinStandAlone +import CSharpStandAlone public extension Lexicon.Graph.JSON { - - static let generators: OrderedDictionary = [ - - "Swift Library": SwiftLexicon.Generator.self, - - "Swift Stand-Alone": SwiftStandAlone.Generator.self, - - "Kotlin Stand-Alone": KotlinStandAlone.Generator.self, - - "JSON Classes & Mixins": JSONClasses.self, - ] + + static let generators: OrderedDictionary = [ + + "Swift Library": SwiftLexicon.Generator.self, + + "Swift Stand-Alone": SwiftStandAlone.Generator.self, + + "Kotlin Stand-Alone": KotlinStandAlone.Generator.self, + + "C# Stand-Alone": CSharpStandAlone.Generator.self, + + "JSON Classes & Mixins": JSONClasses.self, + ] } diff --git "a/Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" "b/Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" new file mode 100644 index 0000000..9246db3 --- /dev/null +++ "b/Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" @@ -0,0 +1,20 @@ +@_exported import Hope +@_exported import Combine +@_exported import Lexicon +@_exported import CSharpStandAlone + +final class SwiftLexicon™: Hopes { + + func test_generator() async throws { + + var json = try await "test".taskpaper().lexicon().json() + json.date = Date(timeIntervalSinceReferenceDate: 0) + + let code = try Generator.generate(json).string() + + try hope(code) == "test.cs".file().string() + } + + func test_code() throws { + } +} diff --git a/Tests/CSharpStandAloneTests/Resources/test.cs b/Tests/CSharpStandAloneTests/Resources/test.cs new file mode 100644 index 0000000..f99ca59 --- /dev/null +++ b/Tests/CSharpStandAloneTests/Resources/test.cs @@ -0,0 +1,124 @@ +public interface I_TypeLocalised +{ + string Localised { get; set; } +} + +public interface I_SourceCodeIdentifiable +{ + string Identifier { get; } +} + +public interface I_LexiconType : I_TypeLocalised, I_SourceCodeIdentifiable { } + +public class L_LexiconType : I_LexiconType +{ + public string Identifier { get; private set; } + + public string Localised { get; set; } + + public L_LexiconType(string identifer, string localised = "") + { + Identifier = identifer; + Localised = localised; + } + + public override string ToString() + { + return Identifier; + } +} + +// MARK: generated types + +I_test test = new L_test(nameof(test)); + +public sealed class L_test : L_LexiconType, I_test +{ + public L_test(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test : I_LexiconType { + I_test_one one => new L_test_one($"{Identifier}.{nameof(one)}"); + I_test_two two => new L_test_two($"{Identifier}.{nameof(two)}"); + I_test_type type => new L_test_type($"{Identifier}.{nameof(type)}"); +} +public sealed class L_test_one : L_LexiconType, I_test_one, I_test_type_odd +{ + public L_test_one(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_one : I_test_type_odd { + I_test_one_more more => new L_test_one_more($"{Identifier}.{nameof(more)}"); +} +public sealed class L_test_one_more : L_LexiconType, I_test_one_more +{ + public L_test_one_more(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_one_more : I_LexiconType { + I_test_one_more_time time => new L_test_one_more_time($"{Identifier}.{nameof(time)}"); +} +public sealed class L_test_one_more_time : L_LexiconType, I_test_one_more_time, I_test +{ + public L_test_one_more_time(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_one_more_time : I_test { +} +public sealed class L_test_two : L_LexiconType, I_test_two, I_test_type_even +{ + public L_test_two(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_two : I_test_type_even { + I_test_two_timing timing => new L_test_two_timing($"{Identifier}.{nameof(timing)}"); +} +public sealed class L_test_two_timing : L_LexiconType, I_test_two_timing +{ + public L_test_two_timing(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_two_timing : I_LexiconType { +} +public sealed class L_test_type : L_LexiconType, I_test_type +{ + public L_test_type(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_type : I_LexiconType { + I_test_type_even even => new L_test_type_even($"{Identifier}.{nameof(even)}"); + I_test_type_odd odd => new L_test_type_odd($"{Identifier}.{nameof(odd)}"); +} +public sealed class L_test_type_even : L_LexiconType, I_test_type_even +{ + public L_test_type_even(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_type_even : I_LexiconType { + I_test_type_even_no no => new L_test_type_even_no($"{Identifier}.{nameof(no)}"); + I_test_type_even_bad bad => new L_test_type_even_bad($"{Identifier}.{nameof(no.good)}"); +} +public sealed class L_test_type_even_bad : L_LexiconType, I_test_type_even_bad, I_test_type_even_no_good +{ + public L_test_type_even_bad(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_type_even_bad : I_LexiconType { +} +public sealed class L_test_type_even_no : L_LexiconType, I_test_type_even_no +{ + public L_test_type_even_no(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_type_even_no : I_LexiconType { + I_test_type_even_no_good good => new L_test_type_even_no_good($"{Identifier}.{nameof(good)}"); +} +public sealed class L_test_type_even_no_good : L_LexiconType, I_test_type_even_no_good +{ + public L_test_type_even_no_good(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_type_even_no_good : I_LexiconType { +} +public sealed class L_test_type_odd : L_LexiconType, I_test_type_odd +{ + public L_test_type_odd(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_type_odd : I_LexiconType { + I_test_type_odd_good good => new L_test_type_odd_good($"{Identifier}.{nameof(good)}"); +} +public sealed class L_test_type_odd_good : L_LexiconType, I_test_type_odd_good +{ + public L_test_type_odd_good(string identifer, string localised = "") : base(identifer, localised) { } +} +public interface I_test_type_odd_good : I_LexiconType { +} diff --git a/Tests/CSharpStandAloneTests/Resources/test.taskpaper b/Tests/CSharpStandAloneTests/Resources/test.taskpaper new file mode 100644 index 0000000..5a4d0da --- /dev/null +++ b/Tests/CSharpStandAloneTests/Resources/test.taskpaper @@ -0,0 +1,17 @@ +test: + one: + + test.type.odd + more: + time: + + test + two: + + test.type.even + timing: + type: + even: + bad: + = no.good + no: + good: + odd: + good: \ No newline at end of file diff --git a/Tests/CSharpStandAloneTests/util.swift b/Tests/CSharpStandAloneTests/util.swift new file mode 100644 index 0000000..ccc7802 --- /dev/null +++ b/Tests/CSharpStandAloneTests/util.swift @@ -0,0 +1,26 @@ +import Foundation + +extension String { + + func taskpaper() throws -> String { + try "\(self).taskpaper".file().string() + } + + func file() throws -> Data { + guard let url = Bundle.module.url(forResource: "Resources/\(self)", withExtension: nil) else { + throw "Could not find '\(self)'" + } + return try Data(contentsOf: url) + } + + func lexicon() async throws -> Lexicon { + try await Lexicon.from(TaskPaper(self).decode()) + } +} + +extension Data { + + func string(encoding: String.Encoding = .utf8) throws -> String { + try String(data: self, encoding: encoding).try() + } +} From 2cc7ed1305f7e85f1cbdf6b93d9bf679df072526 Mon Sep 17 00:00:00 2001 From: Ste Prescott Date: Sun, 7 Aug 2022 21:41:12 +0100 Subject: [PATCH 2/2] Park --- Sources/CSharpStandAlone/Generator.swift | 84 ++++++------ .../ CSharpStandAlone\342\204\242.swift" | 2 +- Tests/CSharpStandAloneTests/Resources/test.cs | 124 ------------------ 3 files changed, 44 insertions(+), 166 deletions(-) delete mode 100644 Tests/CSharpStandAloneTests/Resources/test.cs diff --git a/Sources/CSharpStandAlone/Generator.swift b/Sources/CSharpStandAlone/Generator.swift index b05b23d..fa47c38 100644 --- a/Sources/CSharpStandAlone/Generator.swift +++ b/Sources/CSharpStandAlone/Generator.swift @@ -16,28 +16,20 @@ private extension Lexicon.Graph.JSON { func cSharp() -> String { return """ -public interface I_TypeLocalised -{ - string Localised { get; set; } -} +global using static \(name.capitalized)Lexicon; -public interface I_SourceCodeIdentifiable +public static class \(name.capitalized)Lexicon { - string Identifier { get; } + public static I\(name.capitalized) \(name) = new L\(name.capitalized)(nameof(\(name))); } -public interface I_LexiconType : I_TypeLocalised, I_SourceCodeIdentifiable { } - -public class L_LexiconType : I_LexiconType +public abstract class LexiconType { - public string Identifier { get; private set; } + protected string Identifier { get; } - public string Localised { get; set; } - - public L_LexiconType(string identifer, string localised = "") + public LexiconType(string identifier) { - Identifier = identifer; - Localised = localised; + Identifier = identifier; } public override string ToString() @@ -48,8 +40,6 @@ public class L_LexiconType : I_LexiconType // MARK: generated types -I_\(name) \(name) = new L_\(name)(nameof(\(name))); - \(classes.flatMap{ $0.cSharp(prefix: ("L", "I")) }.joined(separator: "\n")) """ @@ -67,42 +57,54 @@ private extension Lexicon.Graph.Node.Class.JSON { } var lines: [String] = [] - let T = id.idToClassSuffix + let T = id.split(separator: ".").map{$0.capitalized}.joined().idToClassSuffix let (L, I) = prefix let supertype = supertype? + .split(separator: ".") + .map({$0.capitalized}) + .joined() .replacingOccurrences(of: "_", with: "__") - .replacingOccurrences(of: ".", with: "_") - .replacingOccurrences(of: "__&__", with: ", I_") + .replacingOccurrences(of: ".", with: "") + .replacingOccurrences(of: "__&__", with: ", I") - if let protonym = protonym { - lines += """ -public sealed class \(L)_\(T) : \(L)_LexiconType, \(I)_\(T), \(I)_\(protonym.idToClassSuffix) -{ - public \(L)_\(T)(string identifer, string localised = "") : base(identifer, localised) { } -} -""" + if let protonym = protonym?.split(separator: ".").map({$0.capitalized}).joined().idToClassSuffix { + lines += "public sealed class \(L)\(T) : LexiconType, \(I)\(T), \(I)\(protonym)" + } else { - lines += """ -public sealed class \(L)_\(T) : \(L)_LexiconType, \(I)_\(T)\(supertype.map{ ", \(I)_\($0)" } ?? "") -{ - public \(L)_\(T)(string identifer, string localised = "") : base(identifer, localised) { } -} -""" + lines += "public sealed class \(L)\(T) : LexiconType, \(I)\(T)\(supertype.map{ ", \(I)\($0)" } ?? "")" } - let line = "public interface \(I)_\(T) : \(I)\(supertype.map{ "_\($0)" } ?? "_LexiconType")" + lines += "{" + + for child in children ?? [] { + let id = "\(T).\(child.capitalized)" + lines += "\tpublic \(I)\(id.idToClassSuffix) \(child) => new \(L)\(id.idToClassSuffix)($\"{Identifier}.{nameof(\(child))}\");" + } + + // TODO: Generate vars for interface'd properties + + for (synonym, protonym) in (synonyms?.sortedByLocalizedStandard(by: \.key) ?? []) { + let id = "\(T).\(synonym.capitalized)" + lines += "\tpublic \(I)\(id.idToClassSuffix) \(synonym) => new \(L)\(id.idToClassSuffix)($\"{Identifier}.{nameof(\(protonym))}\");" + } + + lines += "\n\tpublic \(L)\(T)(string identifier) : base(identifier) { }" + + lines += "}" + + lines += "public interface \(I)\(T)\(supertype.map{ " : \(I)\($0)" } ?? "")" - lines += line + " {" + lines += "{" for child in children ?? [] { - let id = "\(id).\(child)" - lines += "\t\(I)_\(id.idToClassSuffix) \(child) => new \(L)_\(id.idToClassSuffix)($\"{Identifier}.{nameof(\(child))}\");" + let id = "\(T).\(child.capitalized)" + lines += "\t\(I)\(id.idToClassSuffix) \(child) { get }" } for (synonym, protonym) in (synonyms?.sortedByLocalizedStandard(by: \.key) ?? []) { - let id = "\(id).\(synonym)" - lines += "\t\(I)_\(id.idToClassSuffix) \(synonym) => new \(L)_\(id.idToClassSuffix)($\"{Identifier}.{nameof(\(protonym))}\");" + let id = "\(T).\(synonym.capitalized)" + lines += "\t\(I)\(id.idToClassSuffix) \(synonym) { get }" } lines += "}" @@ -115,7 +117,7 @@ private extension String { var idToClassSuffix: String { replacingOccurrences(of: "_", with: "__") - .replacingOccurrences(of: ".", with: "_") - .replacingOccurrences(of: "_&_", with: "_") + .replacingOccurrences(of: ".", with: "") + .replacingOccurrences(of: "_&_", with: "") } } diff --git "a/Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" "b/Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" index 9246db3..677fe17 100644 --- "a/Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" +++ "b/Tests/CSharpStandAloneTests/ CSharpStandAlone\342\204\242.swift" @@ -3,7 +3,7 @@ @_exported import Lexicon @_exported import CSharpStandAlone -final class SwiftLexicon™: Hopes { +final class CSharpLexicon™: Hopes { func test_generator() async throws { diff --git a/Tests/CSharpStandAloneTests/Resources/test.cs b/Tests/CSharpStandAloneTests/Resources/test.cs deleted file mode 100644 index f99ca59..0000000 --- a/Tests/CSharpStandAloneTests/Resources/test.cs +++ /dev/null @@ -1,124 +0,0 @@ -public interface I_TypeLocalised -{ - string Localised { get; set; } -} - -public interface I_SourceCodeIdentifiable -{ - string Identifier { get; } -} - -public interface I_LexiconType : I_TypeLocalised, I_SourceCodeIdentifiable { } - -public class L_LexiconType : I_LexiconType -{ - public string Identifier { get; private set; } - - public string Localised { get; set; } - - public L_LexiconType(string identifer, string localised = "") - { - Identifier = identifer; - Localised = localised; - } - - public override string ToString() - { - return Identifier; - } -} - -// MARK: generated types - -I_test test = new L_test(nameof(test)); - -public sealed class L_test : L_LexiconType, I_test -{ - public L_test(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test : I_LexiconType { - I_test_one one => new L_test_one($"{Identifier}.{nameof(one)}"); - I_test_two two => new L_test_two($"{Identifier}.{nameof(two)}"); - I_test_type type => new L_test_type($"{Identifier}.{nameof(type)}"); -} -public sealed class L_test_one : L_LexiconType, I_test_one, I_test_type_odd -{ - public L_test_one(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_one : I_test_type_odd { - I_test_one_more more => new L_test_one_more($"{Identifier}.{nameof(more)}"); -} -public sealed class L_test_one_more : L_LexiconType, I_test_one_more -{ - public L_test_one_more(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_one_more : I_LexiconType { - I_test_one_more_time time => new L_test_one_more_time($"{Identifier}.{nameof(time)}"); -} -public sealed class L_test_one_more_time : L_LexiconType, I_test_one_more_time, I_test -{ - public L_test_one_more_time(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_one_more_time : I_test { -} -public sealed class L_test_two : L_LexiconType, I_test_two, I_test_type_even -{ - public L_test_two(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_two : I_test_type_even { - I_test_two_timing timing => new L_test_two_timing($"{Identifier}.{nameof(timing)}"); -} -public sealed class L_test_two_timing : L_LexiconType, I_test_two_timing -{ - public L_test_two_timing(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_two_timing : I_LexiconType { -} -public sealed class L_test_type : L_LexiconType, I_test_type -{ - public L_test_type(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_type : I_LexiconType { - I_test_type_even even => new L_test_type_even($"{Identifier}.{nameof(even)}"); - I_test_type_odd odd => new L_test_type_odd($"{Identifier}.{nameof(odd)}"); -} -public sealed class L_test_type_even : L_LexiconType, I_test_type_even -{ - public L_test_type_even(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_type_even : I_LexiconType { - I_test_type_even_no no => new L_test_type_even_no($"{Identifier}.{nameof(no)}"); - I_test_type_even_bad bad => new L_test_type_even_bad($"{Identifier}.{nameof(no.good)}"); -} -public sealed class L_test_type_even_bad : L_LexiconType, I_test_type_even_bad, I_test_type_even_no_good -{ - public L_test_type_even_bad(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_type_even_bad : I_LexiconType { -} -public sealed class L_test_type_even_no : L_LexiconType, I_test_type_even_no -{ - public L_test_type_even_no(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_type_even_no : I_LexiconType { - I_test_type_even_no_good good => new L_test_type_even_no_good($"{Identifier}.{nameof(good)}"); -} -public sealed class L_test_type_even_no_good : L_LexiconType, I_test_type_even_no_good -{ - public L_test_type_even_no_good(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_type_even_no_good : I_LexiconType { -} -public sealed class L_test_type_odd : L_LexiconType, I_test_type_odd -{ - public L_test_type_odd(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_type_odd : I_LexiconType { - I_test_type_odd_good good => new L_test_type_odd_good($"{Identifier}.{nameof(good)}"); -} -public sealed class L_test_type_odd_good : L_LexiconType, I_test_type_odd_good -{ - public L_test_type_odd_good(string identifer, string localised = "") : base(identifer, localised) { } -} -public interface I_test_type_odd_good : I_LexiconType { -}