简体   繁体   中英

TFS Build -Error CS1002: ; expected and Error CS1519 Invalid token

I built my solution properly in Visual Studio, but when I build with TFS, I have several errors such as:

path\file.cs (8, 47)
path\file.cs(8,47): Error CS1002: ; expected
path\file.cs (8, 85)
path\file.cs(8,85): Error CS1519: Invalid token '(' in class, struct, or interface member declaration

Screen: 在此处输入图片说明

namespace path
{
    public class file : Ifile
    {
        public IContactService ContactService => Locator.GetService<IContactService>();
        public IAddressService AddressService => Locator.GetService<IAddressService>();
    }
}

Thank you for helping me!

public IContactService ContactService => Locator.GetService<IContactService>();

This is an expression-bodied property and is implemented only in CSC 6 and later. Your TFS is probably running CSC 5 or earlier. You have to change it to:

public IContactService ContactService
{
    get { return Locator.GetService<IContactService>(); }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM