From c8f42a0bfc800d4871e899c582c506dcacccde95 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 21 Jan 2021 05:56:17 -0800 Subject: [PATCH] Support for obsolete/error/warning on property declaration --- BeefLibs/corlib/src/Attribute.bf | 8 ++++---- IDEHelper/Compiler/BfModule.cpp | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/BeefLibs/corlib/src/Attribute.bf b/BeefLibs/corlib/src/Attribute.bf index caa8150d..3a16088d 100644 --- a/BeefLibs/corlib/src/Attribute.bf +++ b/BeefLibs/corlib/src/Attribute.bf @@ -245,7 +245,7 @@ namespace System } [Obsolete("Use [CallingConvention(.Stdcall)]", false)] - [AttributeUsage(.Method | .Constructor | .Delegate | .Function)] + [AttributeUsage(.Method | .Constructor | .Delegate | .Function | .Property)] public struct StdCallAttribute : Attribute { @@ -478,7 +478,7 @@ namespace System { } - [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias | .Interface)] + [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias | .Interface | .Property)] public struct ObsoleteAttribute : Attribute { public this(bool isError) @@ -498,7 +498,7 @@ namespace System } - [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias)] + [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias | .Property)] public struct ErrorAttribute : Attribute { public this(String error) @@ -507,7 +507,7 @@ namespace System } } - [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias)] + [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias | .Property)] public struct WarnAttribute : Attribute { public this(String error) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 9acb919e..249d7735 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -20890,7 +20890,20 @@ void BfModule::GetMethodCustomAttributes(BfMethodInstance* methodInstance) { if (methodInstance->GetMethodInfoEx()->mMethodCustomAttributes == NULL) methodInstance->mMethodInfoEx->mMethodCustomAttributes = new BfMethodCustomAttributes(); - methodInstance->mMethodInfoEx->mMethodCustomAttributes->mCustomAttributes = GetCustomAttributes(attributeDirective, attrTarget); + methodInstance->mMethodInfoEx->mMethodCustomAttributes->mCustomAttributes = GetCustomAttributes(attributeDirective, attrTarget); + } + + if ((propertyMethodDeclaration != NULL) && (propertyMethodDeclaration->mPropertyDeclaration->mAttributes != NULL)) + { + if (methodInstance->GetMethodInfoEx()->mMethodCustomAttributes != NULL) + { + GetCustomAttributes(methodInstance->mMethodInfoEx->mMethodCustomAttributes->mCustomAttributes, propertyMethodDeclaration->mPropertyDeclaration->mAttributes, attrTarget); + } + else + { + methodInstance->GetMethodInfoEx()->mMethodCustomAttributes = new BfMethodCustomAttributes(); + methodInstance->mMethodInfoEx->mMethodCustomAttributes->mCustomAttributes = GetCustomAttributes(propertyMethodDeclaration->mPropertyDeclaration->mAttributes, attrTarget); + } } customAttributes = methodInstance->GetCustomAttributes();