private static string GetTypeFromTypeReference(TypeReferenceRaw typeReference, string packagePrefix) { return(typeReference.IsBuiltInType ? UnityTypeMappings.BuiltInSchemaTypeToUnityNativeType[typeReference.TypeName] : string.Format("global::{0}{1}", packagePrefix, Formatting.CapitaliseQualifiedNameParts(typeReference.TypeName))); }
public UnityTypeDetails(UnityTypeDefinition typeDefinition) { CapitalisedName = Formatting.SnakeCaseToCapitalisedCamelCase(typeDefinition.Name); CamelCaseName = Formatting.SnakeCaseToCamelCase(typeDefinition.Name); FullyQualifiedSpatialTypeName = "global::" + Formatting.CapitaliseQualifiedNameParts(typeDefinition.QualifiedName); FullyQualifiedTypeName = "global::" + Formatting.CapitaliseQualifiedNameParts(typeDefinition.QualifiedName); }
protected GeneratorInputDetails(string package, QualifiedDefinition qualifiedDefinition) : base(qualifiedDefinition) { Namespace = Formatting.CapitaliseQualifiedNameParts(package); NamespacePath = Formatting.GetNamespacePath(package); QualifiedName = qualifiedDefinition.QualifiedName; FullyQualifiedName = DetailsUtils.GetCapitalisedFqnTypename(qualifiedDefinition.QualifiedName); }
public UnityCommandDetails(UnityComponentDefinition.UnityCommandDefinition commandDefinition) { CommandName = Formatting.SnakeCaseToCapitalisedCamelCase(commandDefinition.Name); CamelCaseTypeName = "spatialOS" + Formatting.QualifiedNameToCapitalisedCamelCase(commandDefinition.Name); RequestType = "global::" + UnityTypeMappings.PackagePrefix + Formatting.CapitaliseQualifiedNameParts(commandDefinition.RequestType.typeDefinition.QualifiedName); ResponseType = "global::" + UnityTypeMappings.PackagePrefix + Formatting.CapitaliseQualifiedNameParts(commandDefinition.ResponseType.typeDefinition.QualifiedName); }
public UnityEventDetails(UnityComponentDefinition.UnityEventDefinition eventDefinition) { EventName = Formatting.SnakeCaseToCapitalisedCamelCase(eventDefinition.Name); CamelCaseTypeName = Formatting.SnakeCaseToCamelCase(eventDefinition.Name); var payloadTypeName = eventDefinition.RawType.TypeName; FullyQualifiedPayloadTypeName = "global::" + UnityTypeMappings.PackagePrefix + Formatting.CapitaliseQualifiedNameParts(payloadTypeName); }
public UnityComponentDetails(UnityComponentDefinition componentDefinition) { ComponentName = Formatting.QualifiedNameToCapitalisedCamelCase(componentDefinition.Name); TypeName = "SpatialOS" + ComponentName; CamelCaseTypeName = "spatialOS" + ComponentName; FullyQualifiedSpatialTypeName = "global::" + Formatting.CapitaliseQualifiedNameParts(componentDefinition.QualifiedName); IsBlittable = componentDefinition.IsBlittable; }
public UnityTypeDetails(string package, TypeDefinition typeDefinitionRaw) { Package = package; CapitalisedName = typeDefinitionRaw.Name; CamelCaseName = Formatting.PascalCaseToCamelCase(CapitalisedName); FullyQualifiedTypeName = $"global::{Formatting.CapitaliseQualifiedNameParts(typeDefinitionRaw.QualifiedName)}"; raw = typeDefinitionRaw; }
public UnityEnumDetails(EnumDefinitionRaw enumDefinition) { PascalCaseName = Formatting.SnakeCaseToCapitalisedCamelCase(enumDefinition.name); CamelCaseName = Formatting.SnakeCaseToCamelCase(enumDefinition.name); FullyQualifiedSpatialTypeName = "global::" + Formatting.CapitaliseQualifiedNameParts(enumDefinition.qualifiedName); FullyQualifiedTypeName = "global::" + UnityTypeMappings.PackagePrefix + Formatting.CapitaliseQualifiedNameParts(enumDefinition.qualifiedName); }
public UnityTypeDetails(TypeDefinitionRaw typeDefinitionRaw) { CapitalisedName = typeDefinitionRaw.Identifier.Name; CamelCaseName = Formatting.PascalCaseToCamelCase(CapitalisedName); FullyQualifiedTypeName = $"global::{Formatting.CapitaliseQualifiedNameParts(typeDefinitionRaw.Identifier.QualifiedName)}"; Identifier = typeDefinitionRaw.Identifier; raw = typeDefinitionRaw; }
public static string GetCapitalisedFqnTypename(string qualifiedTypeName) { if (UnityTypeMappings.BuiltInSchemaTypeToUnityNativeType.TryGetValue(qualifiedTypeName, out var fqn)) { return(fqn); } return ($"global::{Formatting.CapitaliseQualifiedNameParts(qualifiedTypeName)}"); }
public SingleGenerationJob(string outputDir, UnitySchemaFile schemaFile, IFileSystem fileSystem, HashSet <string> enumSet) : base( outputDir, fileSystem) { InputFiles = new List <string> { schemaFile.CompletePath }; OutputFiles = new List <string>(); relativeOutputPath = Formatting.GetNamespacePath(schemaFile.Package); package = Formatting.CapitaliseQualifiedNameParts(schemaFile.Package); // Filter out the data types like PositionData or TransformData. We don't want to generate these. typesToGenerate = schemaFile.TypeDefinitions.Where(type => schemaFile.ComponentDefinitions.Select(component => component.DataDefinition.typeDefinition.Name) .All(componentDataName => componentDataName != type.Name)).ToList(); foreach (var unityTypeDefinition in typesToGenerate) { var fileName = Path.ChangeExtension(unityTypeDefinition.Name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } componentsToGenerate = schemaFile.ComponentDefinitions; foreach (var unityComponentDefinition in componentsToGenerate) { var fileName = Path.ChangeExtension(unityComponentDefinition.Name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); fileName = Path.ChangeExtension(unityComponentDefinition.Name + "Translation", fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } enumsToGenerate = new List <EnumDefinitionRaw>(); enumsToGenerate.AddRange(schemaFile.EnumDefinitions); foreach (var unityEnum in enumsToGenerate) { var fileName = Path.ChangeExtension(unityEnum.name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } this.enumSet = enumSet; }
public SingleGenerationJob(string outputDir, UnitySchemaFile schemaFile, IFileSystem fileSystem, HashSet <string> enumSet) : base( outputDir, fileSystem) { InputFiles = new List <string> { schemaFile.CompletePath }; OutputFiles = new List <string>(); relativeOutputPath = Formatting.GetNamespacePath(schemaFile.Package); package = Formatting.CapitaliseQualifiedNameParts(schemaFile.Package); typesToGenerate = SelectTypesToGenerate(schemaFile); foreach (var unityTypeDefinition in typesToGenerate) { var fileName = Path.ChangeExtension(unityTypeDefinition.Name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } componentsToGenerate = schemaFile.ComponentDefinitions; foreach (var unityComponentDefinition in componentsToGenerate) { var fileName = Path.ChangeExtension(unityComponentDefinition.Name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); fileName = Path.ChangeExtension(unityComponentDefinition.Name + "Translation", fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); fileName = Path.ChangeExtension($"{unityComponentDefinition.Name}Providers", fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } enumsToGenerate = new List <EnumDefinitionRaw>(); enumsToGenerate.AddRange(schemaFile.EnumDefinitions); foreach (var unityEnum in enumsToGenerate) { var fileName = Path.ChangeExtension(unityEnum.name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } this.enumSet = enumSet; }
public SingleGenerationJob(string outputDir, UnitySchemaFile schemaFile, IFileSystem fileSystem, HashSet <string> enumSet) : base( outputDir, fileSystem) { InputFiles = new List <string> { schemaFile.CompletePath }; OutputFiles = new List <string>(); relativeOutputPath = Formatting.GetNamespacePath(schemaFile.Package); package = Formatting.CapitaliseQualifiedNameParts(schemaFile.Package); typesToGenerate = SelectTypesToGenerate(schemaFile); foreach (var unityTypeDefinition in typesToGenerate) { var fileName = Path.ChangeExtension(unityTypeDefinition.Name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } componentsToGenerate = schemaFile.ComponentDefinitions; foreach (var component in componentsToGenerate) { OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension(component.Name, fileExtension))); if (component.CommandDefinitions.Count > 0) { OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}CommandPayloads", fileExtension))); OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}CommandComponents", fileExtension))); OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}CommandStorage", fileExtension))); } if (component.EventDefinitions.Count > 0) { OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}Events", fileExtension))); } OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}Translation", fileExtension))); OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}Providers", fileExtension))); OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}GameObjectComponentDispatcher", fileExtension))); OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}ReaderWriter", fileExtension))); if (component.CommandDefinitions.Count > 0) { OutputFiles.Add(Path.Combine(relativeOutputPath, Path.ChangeExtension($"{component.Name}MonoBehaviourCommandHandlers", fileExtension))); } } enumsToGenerate = new List <EnumDefinitionRaw>(); enumsToGenerate.AddRange(schemaFile.EnumDefinitions); foreach (var unityEnum in enumsToGenerate) { var fileName = Path.ChangeExtension(unityEnum.name, fileExtension); OutputFiles.Add(Path.Combine(relativeOutputPath, fileName)); } this.enumSet = enumSet; }
private static string GetFullyQualifiedSpatialTypeName(string typeName) { return("global::" + Formatting.CapitaliseQualifiedNameParts(typeName)); }
private static string GetFullyQualifiedGeneratedTypeName(string typeName) { return("global::Generated." + Formatting.CapitaliseQualifiedNameParts(typeName)); }
public void CapitaliseQualifiedNameParts_has_correct_behaviour(string input, string expectedOutput) { var output = Formatting.CapitaliseQualifiedNameParts(input); Assert.AreEqual(expectedOutput, output); }
public static string GetCapitalisedFqnTypename(string qualifiedTypeName) { return($"global::{Formatting.CapitaliseQualifiedNameParts(qualifiedTypeName)}"); }
public GenerationTarget(T content, string package) { Content = content; Package = Formatting.CapitaliseQualifiedNameParts(package); OutputPath = Formatting.GetNamespacePath(package); }