You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64
VS Code version: 1.5.3
C# Extension version: 1.4.1
Steps to reproduce
Creating a class that inherits from another class.
Code used to create bug:
Animal.cs
using System;
namespace Zoolandia {
public class Animal
{
public string Type { get; set; }
public string Name { get; set; }
public string Height { get; set; }
public string Weight { get; set; }
public int NumOfLegs { get; set; }
public static void Sleep ()
{
Console.WriteLine("Animal is now sleeping");
}
public virtual void Init(){}
public virtual string SayGreeting()
{
return $"I am an animal!";
}
}
}
CarassiusAuratus.cs
namespace Zoolandia {
// https://en.wikipedia.org/wiki/Goldfish
public class CarassiusAuratus : Animal
{
public CarassiusAuratus()
{
this.HasScales = true;
this.CanSwim = true;
this.Name = "Goldie";
this.Init();
}
public CarassiusAuratus(string name = "Goldie")
{
this.HasScales = true;
this.CanSwim = true;
this.Name = name;
this.Init();
}
public CarassiusAuratus(int legs = 0)
{
this.HasScales = true;
this.CanSwim = true;
this.NumOfLegs = legs;
this.Init();
}
public CarassiusAuratus(string name = "Goldie", int legs = 0)
{
this.HasScales = true;
this.Name = name;
this.NumOfLegs = legs;
this.Init();
}
public bool HasScales { get; set; }
public bool CanSwim { get; set; }
public override void Init()
{
this.Type = "Carassius Auratus";
}
public override string SayGreeting()
{
return $"Hello, my name is {this.Name}! I am a {this.Type} and I swim! {base.SayGreeting()}";
}
}
}
Program.cs
using System;
using System.Collections.Generic;
namespace Zoolandia
{
public class Program
{
public static void Main(string[] args)
{
// Let's make some animals!
// No animals were harmed in the writing of this program.
List<Animal> myAnimals = new List<Animal>();
CarassiusAuratus myGoldie = new CarassiusAuratus("Goldie");
myAnimals.Add(myGoldie);
foreach(Animal myAnimal in myAnimals)
{
Console.WriteLine(myAnimal.SayGreeting());
}
}
}
}
Expected behavior
No red squiggle underline
Actual behavior
Red squiggle underline but compiles and runs properly without any errors or warnings.
The text was updated successfully, but these errors were encountered:
I've got the same issue. As soon as the class is wrapped by a namespace, I receive the visual error "The namespace ... already contains a definition for ... [netcoreapp1.0]"
Environment data
dotnet --info
output:.NET Command Line Tools (1.0.0-preview2-003131)
Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40e58
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64
VS Code version: 1.5.3
C# Extension version: 1.4.1
Steps to reproduce
Creating a class that inherits from another class.
Code used to create bug:
Animal.cs
CarassiusAuratus.cs
Program.cs
Expected behavior
No red squiggle underline
Actual behavior
Red squiggle underline but compiles and runs properly without any errors or warnings.
The text was updated successfully, but these errors were encountered: