public SDKClass() { UsedNamespaces.Add("UE4.EmptyGame"); UsedNamespaces.Add("UE4.EmptyGame.Memory"); UsedNamespaces.Add("UE4.EmptyGame.UnrealClasses"); UsedNamespaces.Add("UE4.EmptyGame.UnrealStructures"); }
public SDKClass() { UsedNamespaces.Add("ConanExiles"); UsedNamespaces.Add("ConanExiles.Memory"); UsedNamespaces.Add("ConanExiles.UnrealClasses"); UsedNamespaces.Add("ConanExiles.UnrealStructures"); }
public void TestConvertSequentialBuilderClass() { var(compilation, classDeclarationSyntax) = PrepareData(@" using SequentialBuilder.Attributes; using System; [SequentialBuilder] class TestClass { private int field1; }"); var actual = classDeclarationSyntax.TryConvertToBuilder(compilation); actual.Should().NotBeNull(); actual.Should().BeOfType <SequentialBuilderClass>(); actual !.Name.Should().Be("TestClass"); actual !.UsedNamespaces.Should().BeEquivalentTo("SequentialBuilder.Attributes", "System"); }
public override string GetGeneratedCode() { var interfaces = GetFields().Select(x => new SequentialBuilderInterface(Name, x)).ToArray(); var interfacesImplementationString = string.Join(", ", interfaces.Select(x => $"{Name}.{x.Name}")); var usedNamespaceString = string.Join(Environment.NewLine, UsedNamespaces.Select(x => $"using {x};")); return($@" {usedNamespaceString} using System; namespace {Namespace} {{ public partial class {Name} : {interfacesImplementationString} {{ {GenerateMethods(interfaces)} }} }} "); }
/// <summary> /// Resolves given reference to a resource to a qualified name /// </summary> /// <param name="prefix">Namespace in the reference</param> /// <param name="className">Class in the reference</param> /// <param name="trieElementInfos">List of resource files entries - possible targets of this reference</param> /// <returns>Resolved reference</returns> protected CodeReferenceInfo TryResolve(string prefix, string className, List <CodeReferenceInfo> trieElementInfos) { CodeReferenceInfo info = null; if (string.IsNullOrEmpty(prefix)) // no namespace // get namespace where this class belongs { UsedNamespaceItem item = UsedNamespaces.ResolveNewReference(className, Project); if (item != null) // namespace found { info = GetInfoWithNamespace(trieElementInfos, item.Namespace); } } else { string aliasNamespace = UsedNamespaces.GetNamespace(prefix); // suppose prefix is alias - try get actual namespace if (!string.IsNullOrEmpty(aliasNamespace)) // really, it was just alias { info = GetInfoWithNamespace(trieElementInfos, aliasNamespace); } else // no, it was full name of namespace { info = GetInfoWithNamespace(trieElementInfos, prefix); if (info == null) // try adding prefix to the class name - in case prefix is just part of namespace { UsedNamespaceItem item = UsedNamespaces.ResolveNewReference(prefix + "." + className, Project); if (item != null) { info = GetInfoWithNamespace(trieElementInfos, item.Namespace + "." + prefix); } } } } return(info); }
public void AddProperty(UProperty property, string classname = null, string name = null) { string propname = name; if (propname == null) propname = SDKUtilities.CleanupName(property.Name); if (classname == null) classname = property.Class.Name; if (Properties.ContainsKey(propname)) { int counter = 1; while (Properties.ContainsKey(propname + counter)) counter++; propname += counter; } bool supported = true; var prop = new SDKProperty() { Name = propname, ElementSize = property.ElementSize, IsTArray = classname == "ArrayProperty", Offset = property.Offset, Type = classname, }; switch (classname) { case "AssetObjectProperty": case "WeakObjectProperty": case "MulticastDelegateProperty": { supported = false; break; } case "ArrayProperty": { var arrayProp = property.Cast<UArrayProperty>(); prop.SubType = property.Cast<UArrayProperty>().Inner.Class.Name; switch (prop.SubType) { case "NameProperty": { prop.ArraySubType = "FName"; break; } case "ObjectProperty": { prop.SubElementSize = arrayProp.Inner.Cast<UObjectProperty>().PropertyClass.PropertySize; prop.ArraySubType = arrayProp.Inner.Cast<UObjectProperty>().PropertyClass.NameWithPrefix; var nsProp = SDKUtilities.GetPackageName(arrayProp.Inner.Cast<UObjectProperty>().PropertyClass); if (!UsedNamespaces.Contains(nsProp)) UsedNamespaces.Add(nsProp); break; } case "StructProperty": { prop.ArraySubType = arrayProp.Inner.Cast<UStructProperty>().Struct.NameWithPrefix; prop.SubElementSize = arrayProp.Inner.Cast<UStructProperty>().Struct.PropertySize; var nsProp = SDKUtilities.GetPackageName(arrayProp.Inner.Cast<UStructProperty>().Struct.Cast<UClass>()); if (!UsedNamespaces.Contains(nsProp)) UsedNamespaces.Add(nsProp); break; } } break; } case "BoolProperty": { var p = property.Cast<UBoolProperty>(); prop.BoolFieldMask = p.FieldMask; prop.BoolByteMask = p.ByteMask; prop.BitMask = p.BitMask; prop.BoolOffset = p.ByteOffset; break; } case "ObjectProperty": { prop.SubType = property.Cast<UObjectProperty>().PropertyClass.NameWithPrefix; prop.SubElementSize = property.Cast<UObjectProperty>().PropertyClass.PropertySize; var nsProp = SDKUtilities.GetPackageName(property.Cast<UObjectProperty>().PropertyClass); if (!UsedNamespaces.Contains(nsProp)) UsedNamespaces.Add(nsProp); break; } case "StructProperty": { prop.SubType = property.Cast<UStructProperty>().Struct.NameWithPrefix; prop.SubElementSize = property.Cast<UStructProperty>().Struct.PropertySize; var nsProp = SDKUtilities.GetPackageName(property.Cast<UStructProperty>().Struct.Cast<UClass>()); if (!UsedNamespaces.Contains(nsProp)) UsedNamespaces.Add(nsProp); break; } } if (supported) { Properties.Add(propname, prop); } }