ViewBag analyzer
See original GitHub issueI would like to suggest a new analyzer. An analyzer to point out the usage of ViewBag and replace it with an model
Before:
MyController.cs
ViewBag.Message = "Hello World";
After:
MyModel.cs
public string Message { get; set; }
MyController.cs
model.Message = "Hello World;"
Why I think this is useful? ViewBag is a dynamic property and you will only catch errors at runtime making your code error prone.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ViewBag in ASP.NET MVC
The ViewBag in ASP.NET MVC is used to transfer temporary data (which is not included in the model) from the controller to the...
Read more >Analyzing ASP.NET MVC Projects with Roslyn
I am currently working on a static source code analyzer for ASP. ... however in MVC projects, it is common to use ViewBag...
Read more >Analyzers For ASP.NET Core In .NET 6
Analyzers are tools that analyze source code and provide feedback to developers in the form of warnings and suggestions for improvement. In ASP....
Read more >viewdata and viewbag in asp net mvc - YouTube
viewdata and viewbag in asp net mvc. ... Excel Data Analysis Made Easy: Transform Your Data Into Insights. IBU Data Simplified New 592...
Read more >Rule S5770: View data dictionaries should be replaced by models
An analyzer to point out the usage of ViewBag and replace it with an model Expected behavior MyModel.cs public string Message { get;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If this is for AspNetCore there is the official analyzer
There is also AspNetCoreAnalyzers.
@kidchenko It probably wouldn’t make sense for StyleCop Analyzers, but would make sense for one of the other projects linked above. If you are interested in contributing, I would suggest opening an issue on those to check if the project would use it. 👍