This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from bojanrajkovic/custom-attribute-types
Compilation: Fix custom attributes using types defined in the workbook
- Loading branch information
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Tests/Workbooks/Regression/Custom Attribute Types.workbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
``` |