Recent Commits to RefactoringToJQuery:master


CodeContracts break encapsulation and Resharper 5.0 is blissfully unaware of them

Seems I have to make my helper methods public if I want to use them within a code contract, but I avoid this by defining a property with the private setter to end up with the Contract.Requires<TException>(…) implementation below:

Code Snippet
  1. public AbstractTrade Trade
  2. {
  3.     private set { _trade = value; }
  4.     get { return _trade; }
  5. }
  7. public void Execute()
  8. {
  9.     Contract.Requires<TradingServiceException>(Trade.IsValid(),
  10.                                                "Trade execution failed");
  11.     if (TradeExecutedEvent != null)
  12.     {
  13.         TradeExecutedEvent(this, new TradeEventArgs(Trade));
  14.     }

C:\Sandbox\Pricing\CommodityServer\TradingService\TradeManager.cs(24,13): error CC1038: Member 'Zainco.Commodities.TradingService.TradeManager.get_Trade' has less visibility than the enclosing method 'Zainco.Commodities.TradingService.TradeManager.Execute'.
C:\Sandbox\Pricing\CommodityServer\TradingService\TradeManager.cs(24,13): warning CC1036: Detected call to method 'Zainco.Commodities.Interfaces.AbstractTrade.IsValid' without [Pure] in contracts of method 'Zainco.Commodities.TradingService.TradeManager.Execute'.
  elapsed time: 294.0169ms

No comments:

Test driving ASP.NET MVC 5 with the Entity Framework Code First

The great advantage of MVC Code First is the automated code generation tools. We took a test drive of these features by developing a small ...