C # Visual Studio unknown build error

0

I was refactoring my code in C # that was working perfectly, but it was gigantic, and it stopped working and visual studio does not describe the error in any corner. Below is my code and Visual Studio.

Visual Studio Console PrintScreen

TicketController-Mycontroller

usingsgtalk.api.Helpers;usingsgtalk.api.Models;usingSystem.Net;usingSystem.Net.Http;usingSystem.Web.Http;usingSystem.Web.Http.Cors;namespacesgtalk.api.Controllers{[EnableCors(origins:"*", headers: "*", methods: "*")]
    public class TicketController : ApiController
    {
        public HttpResponseMessage Get()
        {
            //TicketRepository.GetAll(lg)
            HttpResponseMessage resp = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest
            };

            if (LoginHelper.isLogged(Request, out LoginTransmit lg))
            {
                //    resp = new HttpResponseMessage()
                //    {
                //        StatusCode = HttpStatusCode.OK,
                //        Content = new StringContent(JsonConvert.SerializeObject(new { }))
                //    };
            }
            else
            {
                resp = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.Unauthorized
                };
            }

            return resp;
        }
    }
}

By analyzing the code a little, I discovered that the error is on the line

LoginHelper.isLogged(Request, out LoginTransmit lg)

Removing this line compiles the program.

LoginHelper - The owner of the above line

using sgtalk.api.Models;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;

namespace sgtalk.api.Helpers
{
    public static class LoginHelper
    {
        public static bool isLogged(HttpRequestMessage r, out LoginTransmit l)
        {
            l = null;
            var ret = false;
            if (r.Headers.TryGetValues("X-Access-Token", out IEnumerable<string> headerValues))
            {
                var s = headerValues.FirstOrDefault();
                l = TokenHelper.Decode(s);
                ret = true;
            }
            else
            {
                ret = false;
            }
            return ret;
        }
    }
}

What's happening? I've been trying to resolve for more than an hour, but I can not find exactly where the error is.

Update: With "stopped working" I mean it does not compile anymore.

Update 2: In the console it lists the following errors:

  C: \ Users \ marcio.nicolau \ documents \ visual studio 2017 \ Projects \ sgtalk \ sgtalk.api \ Controllers \ TicketController.cs (51,61,51,63): error CS1003: Syntax error, ',' expected

On these lines, you have these codes:

public HttpResponseMessage Get()
        {
            //TicketRepository.GetAll(lg)
            HttpResponseMessage resp = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest
            };
//linha 51
            if (LoginHelper.isLogged(Request, out LoginTransmit lg))
            {
                //    resp = new HttpResponseMessage()
                //    {
                //        StatusCode = HttpStatusCode.OK,
                //        Content = new StringContent(JsonConvert.SerializeObject(new { }))
                //    };
            }
            else
            {
                resp = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.Unauthorized
                };
            }

            return resp;
        }
  c: \ Users \ marcio.nicolau \ documents \ visual studio 2017 \ Projects \ sgtalk \ sgtalk.api \ Helpers \ LoginHelper.cs (14,74,14,80): error CS1525: Invalid expression term 'string'

public static bool isLogged(HttpRequestMessage r, out LoginTransmit l)
        {
            l = null;
            var ret = false;
            if (r.Headers.TryGetValues("X-Access-Token", out IEnumerable<string> headerValues)) //Linha 14
            {
                var s = headerValues.FirstOrDefault();
                l = TokenHelper.Decode(s);
                ret = true;
            }
            else
            {
                ret = false;
            }
            return ret;
        }

Update 3: I'm using .NET Framework 4.6

    
asked by anonymous 21.07.2017 / 19:08

1 answer

2

What version of C # are you using? If it is earlier or equal to 6.0, try doing this:

LoginTransmit lg;
LoginHelper.isLogged(Request, out lg);
    
21.07.2017 / 19:11