Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILLink analyzer doesn't warn for unknown interpolated string #101733

Closed
sbomer opened this issue Apr 30, 2024 · 1 comment · Fixed by #101752
Closed

ILLink analyzer doesn't warn for unknown interpolated string #101733

sbomer opened this issue Apr 30, 2024 · 1 comment · Fixed by #101752
Assignees
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Milestone

Comments

@sbomer
Copy link
Member

sbomer commented Apr 30, 2024

        public static void Test(string input) {
            var interpolated = $"{input}";
            Type.GetType(input); // Warns as expected: warning IL2057: Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String)'.
            Type.GetType(interpolated); // No warning
        }
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 30, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 30, 2024
@sbomer sbomer added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Apr 30, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@sbomer sbomer self-assigned this Apr 30, 2024
@sbomer sbomer removed untriaged New issue has not been triaged by the area owner needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Apr 30, 2024
@sbomer sbomer added this to the 9.0.0 milestone Apr 30, 2024
sbomer added a commit that referenced this issue May 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Up until now, the analyzer has been set up to return `TopValue`
for operations which are not handled by their own `Visit`
overrides, to avoid producing warnings that are not produced from
ILLink or ILC. This changes the default handling to return
`UnknownValue.Instance`, so that such operations produce warnings
if the return value flows into a location with dataflow
requirements.

Fixes #101733, where the
return value of a string interpolation operation (which doesn't
have special handling in a `Visit` override) was not producing
warnings when passed to `Type.GetType`.
michaelgsharp pushed a commit to michaelgsharp/runtime that referenced this issue May 9, 2024
)

Up until now, the analyzer has been set up to return `TopValue`
for operations which are not handled by their own `Visit`
overrides, to avoid producing warnings that are not produced from
ILLink or ILC. This changes the default handling to return
`UnknownValue.Instance`, so that such operations produce warnings
if the return value flows into a location with dataflow
requirements.

Fixes dotnet#101733, where the
return value of a string interpolation operation (which doesn't
have special handling in a `Visit` override) was not producing
warnings when passed to `Type.GetType`.
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this issue May 30, 2024
)

Up until now, the analyzer has been set up to return `TopValue`
for operations which are not handled by their own `Visit`
overrides, to avoid producing warnings that are not produced from
ILLink or ILC. This changes the default handling to return
`UnknownValue.Instance`, so that such operations produce warnings
if the return value flows into a location with dataflow
requirements.

Fixes dotnet#101733, where the
return value of a string interpolation operation (which doesn't
have special handling in a `Visit` override) was not producing
warnings when passed to `Type.GetType`.
@github-actions github-actions bot locked and limited conversation to collaborators Jun 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant