MCPcopy Create free account
hub / github.com/Autodesk/AutomaticComponentToolkit / BuildBindingCSharp

Function BuildBindingCSharp

Source/buildbindingcsharp.go:48–109  ·  view source on GitHub ↗

BuildBindingCSharp builds CSharp bindings of a library's API in form of dynamically loaded function handles.

(component ComponentDefinition, outputFolder string, outputFolderExample string, indentString string)

Source from the content-addressed store, hash-verified

46// BuildBindingCSharp builds CSharp bindings of a library's API in form of dynamically loaded function
47// handles.
48func BuildBindingCSharp(component ComponentDefinition, outputFolder string, outputFolderExample string, indentString string) error {
49 forceRecreation := false
50
51 namespace := component.NameSpace
52 baseName := component.BaseName
53 libraryName := component.LibraryName
54
55 CSharpImpl := path.Join(outputFolder, namespace+".cs")
56 log.Printf("Creating \"%s\"", CSharpImpl)
57 CSharpImplFile, err := CreateLanguageFile(CSharpImpl, indentString)
58 if err != nil {
59 return err
60 }
61
62 err = buildBindingCSharpImplementation(component, CSharpImplFile, namespace, baseName)
63
64 if len(outputFolderExample) > 0 {
65 csharpExample := path.Join(outputFolderExample, namespace+"_Example"+".cs")
66 if forceRecreation || !FileExists(csharpExample) {
67 log.Printf("Creating \"%s\"", csharpExample)
68 csharpExampleFile, err := CreateLanguageFile(csharpExample, indentString)
69 if err != nil {
70 return err
71 }
72 csharpExampleFile.WriteCLicenseHeader(component,
73 fmt.Sprintf("This is an autogenerated CSharp application that demonstrates the\n usage of the CSharp bindings of %s", libraryName),
74 true)
75 buildCSharpExample(component, csharpExampleFile, outputFolder)
76 } else {
77 log.Printf("Omitting recreation of CSharp example \"%s\"", csharpExample)
78 }
79
80 csharpExampleSolution := path.Join(outputFolderExample, namespace+"_Example"+".sln")
81 if forceRecreation || !FileExists(csharpExampleSolution) {
82 log.Printf("Creating \"%s\"", csharpExampleSolution)
83 csharpExampleSolutionFile, err := CreateLanguageFile(csharpExampleSolution, indentString)
84 if err != nil {
85 return err
86 }
87 err = buildCSharpExampleSolution(component, csharpExampleSolutionFile, outputFolder)
88 if err != nil {
89 return err
90 }
91 } else {
92 log.Printf("Omitting recreation of CSharp example \"%s\"", csharpExample)
93 }
94
95 csharpExampleProject := path.Join(outputFolderExample, namespace+"_Example"+".csproj")
96 if forceRecreation || !FileExists(csharpExampleProject) {
97 log.Printf("Creating \"%s\"", csharpExampleProject)
98 csharpExampleProjectFile, err := CreateLanguageFile(csharpExampleProject, indentString)
99 if err != nil {
100 return err
101 }
102 buildCSharpExampleProject(component, csharpExampleProjectFile, outputFolder)
103 } else {
104 log.Printf("Omitting recreation of CSharp example \"%s\"", csharpExample)
105 }

Callers 1

createComponentFunction · 0.85

Calls 8

CreateLanguageFileFunction · 0.85
FileExistsFunction · 0.85
buildCSharpExampleFunction · 0.85
PrintfMethod · 0.80
WriteCLicenseHeaderMethod · 0.80

Tested by

no test coverage detected