Open vsfeedback opened 7 months ago
Here is a repro case extracted from comments by the author. In this code, copying a line that references ClassLibrary23.data.Task
using the simple name Task
inside the ClassLibrary23.data
namespace, and then pasting that line into a different namespace, does not correct the type reference. The user appears to be requesting that we apply the complexify/simplify process during copy/paste operations.
namespace ClassLibrary23
{
namespace data
{
internal class Task;
internal class CopyFrom
{
public void testMethod()
{
// Copy this line
Task t = new();
}
}
}
public class CopyTo
{
public void testMethod()
{
// Paste here
}
}
}
The pasted text is:
data.Task t = new();
The pasted text is the following, and Task
has changed to a different meaning from the source text.
Task t = new();
This issue has been moved from a ticket on Developer Community.
[severity:It bothers me. A fix would be nice] C#/. In .NET 8, there is a GlobalUsing feature, and the Task class for async is covered by it.
Currently, as an application, create a data folder in your project, In it, I created a Task class, etc. (belonging to the namespace represented by the default namespace + data).
From a class in the root folder of your project (which belongs to the default namespace), you can use the It uses the Task class in the data folder and the Task class for async. At this time, the Task in the data folder is data. It is distinguished by using it as a Task.
I copied this program to another class in the same root folder. The namespace handled by the data folder is automatically completed. This creates an ambiguity between the Task and the automatically added namespace. I get a compile error. "using data=default namespace.data;" Even if you write it in advance, it will be added.
Each time, you can either manually remove the automatically added namespaces, or you can use the You must turn off the auto-add namespace feature. I don't think you should arbitrarily add a satisfying using.
Original Comments
Feedback Bot on 12/6/2023, 02:02 AM:
(private comment, text removed)
Adam Ratzman [MSFT] on 12/7/2023, 09:42 AM:
(private comment, text removed)
すふぃあ S on 12/7/2023, 05:55 PM:
(private comment, text removed)
Feedback Bot on 12/14/2023, 10:07 AM:
(private comment, text removed)
Feedback Bot on 2/8/2024, 02:16 PM:
(private comment, text removed)
Adam Ratzman [MSFT] on 2/8/2024, 02:41 PM:
(private comment, text removed)
Original Solutions
(no solutions)