Skip to content

DacFx gives false-positive constant warning if source service or a contract is a variable in BEGIN DIALOG CONVERSATION statement #326

@IVNSTN

Description

@IVNSTN
  • SqlPackage or DacFx Version: SSDT 16.0.62205.05200
  • .NET Framework (Windows-only) or .NET Core: 4.8 / 3.1
  • Environment (local platform and source/target platforms)
    • Windows 10
    • VS 2019 16.11.26

DacFx shows warnings about unresolved references to ServiceBroker services and/or contracts if they are variables in a statement. Using variables in mentioned places is a valid syntax, warnings smell like false-positive.
They cannot be fixed (unless rewritten into hardcoded links to services and contracts existing in the project) thus we have to disable such warnings on specific files so we can keep enabled option "Treat warnings as errors" on the whole project.

Steps to Reproduce:

  1. Include into sqlproj a stored procedure with BEGIN DIALOG CONVERSATION statement
  2. Replace service and contract links with variables (which is a valid syntax)
  3. See warnings about unresolved references

Sample code:

CREATE PROCEDURE dbo.SendOnConversation
AS
BEGIN
    DECLARE
        @Handle          UNIQUEIDENTIFIER
        , @SourceService VARCHAR(128)
        , @TargetService VARCHAR(128)
        , @ContractName  VARCHAR(128);

    -- some code with variable initialization --

    BEGIN DIALOG CONVERSATION @Handle
        FROM SERVICE @SourceService
        TO SERVICE @TargetService
        ON CONTRACT @ContractName
        WITH
            LIFETIME = 604800
            , ENCRYPTION = OFF;
END;

Warnings:
image

Note, it does not show warning on target service link which is a variable as well.

Did this occur in prior versions? If not - which version(s) did it work in?
no such version

PS
Speaking of SDK-style projects: if this is not fixed then one'd still have to mention all such files in the .sqlproj to put <SuppressTSqlWarnings>71502</SuppressTSqlWarnings> for hiding warnings purpose.

(DacFx/SqlPackage/SSMS/Azure Data Studio)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions