Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #106 from bojanrajkovic/custom-attribute-types
Browse files Browse the repository at this point in the history
Compilation: Fix custom attributes using types defined in the workbook
  • Loading branch information
abock authored Nov 29, 2017
2 parents 684af07 + 8841574 commit b64cced
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public unsafe AssemblyDefinition Patch (

/// <summary>
/// Search the target byte array for an 8-byte magic value, then rewrite the string prefixed
/// by the magic value. Strings are terminated by '\0', '.', or '>'. This is very aggressive
/// by the magic value. Strings are terminated by '\0', '.', '>', or '+'. This is very aggressive
/// and has nothing to do with the PE format, so the magic value should be very unique!
/// </summary>
static unsafe void Patch (byte [] target, byte [] magicBytes, PatchHandler patchHandler)
Expand All @@ -131,7 +131,7 @@ static unsafe void Patch (byte [] target, byte [] magicBytes, PatchHandler patch
var length = 8;
while (true) {
var b = target [i + length];
if (b == 0 || b == '.' || b == '>')
if (b == 0 || b == '.' || b == '>' || b == '+')
break;
length++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public void RemoveSubmission (DocumentId documentId, DocumentId nextDocumentId)
workspace.RemoveProject (project.Id);
}

const string assemblyNamePrefix = "🐵 XIS";
const string assemblyNamePrefix = "🐵🐻";
static readonly byte [] assemblyNamePrefixBytes = Encoding.UTF8.GetBytes (assemblyNamePrefix);

ProjectInfo CreateSubmissionProjectInfo ()
Expand Down
26 changes: 26 additions & 0 deletions Tests/Workbooks/Regression/Custom Attribute Types.workbook
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
uti: com.xamarin.workbook
id: 60f1e237-ac68-4dd6-8069-4f1ab3049a28
title: Custom Attribute Types
platforms:
- Console
---

```csharp
public class MyCustomAttribute : Attribute
{
public Type TestType { get; set; }
public MyCustomAttribute(Type type) => TestType = type;
}

public class Foo {}

public class Class
{
[MyCustom(typeof(Foo))]
public string Foo { get; set; }
}

typeof(Class).GetMember("Foo").First().GetCustomAttributes(inherit: false)
.OfType<MyCustomAttribute>().First().TestType.AssemblyQualifiedName;
```

0 comments on commit b64cced

Please sign in to comment.