Skip to content

ProjectItem.Save(null) throws ArgumentNullException: Value cannot be null.  #483

Closed

Description

@jcansdale

I think null should be valid because the FileName parameter is optional:
FileName Type: System.String
Optional. The name with which to save the project or project item.
https://msdn.microsoft.com/en-us/library/envdte.projectitem.save.aspx

Here is the exception:
[5076] Parameter name: fileName ---> System.ArgumentNullException: Value cannot be null.
[5076] Parameter name: fileName
[5076] at Microsoft.VisualStudio.FSharp.ProjectSystem.Automation.OAFileItem.<>c__DisplayClass8.b__9()
[5076] at Microsoft.VisualStudio.Shell.InvokableAction.InvokeMethod()
[5076] at Microsoft.VisualStudio.Shell.InvokableBase.Invoke()
[5076] --- End of inner exception stack trace ---
[5076] at Microsoft.VisualStudio.Shell.ThreadHelper.InvokeOnUIThread(InvokableBase invokable)
[5076] at Microsoft.VisualStudio.Shell.ThreadHelper.Invoke(Action action)
[5076] at Microsoft.VisualStudio.FSharp.ProjectSystem.Automation.OAFileItem.DoSave(Boolean isCalledFromSaveAs, String fileName)
[5076] at Microsoft.VisualStudio.FSharp.ProjectSystem.Automation.OAFileItem.Save(String fileName)

Activity

  1. enricosada commented on Jun 8, 2015

    @enricosada
    Contributor

    Got a fix for this one

  2. latkin commented on Jun 10, 2015

    @latkin
    Contributor

    The linked doc is for EnvDTE.ProjectItem, but you are invoking on our OAFileItem. The latter indeed derives from the former, but docs for OAFileItem indicate that empty string is all that's expected to be handled at the OAFileItem level.

    Other VS project systems based on the same MPF skeleton as F# have the same behavior (throw on null):

    So practically speaking, extensions should not rely on null being supported. Maybe we will support it, but it's not a particularly high-priority case.

  3. enricosada commented on Jun 11, 2015

    @enricosada
    Contributor

    is more a compatibility fix with c# project system ( like some other hack ), but harmless

  4. added this to the F# 4.0 Update 1 milestone on Aug 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions