Link to home
Start Free TrialLog in
Avatar of sushant d
sushant d

asked on

mysteriously code vanishes after build

during publish, out of below code one line is gets excluded . it's weird , does anyone else has seen such thing.
public JsonResult GetMethod(ProDetails criteria)
        {
            PResponseApp response = new PResponseApp();
            criteria.UserName = "21927198";  // this line disappears resulting in null value for username
            response = ProDetailsObjBL.GetProTerminal(criteria);
            return Json(response, JsonRequestBehavior.AllowGet);
        }
Avatar of ste5an
ste5an
Flag of Germany image

Code's normally written to be executed..

during publish, out of below code one line is gets excluded . it's weird , does anyone else has seen such thing.
What do you mean exactly?

public JsonResult GetMethod(ProDetails criteria)
{
    if (criteria == null)
        throw new ArgumentException("Oops.");

    PResponseApp response = new PResponseApp();
    criteria.UserName = "21927198";
    response = ProDetailsObjBL.GetProTerminal(criteria);
    return Json(response, JsonRequestBehavior.AllowGet);
}

Open in new window


btw, you have a lot of dependencies in that method.
Avatar of sushant d
sushant d

ASKER

thanks for the reply, what I mean is from the code above , below line (when I decompile the assembly & check ) is not seen, this happens only after publish

criteria.UserName = "21927198";

Open in new window


also the above object's other properties persist value, the object is not null
Sure that you looked at the correct compilation result?

How is the UserName property defined?
Yes I  checked the relevant result. the occurrence is not consistent and random. userName is simple string .

actually I'm reviewing someone's code. is it even possible to happen ? I've seen it first time such selective code exclusion
Three possible reasons:

- Your way to compile code is not reliable. And you looked at a piece of compiled code create from a different source version.
- VS didn't think it needs to compile that part.
- It's dead code.

Two thinks which should help:
- Unit tests.
- Clean builds.
Do you have the file open somewhere else?
Hi Shaun, no the file isn;t open . the above behavior repeated today with a different project as well .a newly added object property & few lines of associated code did not get included in the published version.
somehow it seems an older version of file is getting referred to. but don't know how, since in publish routine only local/workspace code is considered despite the same being present in source control
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.