Skip to content

Commit

Permalink
Actually apply FieldOffsetAttribute, migrate to .net 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Byass committed Jan 22, 2021
1 parent a4cb018 commit c83800d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 5.0.100
- name: Install dependencies
run: dotnet restore
- name: Build - Windows x64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 5.0.100
- name: Install dependencies
run: dotnet restore
- name: Build - Common Lib
Expand Down
5 changes: 5 additions & 0 deletions Cpp2IL/AssemblyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ private static List<CppMethodData> ProcessTypeContents(Il2CppMetadata metadata,
var fieldName = metadata.GetStringFromIndex(fieldDef.nameIndex);
var fieldTypeRef = Utils.ImportTypeInto(ilTypeDefinition, fieldType, cppAssembly, metadata);

var fieldOffsetAttributeInst = new CustomAttribute(ilTypeDefinition.Module.ImportReference(fieldOffsetAttribute));
fieldOffsetAttributeInst.Fields.Add(new CustomAttributeNamedArgument("Offset", new CustomAttributeArgument(stringType, $"0x{fieldOffset:X}")));

var fieldDefinition = new FieldDefinition(fieldName, (FieldAttributes) fieldType.attrs, fieldTypeRef);
fieldDefinition.CustomAttributes.Add(fieldOffsetAttributeInst);

ilTypeDefinition.Fields.Add(fieldDefinition);

//Field default values
Expand Down
2 changes: 1 addition & 1 deletion Cpp2IL/Cpp2IL.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>8</LangVersion>
<Nullable>annotations</Nullable>
Expand Down

0 comments on commit c83800d

Please sign in to comment.