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

Usage of dynamic in WebAPI #1434

Open
xPaw opened this issue Sep 19, 2024 · 2 comments
Open

Usage of dynamic in WebAPI #1434

xPaw opened this issue Sep 19, 2024 · 2 comments

Comments

@xPaw
Copy link
Member

xPaw commented Sep 19, 2024

The API allows doing stuff like this:

dynamic steamNews = WebAPI.GetInterface( "ISteamNews" )
steamNews.GetNewsForApp002( appid: 730, maxlength: 100, count: 5 );

I always found this odd however, but since we can't realistically generate API methods like protobufs, I'm not sure what's a better way of doing things here besides just using the CallAsync which accepts method as string and parameters as args object (which the dynamic object parses into anyway).

One way of fixing this could be creating a source generator which replicates this functionality but without usage of dynamic.

@xPaw
Copy link
Member Author

xPaw commented Sep 26, 2024

I think I would go with removing dynamic support, but I'd like to support #1438 first, to make migrating for a lot of web apis nicer.

@JustArchi
Copy link
Contributor

JustArchi commented Nov 7, 2024

dynamic is evil, since there are no compile-time guarantees that you're even doing the right thing, i.e. using correct number of parameters and likewise.

I used it initially in ASF but quickly discovered how much of headaches it gives me, moved to CallAsync() soon enough.

Maybe obsoleting GetInterface for several versions first is a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants