I have this POGO class (simple putter getter) which I am trying to read in PowerShell
using System;
using System.Runtime.Serialization;
namespace MyApp.VM
{
[Serializable]
public class MyClassVM
{
public Int64 CtrId { get; set; }
public string CtrName { get; set; }
public string CtrPhone { get; set; }
public string CtrZip { get; set; }
public DateTime AddDate { get; set; }
}
}
Here is the ps1 code that is trying to read the class from a file.
function Build-Pogo
{
$FileDir = "D:\YourDirectoryOfPogo"
$ClassName = "MyClassVM"
$FileName = $FileDir + "\" + $ClassName + ".cs"
# Build the class from the file
$AllLines = [string]::join([environment]::newline, (Get-Content $FileName))
Add-Type -TypeDefinition $AllLines
# spin thru each property for class
$ClassHandle = New-Object -typeName $ClassName
$ClassHandle | ForEach-Object {Write-Host $_.name -foregroundcolor cyan}
}
* Note that the last line is a placeholder for more complex logic to come later.
This breaks into an Add-Type with this error message for every get / set in the file.
"MyApp.VM.MyClassVM.CtrId.get" must declare the body because it is not marked abstract or external
Any information on what I am doing wrong will be greatly appreciated.
Racer source
share