Function: org-babel-csharp--format-refs

org-babel-csharp--format-refs is a byte-compiled function defined in ob-csharp.el.gz.

Signature

(org-babel-csharp--format-refs REFS)

Documentation

Format REFS into a string suitable for inclusion in a .csproj file.

REFS should be a list of strings or cons cells, each representing a reference. If an entry is a cons cell, the car denotes the reference name and the cdr is the version.

Returns a formatted string representing the references, categorized into project reference, assembly reference, and package reference. Reference types are distinguished by their file extension.
'.csproj' is interpreted as a project reference,
'.dll' as an assembly reference.
When a version is present, it will be treated as a package reference.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-csharp.el.gz
(defun org-babel-csharp--format-refs (refs)
  "Format REFS into a string suitable for inclusion in a .csproj file.

REFS should be a list of strings or cons cells, each representing a reference.
If an entry is a cons cell, the car denotes the reference name and
the cdr is the version.

Returns a formatted string representing the references, categorized into
project reference, assembly reference, and package reference.
Reference types are distinguished by their file extension.
'.csproj' is interpreted as a project reference,
'.dll' as an assembly reference.
When a version is present, it will be treated as a package reference."
  (let ((projectref)
        (assemblyref)
        (systemref))
    (dolist (ref refs)
      (let* ((version (if (consp ref)
                          (cdr ref)
                        nil))
             (ref-string (if (consp ref)
                             (car ref)
                           ref))
             (full-ref (if version
                           (file-truename (car ref))
                         (file-truename ref))))
        (cond
         ((string= "csproj" (file-name-extension full-ref))
          (setf projectref
                (concat projectref
                        (format "\n    <ProjectReference Include=\"%s\" />"
                                full-ref))))
         ((string= "dll" (file-name-extension full-ref))
          (setf assemblyref
                (concat assemblyref
                        (format "\n    <Reference Include=%S>\n      <HintPath>%s</HintPath>\n    </Reference>"
                                (file-name-base full-ref) full-ref))))
         (t (setf systemref
                  (concat systemref
                          (format "\n    <PackageReference Include=%s />"
                                  (if version
                                      (format "%S Version=%S" ref-string version)
                                    (format "%S" ref-string)))))))))
    (format "%s\n\n  %s\n\n  %s"
            (if projectref
                (format "<ItemGroup>%s\n  </ItemGroup>" projectref)
              "")
            (if assemblyref
                (format "<ItemGroup>%s\n  </ItemGroup>" assemblyref)
              "")
            (if systemref
                (format "<ItemGroup>%s\n  </ItemGroup>" systemref)
              ""))))