{"title":"AppSourceCop Error AS0102","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0102/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0102, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0102","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"It is not allowed to add a return value to a publicly exposed procedure, because it might break dependent extensions at runtime.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"AppSourceCop Error AS0102","slug":"appsourcecop-error-as0102","at":0,"chars":3505},{"level":2,"title":"Description","slug":"description","at":69,"chars":144},{"level":2,"title":"Remarks","slug":"remarks","at":213,"chars":348},{"level":2,"title":"How to fix this diagnostic?","slug":"how-to-fix-this-diagnostic","at":561,"chars":417},{"level":2,"title":"Code examples triggering the rule","slug":"code-examples-triggering-the-rule","at":978,"chars":1370},{"level":3,"title":"Example 1 - Adding a return type to a procedure","slug":"example-1---adding-a-return-type-to-a-procedure","at":1247,"chars":536},{"level":3,"title":"Example 2 - Adding a TryFunction attribute to a procedure","slug":"example-2---adding-a-tryfunction-attribute-to-a-procedure","at":1783,"chars":565},{"level":2,"title":"Code examples not triggering the rule","slug":"code-examples-not-triggering-the-rule","at":2348,"chars":1010},{"level":3,"title":"Example 1 - Adding a TryFunction attribute to a method returning a boolean","slug":"example-1---adding-a-tryfunction-attribute-to-a-method-returning-a-boolean","at":2389,"chars":483},{"level":3,"title":"Example 2 - Removing a TryFunction attribute and adding a boolean return type","slug":"example-2---removing-a-tryfunction-attribute-and-adding-a-boolean-return-type","at":2872,"chars":486},{"level":2,"title":"Related information","slug":"related-information","at":3358,"chars":147}],"text":"# AppSourceCop Error AS0102\nCannot add a return value to a procedure\n## Description\nIt is not allowed to add a return value to a publicly exposed procedure, because it might break dependent extensions at runtime.\n## Remarks\nThis rules validates that a return value has not been added to a publicly exposed procedures. Other changes on the return types of procedures are validated by appsourcecop-as0023.\n> NOTE\n> This rule also covers the cases related to the ../attributes/devenv-tryfunction-attribute attribute which implicitly defines a Boolean return type.\n## How to fix this diagnostic?\nReverting the change will fix this diagnostic. If changing the return type is required, the recommended approach is to mark the procedure with the ../attributes/devenv-obsolete-attribute attribute and introduce a new one with the desired return type. In a future version, once all dependent extensions have updated their code to not reference the obsolete procedure, you can remove it.\n## Code examples triggering the rule\nIn the following examples, the version 1.0 of the extension defines a procedure which does not have a return type.\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure()\n    begin\n    end;\n}\n```\n### Example 1 - Adding a return type to a procedure\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure(): Boolean\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the procedure MyProcedure is now returning a boolean. It does not break the compilation of dependent extensions because they were not consuming the return type of the procedure. However, this change will break the runtime behavior of dependent extensions that referencing this procedure and that have not been recompiled.\n### Example 2 - Adding a TryFunction attribute to a procedure\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [TryFunction]\n    procedure MyProcedure()\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the procedure MyProcedure is now implictly returning a boolean. It does not break the compilation of dependent extensions because they were not consuming the return type of the procedure. However, this change will break the runtime behavior of dependent extensions that referencing this procedure and that have not been recompiled.\n## Code examples not triggering the rule\n### Example 1 - Adding a TryFunction attribute to a method returning a boolean\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure() : Boolean\n    begin\n        exit(true);\n    end;\n}\n```\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [TryFunction]\n    procedure MyProcedure()\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the procedure is now implicitly returning a Boolean. The return type has not changed.\n### Example 2 - Removing a TryFunction attribute and adding a boolean return type\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [TryFunction]\n    procedure MyProcedure()\n    begin\n        exit(true);\n    end;\n}\n```\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure() : Boolean\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the procedure is now explicitly returning a Boolean. The return type has not changed.\n## Related information\nAppSourceCop Analyzer<appsourcecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}