This is a migrated thread and some comments may be shown as answers.

Getting an false error in MVC 2 template

6 Answers 103 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 22 May 2010, 02:32 AM
I was studying MVC  tonight with VS 2010.  I create MVC 2 project, and did some examples.  When I press F5 Just Code is reporting a red error: This class must implement the interface member 'MvcChapter2a.Models.IMembershipService.CreateUser(?,?,?)'  in the file AccountControllerTest.cs.  VS 2010 MVC project template generates this file. 

The project still runs correctly per the book.  I am working out off the book ASP.net MVC 1.0 Quickly by Maarten Ballauw.  Still waiting on good version 2.0 book.

David

6 Answers, 1 is accepted

Sort by
0
Svetlozar
Telerik team
answered on 24 May 2010, 10:33 AM
Hi David ,

Thank you for your feedback.

We had some issues with the VB interface implementation analysis that are already fixed. You haven't specify which language you use and I guess that would be C# (the examples in the book you read are in C#). Please let me know if you use VB.NET.

We haven't encountered problems in C# interface analysis so far. Unfortunately we don't have the book to see the code snippet. We will really appreciate if you could send us a sample project where the problem occurs.        
Sorry for the inconvenience.

Greetings,
Svetlozar Angelov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David
Top achievements
Rank 1
answered on 25 May 2010, 12:00 AM
Hi Svetlozar, yes It is C#. 

This code is MS generated from the MVC 2 template:  The solution runs good with no problem. 

Steps to recreate problem:
File -- New -- Project: Select ASP.net MVC 2 Web Application, click OK
Except default Create Unit Test Project
Open AccountController.cs under the Controllers folder, you should see 1 error in 1 file at the bottom of VS 2010

I check for updates via the drop down for Just Code.  I am running:
Version Q1 SP1 2010 (2010.1.415.1)

Visual Studio MSDN 2010 Professional:  Version 10.0.30319.1 RTMRel
.Net Framework
Version 4.0.30319 RTMrel

Hopefully this helps duplicate the problem.

Thanks,
David



using System;  
using System.Collections.Generic;  
using System.Diagnostics.CodeAnalysis;  
using System.Linq;  
using System.Security.Principal;  
using System.Web;  
using System.Web.Mvc;  
using System.Web.Routing;  
using System.Web.Security;  
using MvcChapter2a.Models;  
 
namespace MvcChapter2a.Controllers  
{  
 
    [HandleError]  
    public class AccountController : Controller  
    {  
 
        public IFormsAuthenticationService FormsService { getset; }  
        public IMembershipService MembershipService { getset; }  
 
        protected override void Initialize(RequestContext requestContext)  
        {  
            if (FormsService == null) { FormsService = new FormsAuthenticationService(); }  
            if (MembershipService == null) { MembershipService = new AccountMembershipService(); }  
 
            base.Initialize(requestContext);  
        }  
 
        // **************************************  
        // URL: /Account/LogOn  
        // **************************************  
 
        public ActionResult LogOn()  
        {  
            return View();  
        }  
 
        [HttpPost]  
        public ActionResult LogOn(LogOnModel model, string returnUrl)  
        {  
            if (ModelState.IsValid)  
            {  
                if (MembershipService.ValidateUser(model.UserName, model.Password))  
                {  
                    FormsService.SignIn(model.UserName, model.RememberMe);  
                    if (!String.IsNullOrEmpty(returnUrl))  
                    {  
                        return Redirect(returnUrl);  
                    }  
                    else 
                    {  
                        return RedirectToAction("Index""Home");  
                    }  
                }  
                else 
                {  
                    ModelState.AddModelError("""The user name or password provided is incorrect.");  
                }  
            }  
 
            // If we got this far, something failed, redisplay form  
            return View(model);  
        }  
 
        // **************************************  
        // URL: /Account/LogOff  
        // **************************************  
 
        public ActionResult LogOff()  
        {  
            FormsService.SignOut();  
 
            return RedirectToAction("Index""Home");  
        }  
 
        // **************************************  
        // URL: /Account/Register  
        // **************************************  
 
        public ActionResult Register()  
        {  
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;  
            return View();  
        }  
 
        [HttpPost]  
        public ActionResult Register(RegisterModel model)  
        {  
            if (ModelState.IsValid)  
            {  
                // Attempt to register the user  
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);  
 
                if (createStatus == MembershipCreateStatus.Success)  
                {  
                    FormsService.SignIn(model.UserName, false /* createPersistentCookie */);  
                    return RedirectToAction("Index""Home");  
                }  
                else 
                {  
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));  
                }  
            }  
 
            // If we got this far, something failed, redisplay form  
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;  
            return View(model);  
        }  
 
        // **************************************  
        // URL: /Account/ChangePassword  
        // **************************************  
 
        [Authorize]  
        public ActionResult ChangePassword()  
        {  
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;  
            return View();  
        }  
 
        [Authorize]  
        [HttpPost]  
        public ActionResult ChangePassword(ChangePasswordModel model)  
        {  
            if (ModelState.IsValid)  
            {  
                if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword))  
                {  
                    return RedirectToAction("ChangePasswordSuccess");  
                }  
                else 
                {  
                    ModelState.AddModelError("""The current password is incorrect or the new password is invalid.");  
                }  
            }  
 
            // If we got this far, something failed, redisplay form  
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;  
            return View(model);  
        }  
 
        // **************************************  
        // URL: /Account/ChangePasswordSuccess  
        // **************************************  
 
        public ActionResult ChangePasswordSuccess()  
        {  
            return View();  
        }  
 
    }  
}  
 
0
Svetlozar
Telerik team
answered on 25 May 2010, 08:05 AM
Hello David ,

Thank you for your response. That seems very strange. I have the very same configuration on my dev machine - Visual Studio 10.0.30319.1 and JustCode 2010.1.415.1 and I am not able to reproduce the problem. JustCode reports me "No errors in solution" of a default MVC2 Web Application (with the Unit Tests project).

Can you please try to Refresh the Analysis, from JustCode menu - Refresh Code Analysis, to see if the problem gets solved.

Do you have any additional Visual Studio plugins, that may interfere with JustCode?

Sorry for the inconvenience. We appreciate your assistance.

Sincerely yours,
Svetlozar Angelov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David
Top achievements
Rank 1
answered on 25 May 2010, 11:12 PM
Hi Svetlozar,

  I just try the refresh and it still reports the error.  I pasted the wrong class below.  The error is in the AccountControllerTest.cs at line 370.  The Visual Studio Error list does not show any errors.   

  The only additional plug I have current install is the Telerik Silverlight and ASP.net ajax. 

Here is the offending code:
 private class MockMembershipService : IMembershipService  
        {  
            public int MinPasswordLength  
            {  
                get { return 10; }  
            }  
 
            public bool ValidateUser(string userName, string password)  
            {  
                return (userName == "someUser" && password == "goodPassword");  
            }  
 
            public MembershipCreateStatus CreateUser(string userName, string password, string email)  
            {  
                if (userName == "duplicateUser")  
                {  
                    return MembershipCreateStatus.DuplicateUserName;  
                }  
 
                // verify that values are what we expected  
                Assert.AreEqual("goodPassword", password);  
                Assert.AreEqual("goodEmail", email);  
 
                return MembershipCreateStatus.Success;  
            }  
 
            public bool ChangePassword(string userName, string oldPassword, string newPassword)  
            {  
                return (userName == "someUser" && oldPassword == "goodOldPassword" && newPassword == "goodNewPassword");  
            }  
        } 
0
Accepted
Svetlozar
Telerik team
answered on 31 May 2010, 11:31 AM
Hello David ,

Thank you for your assistance.

It turned out that we do have a problem in our interface implementation analysis. The problem is that MembershipCreateStatus is marked with [TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")] and we don't handle correctly situations with moved types. We have logged the issue and it will be fixed for the next release. 

Sorry for the inconvenience.

Regards,
Svetlozar Angelov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David
Top achievements
Rank 1
answered on 01 Jun 2010, 05:59 PM
Thanks for the update
Tags
Code Analysis
Asked by
David
Top achievements
Rank 1
Answers by
Svetlozar
Telerik team
David
Top achievements
Rank 1
Share this question
or