/// <inheritdoc/> public void Load(ICSharpWorkspace workspace, ICSharpFile file) { if (file == null) { throw new ArgumentNullException(nameof(file), $"The argument {nameof(file)} was null."); } ((CSharpFile)file).Load(); }
/// <inheritdoc/> public void Load(ICSharpWorkspace cSharpWorkspace, ICSharpAssembly assembly) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly), $"The argument {nameof(assembly)} was null."); } ((CSharpAssembly)assembly).Load(); }
/// <inheritdoc/> public void Load(ICSharpWorkspace workspace, ICSharpProject project) { if (project == null) { throw new ArgumentNullException(nameof(project), $"The argument {nameof(project)} was null."); } ((CSharpProject)project).Load(workspace); }
/// <summary> /// Initializes a new instance of the <see cref="ModelGeneratorExample"/> class. /// </summary> /// <param name="logger">The logger to log the output messages.</param> /// <param name="workspace">The workspace to use to load the project data.</param> public ModelGeneratorExample(ILogger <ModelGeneratorExample> logger, ICSharpWorkspace workspace) { this.logger = logger; this.workspace = workspace; }
/// <summary> /// Initializes a new instance of the <see cref="ToolsGenerator"/> class. /// </summary> /// <param name="logger">Logger that will be used for logs.</param> /// <param name="workspace">The workspace to use.</param> public ToolsGenerator(ILogger <ToolsGenerator> logger, ICSharpWorkspace workspace) { this.logger = logger; this.workspace = workspace; }
/// <summary> /// Load the project. /// </summary> /// <param name="workspace">The workspace within the project is loaded.</param> public void Load(ICSharpWorkspace workspace) { if (workspace == null) { throw new ArgumentNullException(nameof(workspace), $"The argument {nameof(workspace)} was null."); } if (this.isLoaded) { return; } this.isLoaded = true; this.DotNetRestore(); // Get the project data. var projectDataStr = this.DeployAndRunTarget(ProjectData); projectDataStr = projectDataStr.Replace(@"\", @"/"); var projectData = JsonConvert.DeserializeObject <CSharpProjectData>(projectDataStr); this.RootNameSpace = projectData.RootNamespace; var projectAssetsFilePath = projectData.ProjectAssetsFile; var projectAssets = JsonConvert.DeserializeObject <ProjectAssets>(File.ReadAllText(projectAssetsFilePath)); var assemblies = new List <ICSharpAssembly>(); var compileItems = projectAssets.Targets.First().Value.GetAllPackageCompileItems(projectAssets); foreach (var compileItem in compileItems) { var assemblyFile = GetAssemblyFile(projectAssets, compileItem); var registeredAssembly = workspace.RegisterAssembly(assemblyFile); if (registeredAssembly != null) { assemblies.Add(registeredAssembly); } } this.Assemblies = assemblies; // Get the project references. this.ProjectReferences = ( from project in projectData.ProjectReferences select workspace.RegisterProject(PathHelper.ResolveRelativePath(this.ProjectPath, project))) .ToArray(); // Make sure the project references are loaded. foreach (var projectItem in this.ProjectReferences) { ((CSharpProject)projectItem).Load(workspace); } // Once project references are loaded, we can get the files to compile. this.Files = ( from file in projectData.CompileList select workspace.RegisterFile(PathHelper.ResolveRelativePath(this.ProjectPath, file))) .ToArray(); }
/// <summary> /// Initializes a new instance of the <see cref="EntityGeneratorExample"/> class. /// </summary> /// <param name="logger">The logger to log the output messages.</param> /// <param name="workspace">The workspace to use to load the project data.</param> public EntityGeneratorExample(ILogger <EntityGeneratorExample> logger, ICSharpWorkspace workspace) { this.logger = logger; this.workspace = workspace; }