Skip to content

Commit 8f5116a

Browse files
author
Alon Fliess
committed
Fix no namespace bug
1 parent 079858e commit 8f5116a

17 files changed

+82
-840
lines changed

IoTHubClientGenerator/IoTHubPartialClassBuilder.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,15 @@ private void BuildPartialClass(string namespaceName, string className)
9797

9898
AppendLine("using IoTHubClientGeneratorSDK;");
9999
AppendLine();
100-
AppendLine($"namespace {namespaceName}");
101-
using (Block())
100+
if (namespaceName != "<global namespace>") //handle no namespace
101+
{
102+
AppendLine($"namespace {namespaceName}");
103+
using (Block())
104+
{
105+
CreateClass(className);
106+
}
107+
}
108+
else
102109
{
103110
CreateClass(className);
104111
}

IoTHubClientGeneratorDemo/IoTHubClientGeneratorDemo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
77
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
88
</PropertyGroup>

IoTHubClientGeneratorTest/IoTHubClientGeneratorTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
77
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace IoTHubClientGeneratorTest
2+
{
3+
public class TestNoNamespace
4+
{
5+
[TestCase("TestNoNamespaceDevice")]
6+
public static string NoNamespace =>
7+
@"
8+
using IoTHubClientGeneratorSDK;
9+
using Microsoft.Azure.Devices.Client;
10+
11+
[IoTHub()]
12+
partial class MyIoTHubClient
13+
{
14+
[Device]
15+
private DeviceClient MyClient {get;set;}
16+
}";
17+
}
18+
}

IoTHubClientGeneratorTest/TestRunner.TestCase.ForScenario.TestConnectionStatusProperty.received.txt

Lines changed: 0 additions & 59 deletions
This file was deleted.

IoTHubClientGeneratorTest/TestRunner.TestCase.ForScenario.TestConnectionStatusPropertyAndMethod.received.txt

Lines changed: 0 additions & 65 deletions
This file was deleted.

IoTHubClientGeneratorTest/TestRunner.TestCase.ForScenario.TestConnectionStringEnv.received.txt

Lines changed: 0 additions & 55 deletions
This file was deleted.

IoTHubClientGeneratorTest/TestRunner.TestCase.ForScenario.TestConnectionStringFromLocalVariable.received.txt

Lines changed: 0 additions & 57 deletions
This file was deleted.

IoTHubClientGeneratorTest/TestRunner.TestCase.ForScenario.TestDesiredProperties.received.txt

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)