GithubHelp home page GithubHelp logo

Comments (5)

dguder avatar dguder commented on July 17, 2024

Hi, thanks for the hint. What's your proposal now?
Some thoughts:
What caused the error to show up right now? Was anything changed by perforce, so this error can happen? Maybe the command line output which is used to find the entries by the search patterns: "User name:", "Client name:", "Client host:", "Client root:" ? Unfortunately I don't have access to perforce so I can't verify this.

from nantcontrib.

bwojtowi avatar bwojtowi commented on July 17, 2024

There might be several reasons for this. However, I suspect one of the properties is null in the context I'm running the p4 command.
Amending the code to the below would be the first thing I’d try.

protected override void ExecuteTask() 
{

string[] find = {"User name:", "Client name:", "Client host:", "Client root:"};

string[] results = Perforce.GetP4Info(find);
if(results == null) throw new Exception(“Failed to retrieve P4 info.);
Project.Properties[User] = results.Length > 0 ? results[0] :unknown;
Project.Properties[Client] = results.Length > 1 ? results[1] :unknown;
Project.Properties[Host] = results.Length > 2 ? results[2] :unknown;
Project.Properties[Root] = results.Length > 3 ? results[3] :unknown;
}

from nantcontrib.

bwojtowi avatar bwojtowi commented on July 17, 2024

Also, It might be useful to add a parameterized task GetP4Info for retrieving individual info fields.

from nantcontrib.

dguder avatar dguder commented on July 17, 2024

Hi,
hmm.... IMHO this length check won't help since GetP4Info will always return a string array with length of find.Length. In addition the result will not be null either.

Could you please show me your output of your p4 info when you run it on your command line? As stated at p4 info docs the current implementation is still valid. Are you using a localized version?

from nantcontrib.

bwojtowi avatar bwojtowi commented on July 17, 2024

Assuming the “results” array is not null, not calling ToString() on each element would help in the sense it would retrieve the maximum information available instead of throwing a NullReferenceException. It's a good practice to implement validation in your code instead of relying on what thirdparty developers say. This issue itself shows why the best. That is the reason for additional checks to the length and results not being null. You never know in what context people may run it in the future.

I use standard version I believe.

Here’s the output my p4 info cmd line (I changed the environment specific values). It seems the Client Root is not there for some reason.

C:\Documents and Settings\user1>p4 info
User name: user1
Client name: currentbox
Client host: currentbox
Client unknown.
Current directory: c:\Documents and Settings\user1
Peer address: localIPAddress:clientport
Client address: localIPAddress
Server address: serverbox:serverport
Server root: /perforce/data
Server date: 2013/06/05 11:22:08 +0100 BST
Server uptime: 248:59:20
Server version: P4D/LINUX26X86_64/2012.2/538478 (2012/10/16)
Server license: licence details
Server license-ip: serverbox
Case Handling: insensitive

C:\Documents and Settings\user1>

from nantcontrib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.