# AppSourceCop Error AS0018
A procedure belonging to the public API cannot be removed
## Description
A procedure that belongs to the public API cannot be removed, because it will break dependent extensions calling this procedure.
## Remarks
Removing or renaming a procedure that belongs to the public API is not allowed, because it will break dependent extensions which are referencing it. It is allowed to remove or rename local or internal procedures.
> NOTE
> Internal procedures are also available for the modules specified in the internalsVisibleTo property in your app.json<../devenv-json-files> file.
## How to fix this diagnostic?
Reverting the change will fix this diagnostic. If removing or renaming the procedure is required, the recommended approach is to mark the procedure with the ../attributes/devenv-obsolete-attribute attribute. In a future version, once all dependent extensions have updated their code to not reference the obsolete procedure, you can remove it or rename it.
## Code examples triggering the rule
### Example 1 - Removing a public procedure
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    procedure MyProcedure()
    begin
    end;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
}
```
In version 2.0, the public procedure MyProcedure has been removed. If a dependent extension referenced this procedure, this will lead to a compilation error similar to `The name 'MyProcedure' does not exist in the current context (AL0118)`.
For example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:
```al
codeunit 50120 AnotherCodeunit
{
    procedure AnotherMethod()
    var
        c: Codeunit MyCodeunit;
    begin
        c.MyProcedure();
    end;
}
```
### Example 2 - Renaming a public procedure
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    procedure MyProcedure()
    begin
        // Business logic
    end;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    procedure MyRenamedProcedure()
    begin
        // Business logic
    end;
}
```
In version 2.0, the public procedure MyProcedure has been renamed to MyRenamedProcedure. If a dependent extension referenced this procedure, this will lead to a compilation error similar to `The name 'MyProcedure' does not exist in the current context (AL0118)`.
## Code examples not triggering the rule
### Example 1 - Removing a local procedure
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    local procedure MyProcedure()
    begin
    end;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
}
```
In version 2.0, the local procedure MyProcedure has been removed. This is not a breaking change because this procedure couldn't be referenced by other extensions.
### Example 2 - Renaming an internal procedure
Version 1.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    internal procedure MyProcedure()
    begin
    end;
}
```
Version 2.0 of the extension:
```al
codeunit 50100 MyCodeunit
{
    internal procedure MyRenamedProcedure()
    begin
    end;
}
```
In version 2.0, the public procedure MyProcedure has been renamed to MyRenamedProcedure. This is not a breaking change because this procedure couldn't be referenced by other extensions.
## Related information
AppSourceCop Analyzer<appsourcecop>
Get Started with AL<../devenv-get-started>
Developing Extensions<../devenv-dev-overview>

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-as0018, 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. https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0018/
